Wirehead Studios

Wirehead Modifications => General Development ('Laced Neptune') => Topic started by: Tabun on 2005-04-07, 00:37

Title: Tab's Q3 modelling tips and comments (no discussion)
Post by: Tabun on 2005-04-07, 00:37
This thread is intended for anyone making or about to make Q3 models of any kind.

last update: 2006-08-20
(added sections below the marker)

Modelling is for a very very large chunk the constant and precise avoidance of bugs, quirks and limits of the tools used. Instead of it being the creative and enjoyable process model creation is supposed to be, it can be frustrating and mind-boggleing, which is why I take careful note of tricks that work, and tricks that destroy your work, crash your system and throw your computer out of the window. (okay, it is actually the user doing that last bit, but I don't mind if one doesn't admit this)

The tools in question are the following (for I use them):

  • 3D Studio max (v4.2 in my case)
  • Character studio (v2.5)
  • Npherno's MD3 Compiler and MD3 Viewer
  • The Pop 'n Fresh MD3 Export plugin (recompiled 3dsmax 4 version)
  • MD2 and MD3 import 3dsmax import scripts
  • meshtools
  • Quake 3 (Is that even a tool? Well, [i]you[/i] are a tool, so.. why not?)

Until I have enough material to write a decent book or a lengthy tutorial, I'm just going to slap bits and pieces together, and make a list of interesting or important tidbits, creating a small knowledgebase.
Additions and suggestions can be made in here, but will be removed after they've been adressed or incorporated in this post, to prevent clogging.

Good links, overall
- http://www.planetquake.com/polycount/resou...tutorials.shtml (http://www.planetquake.com/polycount/resources/quake3/tutorials.shtml)
- http://www.planetquake.com/polycount/resou...ke3/tools.shtml (http://www.planetquake.com/polycount/resources/quake3/tools.shtml)
- http://www.4thdimented.com/dimented_tutori...ialQuake3_1.htm (http://www.4thdimented.com/dimented_tutorialQuake3_1.htm)
- http://merlin.zsnes.com/tutorials/export/index.html (http://merlin.zsnes.com/tutorials/export/index.html)

Setting up Max
3D Studio Max is a complex application (and yes, I know Maya/Lightwave etc. are better, but if you know that, why read this? :]).

To get quake unit scaling go to the 'customize' menu, 'Grid and Snap'.
Make your home grid - grid spacing: 8, so that every gridline == 4 units in Quake.

Some other settings I prefer are the following:
- For every object, I like to set it to not 'show frozen in gray', so transparant bits stay transparant when you freeze them, etc. (in object properties)
- I like to set all my viewports to show edges, not show selection's bounding boxes and I want to 'shade selected faces'. (viewport settings)

For unwrapping (dang, you have to do this every time), you'll want to have a 'constant update in viewports'. (unwrap settings)

MD3 Importing
If you get errors trying to import MD3's using the MD3 import script stating things like 'undefined such and such', the MD3 is most likely exported using the pop 'n fresh exporter, without recompiling/fixing it afterwards. The latter can be done with Npherno's MD3 compiler.
Related links:
- http://www.4thdimented.com/dimented_tutori...ialQuake3_5.htm (http://www.4thdimented.com/dimented_tutorialQuake3_5.htm)
- http://www.planetquake.com/polycount/resou...max-to-q3.shtml (http://www.planetquake.com/polycount/resources/quake3/tutorials/max-to-q3/max-to-q3.shtml)

MD2 Importing
MD2 importing, using the import scripts, can be a hassle too. If you find that there gaps in the loaded data (way too few frames, choppy animation), select New All and re-import the md2. You'll note it is (probably) correct now.
Lesson learned?
Never import anything directly into a scene your working with, unless you know exactly what you are doing - sometimes you can select the imported stuff and simply delete, sometimes everything crashes and you lose hours of work. Oh. And save regularly. Very. Regularly. But that goes without saying and is not directly related to this problem ;]

