RequirementsThis document assumes that you already know the basics of modelling, texturing, and UV-Mapping objects in blender3d. There are a large number of tutorials, including video tutorials, out on the internet on how to create objects in blender, then texture them. Before an object can be made into a prefab the following needs to be there:
Steps (each covered in more detail below)
Naming your objects appropriatelyGenerally, when prefabs are made, they are made in sets. The entire set is in the same .BLEND blender3d file at once, so that textures can be shared easily. For the Magic Button export to work (which exports all objects in the entire blend file), your objects should be named appropriately. Appropriate names are suggested to be a set name, underscore, then a hint name. Keep it short. For example, if you're making things which look like scaffolding, and they plug into each other, and you have a middle piece, a corner, and a terminator piece, then perhaps name them scaf_mid scaf_corner and scaf_term. To name an object, you may as well name both its object and its mesh the same thing. See the screenshot below: In this screenshot, we have three prefabs. The middle one, the straight piece, is selected. In the bottom area (links and materials) in the edit subtype, I have named it r1_straight1 Notice both mesh and object (ME and OB) are named the same thing. This is useful. I've also turned on show names (F7, its under the DRAW box, 'draw extra' 'name') Z for wireframe mode. As long as all of your objects are appropriately named, it can automagically export. Ensuring textures are correctFor it to properly export, each mesh object you intend to export must have a texture bound to the first slot of its material. Objects can share materials, and have multiple materials (its the only way to use multiple textures on a single object). In the shading panel (F5) if you repeatedly hit F5 you will cycle through the options. With your object selected, make sure the material buttons are selected (red ball). See the attached screenshot: Note that in the screenshot, it shows:
If you go into the textures subpanel you see this: In this screen shot note that
Ensuring object centers are appropriately placedWhen you put prefabs down in the map editor, their centerpoint will be placed on the floor, and they will rotate around that center point. You should use this to make it as easy as possible for yourself when it comes time to actually place them. This means that the centerpoint (pink dot in blender3d) should be at z=0 in blender, and in a good place for rotating the object around.
Using Hyperbol Material ToolkitITS INCREDIBLY IMPORTANT THAT YOU HAVE ALREADY ASSIGNED A REAL DIFFUSE MATERIAL WITH TEXTURE TO ALL YOUR OBJECTS BEFORE YOU DO THIS ITS ALSO HIGHLY RECOMMENDED THAT YOU SAVE A BACKUP BEFORE YOU DO THIS AS IT ALTERS THE MESH. If installed correctly (to your python scripts folder) materializer should appear automatically in edit mode (TAB) under python The Material Toolkit window appears In edit mode, simply select faces that you'd like to use a particular shader, and then click the shader name. Most shaders work fine but your workhorse shaders are going to be CHROME, FULLBRIGHT, SPECULAR, CHROME - OVERLAY PULSING, etc. Glass and stuff is tricky Note that overlay type textures will require two textures in the end - one named (texturename).dds and another named (texturename)_over.dds for the glowing overlay on top. Here in the screenshot, I select a bunch of faces (face mode must be used) and then click SPECULAR to give them that 'shiny when they glint in the light' look. They turn yellow in edit mode to indicate what type of shader they use. They will not look yellow in game. ITs just an edit mode indication. Its highly recommended that you start by selecting all objects and all faces and clicking 'Diffuse' to create a good baseline, uniformly, then selecting just the specially shaded faces
Create Collision Curves for the objects.For an object to be collidable, it needs collision curves. These are blender Curves set to vector mode, on the 2d plane, named the same as the object but ending with '_coll'. Here we have our object, again. I'm going to top view, wireframe mode, object mode (not edit mode, tab). I'm going to center the cursor on the object (SHIFT+S) cursor to selection. Then I'm going to move it a little out of the way and SHIFT+S Cursor to grid so that its not quite on the same center as the object. Then I'm going to press SPACE, and choose "add -> curve -> bezier curve" It creates a bezier curve for me at the cursor. It automatically selects it and enters 'edit mode' (tab). I'm going to change it into a polygonal curve by clicking the POLY button at the bottom. Now I rename the object to the same name as the object, but with _coll at the end.This is very important as it is the signal to the magic button that these objects are related. Now, back to the actual curve. Just like always in blender, adding vertices is easy. Shift click (might take a middle or right click depending on your settings) with an endpoint selected and vertices are added. Click to select and delete button to delete. A nice trick, if you have grid, is to select as many verts as you want and press (SHIFT+S) Selected To grid to auto align all selected objects with the grid! The idea here is to keep the vertices at Z=0 but to use this 2d line to represent the edge of the object, where it will be collidable. For example, this prefab Has the following collision line Notice that only the edges with polygons are important. Do not use the 'close tool'(c button in edit mode) to close an edge - those are ignored. For closed shapes, simply close the shape by putting a last vert on the first vert. Ships and other projectiles will only collide with these lines, so its a good idea to ensure that they are closed when the object they represent is. Objects (or pieces) that ships will never reach need not have collision lines at all. Its also good for performance to keep the number of collision lines low, so feel free to approximate curves with much fewer lines. Each collision line set can contain any number of blender3d curves. So an object can have several unconnected curves forming its collision line. simply make a bunch of curve objects, then select them all and choose join (CTRL+J). Remember to rename the resulting object to the same name as the object it represents, but with _coll Run the exporterEach of your objects now has a texture, has a name, and has a collision line set with the correct name. Time to automatically export using the Magic Button! In OBJECT MODE, select the python script "Hyperbol Prefab Tool" from the scripts menu. The prefab tool will appear. The prefab tool lets you specify the parts you want to export. There should only be three settings you're interested in here... the MAGIC BUTTON, the scale, and the export path First things first - choose an export path. Click on the Export to button and choose a destination .PFB file (type one in if necessary) Note that when using the Magic Button to export, all meshes that have no period (.) in their name are automatically exported whether selected as geometry or not. Selection is ignored - in fact, it will auto select everything as it seems fit. So make sure that your meshes are named, and that stuff you dont want exported has a dot in its name! (both mesh and object name). Once the export path is selected, all you need to do is click "Magic Button" and it will do everything for you. It might take some time. It will highlight each one as it does it, so zoom out and look from the top before you start. You will end up with PFB files in the folder you specified (the filename in the box is ignored - the files will be named based on the name of the object). Those PFBs can be fed to the prefab compiler. Run the prefab compiler on your objectHard way:
Easy (?) way
Now whenever you double click on any PFB file it will automatically compile it. You can select entire groups of pfbs and it will automatically compile for you This will output a PF2 and a MEX file. At this point you can already take the PF2 and MEX files, and place them in your maps folder (or elsewhere). If you refer to them in the map editor, they will load. (But will probably be missing textures!) Making the textures right (and editing the mex file)Open up the MEX file in notepad or whatever. The MEX (Model EXtra) file tells the game what shader to use, and what textures to feed that shader.
In the picture above, notice that the "Stretch stand" takes two textures for one of its different shaders. It has 3 shaders. Chrome and Specular does not need a second texture. But OVERLAYPULSE needs another overlaid texture (with alpha) that it renders on top of the underlying texture, glowing and pulsing. So for that texture, its specifying that it should use (imagename)_OVER.dds as the overlay. Note that the _OVER.dds is automatically created for you, as is the DDS extension. it is assumed that your exports will be DDS - but you can manually edit the file to be tga. For example, if you intend to include your PF2 and MEX's and textures inside your map folder, you should probably change the relative path of your textures in the MEX file from data/textures/prefabs to data/maps/mapname_v1/texture.dds (or tga). Textures should be in TGA format or DDS format. If using DDS, please use DXT5 (for alpha) or DXT1 (for nonalpha) orR8G8B8A8 or R8G8B8 only. DDS is probably the best, but TGA if you can't find a DDS tool. DDS tools are available for photoshop and the Gimp, you can get them straight from nVidia for the former. All done.Just make sure that your pf2 and mex files are in the right place, then in the map editor, put a prefab down (any prefab). Change its MEX and PF2 paths to the relative path to your prefab, and you're done! Remember, the path to your map folder is probably data/maps/(your-map-name) - so your prefabs could be in data/maps/(your-map-name)/myprefab.pf2 If your pf2 and mex files are correct, and the textures inside them are correctly pointed at it should all Just Work. As an added bonus, if you're using the auto-packaging feature of the map editor, and you keep your resources inside your map folder, they will automatically be included in the packaging. (This is highly recommended). In other words, the result HBC file from autopack will include the necessary prefabs and textures as long as you keep them all in the map folder. (WAV and OGG are also autopacked) |
Editing/Modding >