Hints, tips and tutorials for 3D modelling & content creation
|
KatsBits
Creating 3D models, meshes &
game content
3D modelling & meshing, level editing and textures makingHints, tips and tutorials for 3D modelling & content creation [back]Getting custom models into Doom 3 engined gamesResourcesThe tools used for the following tutorial are as follows; (*note : replace these with tools/scripts of your choice. '#' recommended) Contents
Getting custom models into game ^When you first try messing around with Doom 3s built in editor it seems quite clunky and difficult to find where things are it's changed since Q3Radiant (the Quake 3 editor), one of which is loading models into Doom3Ed. Basically there are now two ways of loading a model into a map via the editors own model loader/viewer or loading the mesh directly onto a func_static brush object - gone is the old misc_model entity of Quake 3 editing. These methods will be covered in more detail further on but suffice to say now, using either/or method has the same end result; a model in the map. What's this about then? ^This article is going to outline the process of getting custom models into Doom 3, these are models you've created yourself with 'X' 3D modelling application (Max, gmax, LightWave, Maya, Blender, Wings etc. etc.). There are basically two types of model, animated and static, we're going to deal with static meshes in the following. The basic process is to make a model, export it to a format Doom 3 understands, (optional depending on texture assets available : write a material file that contains texture information) load the model into the editor, compile the map and run ingame. Blender setup ^It's also assumed that you know how to run scripts in Blender3D and that you have it set up correctly to do so or your app of choice. Setting up Blenders grid ^![]() Changing GRID setting Blender has this neat little feature, that usually goes unnoticed, which can be tricky to set up in other 3D apps; you can set the grid to mirror the unit based measurement system of Quake 3 and Doom 3 by altering the 'Spacing' info (highlighted in green opposite) of the background grid plan. This in theory means when you start to model you'll basically be using the same units of scale as Doom 3 so objects will match.
With this in mind, to match the default QeRadiant and GTK Radiant grid settings in Blender you need to edit the settings so 'Spacing' reads as '8.00' (as indicated opposite). You should then find the 'Clip End' distance can be increased quite a bit to allow for larger sized models to be worked on
A model citizen ^It's assumed here that you have a object ready to roll and modelled using quad based polygons. It also needs to have been UVWmapped and then UVWunwrapped with at least a basic textured material (a material that contains a 2D texture).
![]() Completed model of a wooden corner support ready for exporting - note the models position relative to the XYZ grid, it's placed so the centre of mass is at the 0,0,0, point to allow for the model to be buried into brushwork without burying the origin point (which would be where the 0,0,0, point currently is) and resulting in 'leak' errors at compile time. Prepping the model ^We're going to be using the USM Unreal Tournament ASE export script for Blender3D by Doc Holiday. The good thing about this particular script is that the interface shows you any errors *before* you export a model. Design note : Goofos's ASE export script can also be used and is in fact the prefered method over the now obsolete USM Exporter If you try to export the model now, the chances are it'll throw up a few warning flags relate to certain aspects of the mesh, usually this will be to do with the presence of quad ('quad'ratic - 'quads' for short) polygons in the mesh - see image below showing quads selected. Design note : Goofos's ASE exporter will automatically triangulate a mesh. It's prefered that this be done manually. ![]() Original quad based polygon model These need to be removed by converting the mesh to an object wholly composed of triangular polygons ('tris' for short), the reason for doing this is because of the way a quad is made; the corner to corner edge through the centre of the face - which you don't normally see - can follow a diagonal in more than one direction, this means the game engine can't determine where that diagonal edge is at any given time using just the corner vertex points without additional data. Triangulating a mesh ^Depending on what 3D app you're using converting quads to triangles may vary. In Blender3D you need to have all the vertices selected ('A') in editmode and then hit keyboard Ctrl+T, this will force triangulation of the whole mesh. Incidentally you can convert triangles back into quads using Alt+J (but you have to do this one 'quad' at a time, otherwise you can't control which triangles get merged with their neighbour). ![]() ...after triangulation Once you've triangulated the mesh you should end up with something similar to the above - the yellow outline is the main 'quad' (made now from 2 triangles); the orange line the edge added by triangulation. Edge 'turning'/Edge 'flipping' in Blender ^You may notice after triangulating the mesh the new distribution of polygons has created some odd 'indentations' where the corner to corner edge cuts across the surface (the orange line in the image above). The next step is to correct these and check the orientation of the triangles so we give the mesh a more shapely appearance. Doing this means flipping or turning edges. In editmode simply select the corner vertices for the corresponding faces and press Ctrl+F, you'll see the edge between the two polygons change orientation. Be careful doing this though as you can crash Blender by trying to flip and edge into a weird placement.
Just go round the whole model checking to see if the edges are giving the mesh the shape it needs. Once you've done that the next thing to do is the smooth groups. Smoothgroups and game models ^If you were to export the model in it's current state you'd find it wouldn't be lit correctly ingame, this is because Doom 3 is using the information it reads about the smooth groups from a 'solid' object. What this means is that Doom 3 reads how light gets distributed over an objects surface (polygon to polygon) by using smoothgroups so if you leave an object as one big grouping the lighting will be distributed relative to that, causing weird side effects ingame (usually it results in an object only being lit correctly from underneath or from behind, but other visual artefacts occur). To correct this the mesh needs to be 'split', this is done using the split mesh command. Forcing smoothgroups using 'Split Mesh' ^Although Blender has various options to set different and variable smooth groups for 'internal' use, i.e.. within the Blender environment itself, splitting a mesh is the only way to guarantee wysiwyg ingame. What this basically does is physically detach selected faces into their own sub-mesh (to use 3DS Max terminology) whilst keeping it part of the parent mesh; i.e.. the mesh is still a single object. The normal way of do this kind of thing is to physically detach mesh sections so they become individual objects not attached in any way to the original mesh. You would then select each section and 'merge' or 'attach' them back together into one mesh object. This basically does the same thing as split mesh as it creates a single object made from a number of subobjects that have their own face vertices along any given 'shared' edge. Split mesh is slightly more convenient to work with. ![]() Selecting vertices and face to create a new smooth group Split mesh only works in editmode (keyboard 'Tab') so once there make sure all the vertices are deselected ('A') - if you happen to leave the odd rogue vertex in place it can cause problems later so double check this (the mesh will turn yellow if you had any vertices already selected, just hit 'A' again to deselect all). If you've turned on the draw edges & draw faces feature mentioned in the note above then as you select the vertices of each face that will form the basis of the sub-mesh it'll turn 'yellow', it's a good idea to have that tool turned on. Then all that needs doing now is to just hit 'Y'. A little popup will show which ask you to confirm the split, click 'split'.
Working with 'Split Mesh' smoothgroups ^If there are several areas on the mesh that need to be split like this it's a good idea to then do at least one of two things.
The reason behind this is that currently Blender won't allow you to select this sub-mesh 'as-is' so the only way to make the whole object easier to work with is to either hide the sections as you work on them or assign a different sub-material to them so at the press of a button they can be selected/deselected (from the 'Link & Materials' tool panel in the edit buttons window); trying to Shift+LMB click vertices when there are several of them in one location gets tricky and is time consuming on really complex splits. ![]() Distinct smooth grouped areas Once you've gone over the mesh and split it up the way you want the smooth groups to appear you'll end up with something similar to the shot above, you can see how the shadowing is distributed across the model to give clear and distinct regions, the top faces are no longer connected to the main body. The result of this is a nice clean line which allows each area to show up correctly lit ingame.
If you find using the 'spilt mesh' feature cumbersome to use then you can, as was mentioned above, still split the up mesh the old fashion way by using 'Separate Mesh'. Simply select the verts/polys to create a selection area and then hit keyboard 'P' to totally create a completely separate object from selected polygons/verts. Once you've done this to the mesh and get the sections you want joining them all back together again using Ctrl+J will create smoothgroups as described above. Multiple smoothgroups using the 'Split Mesh' function ^Obviously creating of each split will depend on what the model is, the red lines shown below indicate where a 'boarder' has been created so that along the line there are multiple sets of vertices, one for each region, each 'leg' is a separate region the bottom faces of which have also been split so ingame shadows don't try and wrap around that edge (the number of vertex sets will depend on the number of region splits in the local area). The boxout shows an important 'hidden' split that runs down the back of the model forcing an edge to be seen which in turn forces a slightly better distribution of the shadows on the trunk of the mesh ingame. Again the top and bottom faces of that section have been split from the main mesh. ![]() Red lines indicate the boarders of each split mesh region
Prepping models for export ^Depending on what the model is for and where it's going to go the final thing we need to do before export is position it in object space relative to the 0.0.0. grid centre of Blender and then 'freeze' it in place. ![]() Almost ready - the model is centred to allow burying into brushwork without errors. The reason re-centering like this needs to be done is to avoid errors where the origin point of the model gets buried in solid brushwork. The example model used in this tutorial for instance has been positioned over the grid in such a way as to allow the origin point to occupy approx. the centre of mass of the models mesh. This now means that in D3Ed the model can be buried a few units into brushwork without worry about 'Entity Leak' errors (and thus given the impression of a wall being built around the support rather than the support just sitting on the surface). Incidentally, if you're getting that error cropping up when you're doing something it's worth checking the origin point of the models you've used in a map as a first port of call to make sure none of them are buried or hiding inside brush work.
If you hold down Ctrl whilst moving the model it will move snapped to the grid. It's a good idea to try and do this especially if you've been accurate about a models size and position in relation to in game brush work. Objects can also be moved by smaller snapped increments by holding down Ctrl+Shift. Apply 'Size' and 'Rotation' ^Once the model is positioned where it should be on the Blender grid it needs to be 'frozen' into place, this is done with 'Apply Size/Rot'. It's important to do this step if using the USMExporter otherwise it basically re-centres the mesh back to the original position the model had when you first drew out the initial mesh object. This often means a model ends up facing the wrong way or lying flat on it's back. Simply select the model and hit Ctrl+A. A little popup will appear which you need to click to confirm the command. Once done the model is then ready for export. USM ASE Expoter setting ^![]() Switch to the 'text' viewport (Shift+F11) and then open up the USM exporter script, it'll appear as a text file because loaded scripts don't run by default (incidentally, make sure you have your python path correctly set up otherwise the script won't run or you'll get runtime errors) so with the mouse cursor over the text viewport press keyboard Alt+P to activate and run the script, you should see the GUI pictured opposite appear. GUI settings ^The example shown on the left lists details to do with the wooden support for this tutorial;
If the exporter doesn't show anything when you run the script simply select the object that needs to be exported and move the mouse back over to the exporter, the GUI will then change to list details relative to that selection. It's at this point that any 'errors' in the mesh will be reported by the exporter using red coloured text; polygons left as quads for example, would show as 'Quads : [value]' the [value] being the number of quads still remaining on the mesh. Any errors will need to be fixed before export. Once the mesh receives a clean bill of health (no red errors) the exporter will give the 'VALID' stamp of approval indicating the mesh can now be exported to the location shown in the 'Path' text field by pressing the 'Export to [name].ase' button (where [name] is the value assigned to the mesh object). Editing texture paths in the exported ASE model ^The final part of all this is getting the model into Doom 3. Because Blender currently (at time of writing) has a hard coded limit on the number of characters you can use for an object or material name it means the ASE file has to go through another stage before it can be used correctly ingame. All this means doing is opening the file into NotePad (or a similar text editor - make sure it saves 'pure text' because some editors, like WordPad, tend to save hidden characters used for internal formatting into the file which can cause corruption in other applications to the extent that the file can't be read, opened or edited) and looking for a line of text that says *BITMAP.
This needs changing to reflect the file path to where the texture (or material file) is so Doom 3 can find it. Now this next bit is going to cause a bit of a ruckus because there are currently 3 different working methods to reference the file path for the models to work; I've only successfully got one of them to work so I tend to stick to that, they are (in no particular order);
A corrected section of an ASE would then look similar to the following after the amends have taken place;
Note also that you don't need to put the *.tga file extension on the end of the path because Doom 3 is actually referencing material files (shaders) so the actual image assets (textures) are indirectly referenced from the material (even when you don't use a material file the game still creates a material for these 'orphaned' textures in the background). Once you've changed the *BITMAP path to reflect where you've got the model and it's assets, save it and place it in a folder within the 'base' folder of Doom 3, making sure to follow a similar filepath indicated in the ASE file.
All you then need to do is open up Doom 3 Radiant, right click on the grid viewport and select 'New Model...' from the popup menu. This will then open the internal model viewer from where you can browse to the new model. Once selected it'll preview and if everything looks ok click the 'OK' button and it'll be placed in Radiant. Compile the map and run in Doom 3 or just hit F3 with Radiant open and the camera viewport will go into 'render mode' which shows you exactly what you'd see ingame. It's a good quick way to check model lighting as any shadow problems you see here will show up exactly the same ingame. Depending on what happens here the model will be ok and shadows falling correctly or it won't. If it's still not lit correctly then the split mesh regions will need adjusting until you have something that looks correct relative to the model. ![]() The model correctly lit in Doom 3. Also shown is a 'corner' support that's buried in brushwork without errors due to origin point placement as outlined above. |