Unwrapping in Max
When unwrapping in 3D Studio Max, be sure to collapse the stack regularly, to prevent crashes, dataloss and other unwrapping problems.
- See also my unwrapping tutorial (http://www.tabun.nl/max_unwraptut).

Physique does NOT like mistakes
Once you apply the physique modifier to an object, make sure you test it as good as you can manage, without going into details - there is no going back. Fixing anything but the most minimal of vertex position shifting will destroy your vertex assignments. If you get halfway through rigging a model, and you suddenly discover an unwanted overlap on your UVW map, either live with it or face having to re-rig the entire model (object) again. Be warned.

Max axis vs Q3 world axis
In Max, the viewport "Right" represents the Q3-Front viewpoint, and the "Front" viewport is thus the view from the left of the object. That means that anything you want to have facing to the 'front' in quake 3, will have to be turned 90 degrees counterclockwise around the z-axel.

Max axis and Steed's .bips
(If you didn't know, .bips are movement files for Character Studio, and Steeds .bips contain all the player model movements as shown in-game. Rig a model, load the "Sarge" .bip, and your model moves exactly like sarge does. Very useful as a base, and for testing.)
After you load up a .bip, you'll note the model now faces the right way in Max and thus, the wrong way in Q3 (Why Steed? For The Love Of Quake - Why?).
If you don't feel like repositioning everything manually (and thus destroying the animation), do the following:
1. FIRST make any changes you want to make, and SAVE, then
2. select all the parts of the Biped (ONLY those parts) and Group them. Then, select rotation mode, use the "world"-pivot and make sure the "Transform Coordinate Center" is selected (right next to it). Enter an Offset:World value of 90 degrees for the Z-axel, and you're done. You can now export the bits of the model. You cannot edit the animation at this point, because the links are messed up - don't save over anything, after you're done animating.
Phoenix deserves a big hug for this one.

Mirroring objects in 3D Studio Max
Speaking of which, for information on what to do when/after mirroring stuff for later MD3 exporting, see Phoenix's thread: http://forums.wireheadstudios.org/index.ph...t=ST&f=11&t=121 (http://forums.wireheadstudios.org/index.php?act=ST&f=11&t=121)

How to use the MD3 Viewer
Because it's hardly a user (or newbie-)friendly tool, here are some tutorials on the basic usage of the MD3 Compiler and the MD3 Viewer by Npherno. The second tutorial is useful for when you only want to change skinpaths (which is nescessary for mapobjects, weapons etc, but not for player models).
- http://www.tabun.nl/tools/md3viewer_tutorial/ (http://www.tabun.nl/tools/md3viewer_tutorial/)
- http://www.tabun.nl/tools/md3skinpath_tutorial (http://www.tabun.nl/tools/md3skinpath_tutorial)

Max Crashes in vertex editing mode - Editable Mesh
If you have problems with Max's stability, and it typically only crashes in a specific editing mode (for me, it was in vertex editing mode, but in principle the same goes for any of the other modes) and you do not know how to fix this, try converting the model to editable poly (or nurbs, if you prefer?) to do those things which could otherwise crash the program.   
Obviously this is only an acceptable solution if you do not feel like re?nstalling Max and you know of no other way to prevent crashes.

Editable poly and related problems
I use editable poly mode with meshtools, because it rocks for effici?nt shape control. None of the tools  seem to mind, but there is something you have to be on the lookout for; if you have polygons with more than 3 vertices (ie. squares for you nutty sub-div modelers), either your export will fail, or worse, Q3 will give you incomprehensible error codes. (something about exceeding poly limits, which only makes sense if you know what you're looking for)

Now, before you go and connect ALL the vertices, consider this more economic method:
- Convert the objects to editable mesh, select all edges and click the button labeled 'visible' (scroll down if you don't know it), to make them.. well.. visible edges. You can convert back to editable poly, or make use of the edge-turning tools available in editable mesh (which is what I do).
- Already physique'd your model? Oh dear. But wait, it can still be done. Do not collapse the physique modifier, but select the 'Editable poly' modifier underneath it. Then apply a new modifier 'Turn to Mesh' and collapse only that. If you're lucky, turning an edge or two does not affect your vertex assignments but do not count on it, my friend. The above physique tale still goes.

Npherno's compiler-slashes
If you're fixing an MD3, remember to use forward slashes. The compiler will (for unfixed MD3's) show backslashes, but you will need to replace them by forward slashes for shaders and textures to work properly in Quake 3.


Npherno's compiler; quirks
One of the things that may have happened to you is this: You set a skin path in the proper way in the compiler, then export the md3. All of a sudden, one of the skin paths is missing! This can be particularly annoying when dealing with large model files, since you have to do it all over again. Here's how I prevent it:
1) I make sure to press Return after editing the skin paths (I know, this is the 'forgetful noob' problem).
2) I select something that either doesn't need a skin path, or already had one upon import from the drop down menu, before exporting. It seems that Npherno ignores the skin path of the object you have selected upon exporting, for no apparent reason whatsoever.

(see Footsies on the Floor)

Npherno's compiler; Footsies on the Floor (edited)
Whenever you've managed to get a player model into Quake 3, make sure its feet touch the floor. If you do everything perfectly in Max, your model will hover 24 units above the ground - You can fix this with Npherno's MD3 Compiler, by offsetting Y to -24. Yes, you read that correctly, you have to modify the Y-axis value. Don't ask me why. The following is important: make sure you have the l_legs (or whatever it is called) selected when you do this (but don't forget to check the two checkboxes in the align/offset window), otherwise it'll mess up the operation.

Using 3d Studio Max: Interface
Important to know for animation: scaling the track bar (with the time/frame slider on it) can be done by holding CTRL + ALT and using the right and left mouse buttons. Each mouse button scales from one end of the track bar.

Character Studio
One of the quirky oddities of CS is the way keyframes work. Officially, normal keyframing "shouldn't work". I find that (at least in 3d Studio Max 8) Autokey mode works for everything but the biped core. You know, the little diamond-shape at the hip, which controls the position of the biped. This has to be animated using the track selection submenu (motion panel). Setting keys without selecting the horizontal/vertical/rotation track will either give you no or at most erratic results. Keep this in mind and you won't slip up.

Character modeling: modeling for animation
Hip joint: more vertices at the backside, less in the front (this will always be a sucky joint with CS-Biped).

