MAYA object tutorial

LEVEL: Advanced – Experience with Maya

TOOLS:  Maya 6 (last version with BF2 plugin support), BF2 plugins

This tutorial will cover all of the steps to getting your object into the editor, whether it's a staticMesh or a BundledMesh (no skinnedMesh, but it's not all that different), using Maya 6.

So first make sure you have Maya 6.0 installed along with the BF2 Maya plugins.

You will need a folder for your project somewhere in Battlefield 2\bf2editor\RawData\Objects. My folder will be C:\Program Files (x86)\EA GAMES\Battlefield 2\bf2editor\RawData\Objects\staticObjects\woodCrate. Inside that folder you should create another folder named textures.

Now start up Maya.

Let’s keep it simple for this tutorial -- so let's just make a cube. You can do this by selecting Create -> Polygon Primitives -> Cube[] (click the little square). A menu will pop up asking you for the dimensions of the cube. I'm going to just set them all to 1m.

You will probably want to know how to move the camera around, so let me show you some ways to do that:

Fly Tool: From a viewport menu (the one at the top of each view) select Veiw -> Camera Tools -> Fly Tool. This tool lets you move the camera around in the perspective view only. Hold the left mouse button down and drag the mouse to look around and use the mouse wheel to move the camera forwards and backwards

Track Tool: From the same Camera Tools menu you can also select the Track Tool, which works just like the Fly Tool, except instead of rotating the camera when you left click drag, it simply moves the camera along whatever plane you are viewing. This camera works in all views

You can also use the Move tool (third from the top in the Toolbox menu) to move the camera just as you would move a mesh or vertex.

Okay, so we have a cube and we can move the camera around to inspect it. Now it's time to texture it. First we need to open the UV Editor:

At the bottom of the program on the left side, there is a box that you can type commands into. Click on it and then type "dnyUVPanel" (no quotes, case sensitive) and press enter. If your plugins are installed correctly a window will pop up labeled "DiceNY UV Editor".

Now select the cube: Move the UV window aside and select your cube. You can do that by selecting the first tool in the toolbox (the select tool) and then clicking on your cube.

Now grab that UV Editor window and you'll see your UVs laid out over a grid. The top right quadrant of that grid is the texture; Putting UVs outside the grid will cause the texture to tile, which may or may not be desirable.

Anyway, we want all the UVs on our cube to be in the texture quadrant for now, so go back to the main Maya window, make sure your cube is still selected, and hit Edit Polygons -> Texture -> Unitize UVs. Now if you look at the UV Editor, all the UVs are in the top right quadrant.

*If there is no Edit Polygons menu make sure the drop down box at the top left is set to Modeling

Static meshes have layered textures, which means they can have two textures for each face with their own UVs. To set up the second texture layer you will need to create a new UV set. To do this, select your cube and go to Edit Polygons -> Texture -> Copy UVs to UV Set -> Copy into New UV Set[] (click the little box). a new window will pop up asking for a name for the new UV set. Name it "detail". You wont have to do this for bundled meshes as they have only one texture layer.

You can switch between UV sets to modify them by going to Edit Polygons -> Texture -> Set Current UV Set... and entering the name of the UV set you want to switch to (not sure why there isn't a drop down box instead). To see which UV set is currently selected, go to Edit Polygons -> Texutre -> Copy UVs to UV Set and just see which one is grayed with a check mark next to it (don't click anything on that menu though).

Okay, now we need a texture. A square .DDS will work nicely. Got one? Good. Put that texture in your project's textures folder. If you're making a static mesh with two texture layers you will obviously need two textures, but we'll get into that later.

Next open the Hypershade by selecting Window -> Rendering Editors -> Hypershade... You should see three default shader objects, but just forget about those. From the menu on the left click on File (under 2D Textures); a box will appear in the "Work Area" labeled "file1". Select file1 by clicking on it then go back to the main window. On the right, the attribute editor should be open; if not hit ctrl+a. With file1 selected, you should see a box that says "Image Name" next to it. Click the little folder icon and select a .DDS texture (don't worry about the second texture layer for now).

Now select your cube and go back to the Hypershade. Without deselecting your cube, hold down right click over your "file1" box and hit Assign Texture's Material To Selection. Now you can check out the texture on your cube.

Now we have the materials set up for Maya, but they're no good for BF2, so let's fix that. Open up the DiceNY UV Editor again and look for a button on the bottom labeled "Assign". Click it.

If you get a pop up box that says "Please Load the Dice modified "cgfxShader.mll" Operation Cancelled" you'll need to load the plugin. Go to Window -> Settings/Preferences -> Plug-In Manager... In the window that pops up, check the two boxes next to cgfxShader.mll (loaded and auto load). Now try hitting Assign in the UV Editor again.

When you press Assign, a new cgfxShader material will be created for you. You can see it in the Hypershade (you may have to close and re-open the Hypershade). If you had an object selected when you clicked Assign, the cgfxShader material will be assigned to the selected object. I prefer to create the material with nothing selected.

So now we need to set up the cgfxShader material, just like the file1 material. Select the cgfxShader in the Hypershade, then go back to the main window and look at the attribute editor on the right. At the top is a box labeled CgFX File; this is where you select the shader to use. Click the little folder next to it and navigate to Battlefield 2\maya\CGFX6.0. You should see three shader (.fx) files.

If you're making a static object, you'll want to use the StaticMesh shader, so select that one. There should now be a section under the CgFX Shader section labeled StaticMesh Parameters that should contain boxes with various texture names in them. I like to set up the colorLUT texture first because it will always be the same texture. So click the little folder next to colorLUT and navigate to Battlefield 2\maya\CGFX6.0\cgfx_textures, then select I'm sure you could use other textures for this, but I've never cared too much about that. Now set the diffuseTexture to a texture in your project's texure folder (the color texture), and make sure it's name ends in "_c" (if you don't use the texture suffixes strange things can happen). Next you can set a detail texture if you want (this is the second texture layer), which should end in "_de", and a detail normal texture, which should end in "_deb" (this is the normal/bump texture for the detail layer). Okay, now just clear any other fields you're not using and that should do it for a basic staticMesh shader.

If you're making a bundled mesh, like a vehicle or dynamic object select the bundledMesh shader. Set up the colorLUT, diffuseTexture, and normalTexture just like you would with the staticMesh shader.

Now we'll want to assign that cgfxShader material to our cube. We can do that just like we did before by selecting the cube, opening the Hypershade, holding right click over the cgfxShader, and selecting Assign Material To Selection (it works on objects in the Work Area and the Materials section above it). Don't worry if your cube turns black, it will still show up fine in-game.

It would be a good idea to triangulate the mesh now. Some people may tell you that it's better for performance to leave the visible mesh as quads (squares), but that simply is not true. When you import the mesh into the BFEditor, it will auto-triangulate the mesh anyway, but it's much better to just do this in maya to avoid potential problems. So triangulate the mesh by selecting it and going to Polygons -> Triangulate.

Now it's time to set up the hierarchy and collision meshes:

First open the Outliner by selecting Window -> Outliner. In the Outliner window you should see four cameras, a mesh object named something like "pCube1", a cgFxLight (which you can ignore) and some other crap (defaultLightSet, defaultObjectSet) which you can also ignore.

Now let's name our object by double clicking it in the Outliner and typing a name. I'm naming mine "woodCrate".

Next we need to create collision meshes for our object. Since our object is so simple, we can just duplicate the original object for each col mesh. To do this, select your cube and hit ctrl+d (or go to Edit -> duplicate). Name this new cube "col0". Select col0, then duplicate it twice to make col1 and col2.

  • col0 is the projectile mesh; this is what bullets will hit and what bullet

holes will appear on.

  • col1 is the vehicle mesh which is what vehicles, dynamic objects, and the

ground will hit.

  • col2 is the soldier mesh which is what soldiers will run into.
  • col3 is the AImesh. This is not required and only used during the Navmesh process to support singleplayer.

You will probably want to create materials to assign to the collision meshes so you can assign BF2 materials to them later (like sand, metal, etc.). Open up the Hypershade and click Lambert on the left; a new lambert shader will appear. Name it whatever you want (wood, sand, etc.) and then assign it to your col meshes.

Now we need to group these col objects together. First select them in the Outliner by holding left click down on one and draging over the other two, or by holding ctrl and clicking each one. When they're all selected hit ctrl+g to group them. A group is kinda like a file folder; you can click the little '+' sign to expand the group and view it's objects. Name this group "nonvis_" (no quotes, one underscore on the end).

Next we need to parent this group under the original cube (the one I named "woodCrate"). First select the nonvis_ group, then hold ctrl and click the original cube to select it as well. Now hit p to parent nonvis_ under the cube.

Now select the cube and hit ctrl+g to put it in a new group. Name the new group "lod0". Do this again with the lod0 group and name the new group "geom0".

The last thing we need to create is a locator, which is basically just a point. Go to Create -> Locator. Find the locator in the Outliner and name it "root_staticMesh" if you're making a static mesh or "root_bundledMesh" if you're making a bundled mesh. Now just parent geom0 under the locator by selecting geom0 and the locator (in that order) and hitting p.

Expand all of the objects in the tree. Your hierarchy should now look like this:


For more complex objects, like vehicles, you will want to have more geom groups parented under the locator. For vehicles, geom0 is the interior, geom1 is the exterior, and geom2 is the wreck mesh.

You can also add LOD groups with less-detailed versions of your model to ease rendering when your object is far away. I'm not sure how many LODs you can use, but I doubt you will run out. lod0 should be the most detailed version.

Okay, now select everything and hit Edit -> Delete All By Type -> History, then hit Modify -> Freeze Transformations. This is just to prevent potential problems. You may not need to do it every time, but I think it's good practice.

Okay, save the project to your project's folder and give it the same name as your main cube (so mine is woodCrate.mb). And now you're ready to import the model into the editor.

So open up the editor, and select bf2 as the startup mod. When the editor is done loading make sure ObjectEditor is selected in the drop down box at the top left. Now go to File -> Import and select the .mb file you saved in Maya. Let the importer do it's job, then double click on your object in the resources menu on the left. The object should show up in the main window.

If your object looks wrong or the import fails, you'll have to go back into Maya and find the problem. Usually it's something simple, like the collision meshes aren't triangulated or the shader is set up wrong. Check your hierarchy too.

Once you have your object looking right in the editor, go find the files generated by the editor. They should be in Battlefield 2\mods\bf2\Objects\YOUR_OBJECT_PATH, so mine is C:\Program Files (x86)\EA GAMES\Battlefield 2\mods\bf2\Objects\staticobjects\woodcrate. Now you can modify your .con/.tweak files to suit your purposes and copy all the files into your mod.

And that's it. If anything is unclear or just plain wrong be sure to mention it and I will fix it.

Community content is available under CC-BY-SA unless otherwise noted.