MD3 Exporting
3d Studio Max 8 exports MD3s with the max6-md3exporter (an adaptation of the old pop 'n fresh exporter). It is said to have been improved, but this is certainly not the case for all aspects of the exported model. You will probably need to reimport it in an older version of Max, then re-export it, to get it right.
a. The files are quite huge, for some reason. I don't know what extra data is being stored, but a 400Kb model file will quickly turn into a 1.2Mb model with the new version.
b. It crashes Q3 when the exported data is used out of the 'box'. This is typical, but this time, Npherno's compiler does not help.

Using old installations of 3D Studio Max R4.2
I used to simply install 3D Studio Max, then copy over the old directory from a previous install, and voila: everything works just the way it used to. Excellent for saving time when reinstalling your OS. When I tried it  after switching from Windows 2000 to Windows XP Corporate, however, it didn't exactly work. First of all, the C-Dilla copy protection didn't work under XP, so that had to be patched (that's not too difficult, just Google it or go straight to the Max website to find the patch for XP).
Stranger was that some features (such as using the rotation modifier) didn't work. The solution to this odd quirk was to open up the main .ini of the fresh install as well as the old .ini of the previous installation, and manually edit the new one until it suited me. It's a few minutes of work, but it works.

Title: Re: Tab's Q3 modelling comments
Post by: Phoenix on 2005-04-07, 09:15
Also, here are direct links to some useful import and export utilities and a few helpful tips from the bird:

q3-md3.ms (http://www.wireheadstudios.org/phoenix/editing/q3-md3.ms)
md2Export.ms (http://www.wireheadstudios.org/phoenix/editing/md2Export.ms)
importmd2.ms (http://www.wireheadstudios.org/phoenix/editing/importmd2.ms)

Put these in your scripts/startup folder.  They'll be available on the right-side menu.  Click the Hammer icon and use the Max Script dialogue.  The MD3 and MD2 importers were written by Chris Cookson.  I forget who wrote the md2 exporter, read the credits I guess.  The original importers  both had a problem importing the UVW mapping.  I've corrected it in both of the importers.  The md3 import needed a fixed offset, the md2 export needed a dynamic offset.  Should work fine for importing texture maps at this point.

Note that when using either, if you didn't catch it above, you cannot accept the first import if you have any frames in the model.  It will set the length of time incorrectly and your frames will be screwed up.  Import, do a "New" with "all", and re-import and you'll be fine.  Also note that if you export a non-player model that needs a specifically linked texture, like a rocket or weapon, the Pop'n'Fresh md3 exporter has a limit to how long the skin name can be, so when you go to use nPherno's MD3 compiler to clean it up watch your skin name so it doesn't get truncated.

Any time you export an md3 from Max it will have incorrect normals.  This will affect how the model is lit in-game.  I know this was supposed to have been fixed, but it was not.  Here's what you do:

1) Load the model into nPherno's md3 compiler.
2) Go through and correct any skin links that may be required, and make sure your object names are what you want them to be (important for player models!)
3)  Do a "select all".  Note:  It is important you fix the links BEFORE doing a "select all".  nPherno's has a tendency to "undo" your typing if you don't do it in that order.
4)  Select "Rebuild Normals", and click the "ignore UVW splits" checkbox.  This will give your model a nice uniform normal mapping, and you'll notice the color pattern change in the viewer window.
5)  Select "Export Objects" to save your file.  The "internal name" dialogue box doesn't seem to really do much for actual usage in-game, so you can leave that blank if you wish.

If you have trouble importing an md3 into Max, try doing the above procedure on it.  I've found that an md3 that's exported using Pop'n'Fresh's md3 exporter has about a 50% chance of not re-importing into Max, however every md3 I've run through nPherno's compiler WILL import into Max without any errors (unless Max decides to be stupid and crash).

One last note - the position offset tools in nPherno's compiler DO NOT WORK.  Do your position offsets in Max first, then do your export.  It would have been nice if he had finished the compiler, but even in it's somewhat incomplete state it's an indespensible tool.

Title: Re: Tab's Q3 modelling comments
Post by: Phoenix on 2006-08-20, 15:59
Regarding Pop'n'Fresh's exporter for Max, I've found the one (supposedly) fixed by Chris Cookson does not work correctly.  When I tried exporting our BFG9000 model, I found I could see the edge turn direction on some flat surfaces that I could not ever see before.  If a surface is a flat plane, edge direction should be irrelevent.  What I noticed on inspection of the model is that flat planes were no longer flat.  Apparently this version of the exporter screws up vertex positions, which was effectually turning my nice planar geometry into a miniature terrain system.  Why, I have no idea, but I have a feeling it's a rounding or decimal precision issue, and it was worse than md2 export rounding out of Q2Modeler.

I have a feeling that any later versions for Max were based on this buggy version of the exporter, which is a bad thing.  The ONLY version I've found that works right for exporting is the TiCal tweaked version for Max 4 and prior.  Yes, you have to use Npherno's to fix the normals and texture paths, but even the normals still don't light correctly with the Chris Cookson version.  At least, they do not light the way Id's models do.