Blender 2.76 to edit a navmesh from BF2Editor.exe v1.3
This tutorial covers Using Blender 2.76 to edit a navmesh.
These instructions are intended for use with Blender 2.76b for Windows. It is the last version available that has a kit able to run on Windows XP, but should be similar to more current versions of Blender
>> NOTE: Blender 2.76b Requires Windows XP to be at Service Pack 3 (SP3)
GETTING STARTED == You must have created a navmesh set with BF2Editor v1.3 Save a copy of the "Output" folder to somewhere it won't get damaged (just in case), as a backup.
default location: C:\Program Files\EA GAMES\Battlefield 2\NavMesh\work\<map folder name>\GTSData\Output
The navmeshes are .obj files: Infantry.obj and Vehicle.obj. These .obj files are a list of text entries. You can open and view them with Windows Notepad. It can be helpful to understand the format of the Navmesh obj file, which is explained in detail here:
Understanding the Obj format of a Navmesh
PREPARE the .obj and .mtl files
Place a copy of the Infantry.obj (Vehicle.obj) and the materials.mtl files into the same folder. The materials.mtl file defines the "materials" the navmesh is made up of. ("ground", "ladder', "water", and "deepwater") The different materials are shown as different colors: Green for ground, Yellow for water, Blue for deepwater and Red for Ladder
For a more in-depth explanation of the importance of the material file for the Navmesh, take a look at this tutorial:
Start Blender (When you start Blender a command window will open for a few seconds then Blender will run.)
>> With the default configuration (Factory Settings)
Blender will open with an information "Splash" pop-up Left click on the top part of the pop-up next to the "2.76" (or press ESC) to get rid of the splash pop-up
- There is a menu list in the right-side panel called "Scene". - In it are selections for "Camera", "Cube", and "Lamp". - To prepare Blender to edit a navmesh we have to make changes and these menu options will disappear. - This is not a problem.
In the working window (the middle of the screen) You see a cube, a dotted circle on a stick and a pyramid on it's side (with a black triangle). The cube is a default model which will mess up any editing done on a navmesh so we have to delete it. The cube is already selected so press DELETE and Enter to get rid of it. (or Left-Click the "Delete" in the pop-up) Since Blender is used for 3D animation there is a default light source. The dotted circle on a stick. Right Click on the circle then press DELETE and Enter to get rid of it. Finally there is a "Camera View" icon. The pyramid on its side. Right Click in the black triangle to select it then press DELETE and Enter.
- In the Scene menu: Cube, Lamp, and Camera are now gone.
Blender is now ready for a navmesh file.
Blender doesn't work natively with .obj files but using the "Import" function it can convert them into something it can work on. (After the editing is done you have to use the "Export" function to change the Blender file into ".obj" format.). The following link has the settings and examples for importing a navmesh:
-- SPECIAL WARNING --
The navmesh in Blender is a MIRROR IMAGE of how it appears in BF2Editor. Left and Right are reversed
- Blender uses the Engineering co-ordinate system where Z is UP, Y is RIGHT and X is FORWARD.
(looking at a house, Forward comes from the house to you.) But, in BF2Editor the Y is used as UP, X is RIGHT and -Z (negative Z) is FORWARD.
To Blender, all three axes are in the wrong place and one of the directions is going the wrong way. Using the import options Blender can "rotate" where it points two of its axes. And even change the direction they go toward when configuring "UP" and "FORWARD". But, because all 3 of them are in the wrong place to start with, "fixing" two of the axis causes the last one to point in the wrong direction.
Using the default Import .obj settings in Blender ("Forward: -Z Forward" and "Up: Y Up") will make the forward-back and up-down the same as BF2Editor. But, the left-right becomes backwards. This is why the navmesh is a Mirror Image of how it appears in BF2Editor.
When you first import your navmesh you might not see it. Run the scroll wheel back to see the mesh.
= = >>>> EDIT NAVMESHES <<<< = = = To do this you have to learn to use Blender = = You will have to edit both the Infantry.obj and the Vehicle.obj = (One at a time.) to get a finished navmesh "set". = = There are a few hints about controls later =
--> HINTS on using Blender 2.76b
When you Import a file Blender will start in "Object Mode."
Most likely you will not see your navmesh. You will, probably, only see the "Base Grid" for Blender. Scroll wheel back until you see part of the mesh. If you press and hold the scroll wheel button you can tilt and shift the view. But, this is really not that useful.
Click it to get a new set of options. Click "Edit Mode". (The mesh has to be selected before the Edit Mode option will appear.) The mesh will now get a yellow dot at every vertex and a yellow line for every edge. [6_Edit_Mode.jpg]
Each triangle has an "up" side and a "down" side. To see which side is up we add the "Normals" to the triangles.
Move the mouse pointer into the work window. Press: N. A new panel will pop out on the right side of the work window. (The panel will NOT appear unless the pointer is inside the work window when you press N.) The option we need is not visible so grab the slider bar on the right side of the panel and pull it down to see the box labled "Mesh Display". In the mddle of the box is the option "Normals:" with three buttons under it. They are: a cube with a dot on a corner (Vertex selection), a cube with a hilight on an edge (Edge selection), and a cube with a hilight on one side (Face Selection).
Click on the "Face Selection" button to turn on the Normals for every face. Each triagle will get a "post" in the middle showing which side is up. When you look at the bottom of a triangle there is no post (but there is a dot). If you want you can make the post taller. Next to the "Normals" buttons is "Siz0.10" with arrows to the right and left. Click an arrow several times to change the size of the normal. Press N to close the panel.
It's a good Idea to have the Normals turned on all the time. The reason why we need to see the normals is to ensure we don't add a triangle that's upside down to the navmesh. In a finalized map, if a bot moves on to a Quadtree made from a triangle that's upside down the game will crash.
Using Shift F and the W, S, A, D keys move around the mesh looking for problems.
When you find a place that needs fixing move your view close to the place you want to edit then Left Click to freeze the view.
Before you add new mesh you must pick the material you want to add to the mesh. On the right of the display is a panel with a series of option boxes. The top one will say "View" and "Search". The box below that has a row of icons starting with a Camera. We need the ninth icon in that row. It's a ball located between a funny triangle and a checkerboard. Left Click the ball.
The option box will expand and you will see the list of materials for the navmesh. They are: ground, water, deep water, and ladder. There is a ball next to each material to show it's colour on the mesh. Usually if a material isn't used in the mesh the ball will be grey. Left Click on the material you want to add to the mesh.
[16_Material_List.jpg]16 Material List
To create a triangle you need to mark 3 vertices. To do that, RIGHT Click on the first vertex. It will get a circle with 3 arrows coming out of it. The vertex and all of the edges attached to it will get a yellow highlight. Then press and hold SHIFT. Keeping Shift down Right Click a second vertex. The second vertex and all its edges will turn yellow. The circle with the 3 arrows will move to the middle of the edge between the first and second vertices. Then, still keeping Shift down, Right Click a third vertex. The third vertex and its edges will go yellow. The circle with the arrows will move to a spot that is in the open area between the three vertices. Release Shift and press F. You will get a new triangle, made of the material you picked, between the three vertices. The circle with the three arrows will now be in the middle of the new triangle. If you have a vertex with two edges open to an "unused" area there is a quick way to create a triangle. First pick the material you want the triangle to be made from. RIGHT Click on a vertex that has two open edges. The vertex and all of the edges connected to it will light up. Press: F. You will get a new triangle made of the material you selected added into the previously open area.
UNDO If you made a mistake (like picking the wrong material) you can use the UnDo function. Press Ctrl Z to "undo" the last action you did. You can "undo" about 10 of the last things you did. But, they all have to be in order.
DELETE TRIANGLE If you need to delete a triangle you must change from Vertex Select to Face Select (Blender starts in Vertex Selection by default). On the menu bar below the work window are 3 buttons. They are: a cube with a dot on a corner (Vertex selection), a cube with a hilight on an edge (Edge selection), and a cube with a hilight on one side (Face Selection). LEFT Click Face Select. The button will turn dark grey to show it's active. (And the vertex select button will change to light grey to show it's off.) Right Click on the "bad" triangle. Every part of the mesh except the triangle will have the hilight turned off. Press Delete on the keyboard. A pop-up menu will appear. Move the mouse pointer to "Faces" and Left Click. The triangle will disappear. To delete several triangles you can mark them with the "Lasso." In face select press Ctrl and hold it down, hold down the left mouse button, move the mouse pointer. A white line will appear where the mouse moves. A white "hilight zone" will appear from where the mouse is back to the point where the mouse started. Release Ctrl and the mouse button. Everything that was inside the "hilight zone" will be hilighted to show it's selected. Press Delete on the keyboard. In the pop-up menu click Faces and all of the faces will disappear.
SELECTION Mode You can select a vertex, an edge or a triangle by changing the Selection Mode. On the bottom menu bar is a group of three buttons: a cube with a dot on a corner (Vertex selection), a cube with a hilight on an edge (Edge selection), and a cube with a hilight on one side (Face Selection). By default Blender starts in Vertex Selection. Left click the button to get the Selection Mode you want.
MOVING things You can move a vertex, edge or triangle after you select it. When you select a vertex, edge or triangle it will get a circle with 3 arrows coming out of it. To move something put the mouse pointer on the "head" of one of the 3 arrows press and hold the Left Mouse Button. A red Line will appear showing the axis the movement can occur on. Keeping the mouse button down move the mouse to move your selection. Release the mouse button to "lock" the selection to the new position.
NON-MANIFOLD To BLENDER "Non-Manifold" is used to describe any Vertex, Edge, or Face that is not correctly attached to a mesh. Since Blender is designed for 3D objects, with its default settings, most of a navmesh is Non-Manifold. BUT, with one option change, Blender's Non-Manifold function can be useful on a navmesh.
The Non-Manifold function only works in Vertex Selection or Edge Selection. When starting EDIT MODE all of the vertices and edges are highlighted. But to find Non-Manifold problems we only need non-manifold areas to be highlighted. So, first, turn off all the highlights. On the keyboard Press: A (Pressing "A" toggles "Select All" On and Off.) With the Highlight off Press: Ctrl Alt Shift M Or if you prefer to use the mouse go to the menu bar below the work window and Click: Select -> Non-Manifold The options for Non-Manifold will appear in the bottom of the left-side panel under the title "select Non Manifold".
UNcheck the Boundaries option.
Now Blender will ignore everything that is on a "Boundary". It will only select areas that have Non-Manifold vertices or edges "inside" a navmesh. You will have to move around the navmesh to find the hilighted places. Blender has a set of counters above the work window showing the number of selected vertices, edges, and faces. It's located to the right of the Blender Icon in the top menu. (The icon looks like an orange circle around a blue dot.) The counters will read something like | Verts:7/6,453 | Edges:4/12,872 | Faces:1/8,393 |. When the Non-Manifold function is used only the Non-Manifold elements are counted. So, you can use this to keep track of how many things still needs to be fixed. [27_Non_Manifold_counter.jpg]
To fix a problem the Non-Manifold function will have to be turned off. So, after you have fixed one problem, to find the next problem area you will have to start over with the turning off all the highlights (Press: A) and redo the Non-Manifold function. You can fix an area and still have show up as Non-Manifold. This happens when there are several Non-Manifold things "stacked" on top of each other. These are examples of "multiple" Non-Manifolds I found:
Example 1: When "Vertex Select" was active a vertex and all ten of it's edges were Hilighted. When the "Edge Select" option was activated only an edge of the zone was hilighted. Close examination of that edge showed, at one end, it was actually two edges close together. Where the edges were far enough apart to see there were two of them there was a short black line between the ends of the edges. This Black line was a third edge. The two edges and the Black line made a triangle but for some reason there was no material in it. Changing to Vertex Select all three of the vertices making this "empty" triangle were selected. "F" was pressed to add a face. The non-manifold was repaired.
Example 2: When "Vertex Select" was active a vertex and all five of it's edges were Hilighted. One of the Hilighted edges had no face attached. When a face was inserted the Non-Manifold problem was still present. The new face was deleted and the edge without a face was examined. As a test the edge was selected and deleted. A second edge appeared in the same place as the first. The second edge was also selected and deleted. Finally no edges remained. In Vertex select the Vertices at the ends of the gap, where the edges had been, were selected and the third vertex was added. A face was created and the non-manifold problem was repaired.
Example 3: Several edges at an area where water ended were hilighted. The water was connected to deepwater but not ground. This meant there was no need for a path in this area. So, Faces were selected and deleted until the non-manifold problem was fixed.
FLIP NORMALS If you have face that is upside down. Change to Face Selection. Select a face. From the lower menu: Mesh -> Normals -> Flip Normals OR Mesh -> Faces -> Flip Normals
SUBDIVIDE You can split a triangle into smaller triangles with Subdivide. Change to Edge Selection Mode (on the lower menu bar). Select an edge. On the left side panel (it should be on the "Tools" tab) in the Mesh Tools area find the "Add:" section. The sixth button down is "Subdivide". Click the button. At the bottom left on the panel the options for Subdidvide will appear. Click the box next to "Quad/Tri Mode" to get a check mark in the box. By default Subdivide will cut the edge in half so that every triangle on that edge will be split in two. You can increase the number of parts to as many as you need by changing the "Number of Cuts" to any value more than 1. You can also get the Subdivide function from the lower menu. Click Mesh (get a pop-up menu) - Select Edges (get a extended menu) - Click Subdivide. The edge will be cut by the options in the Subdivide Panel (lower left).
Edit with Terain present The navmesh is supposed to follow the "terrain" like a blanket. But when BF2Editor creates the navmeshes there might be areas where the mesh is above or below the terrain. If the navmesh is too high or too low the bots can't "see" it. The bots treat these places like there is no navmesh there at all and avoid them. If this happens, to get the bots to move properly, the "height" of the navmesh has to be adjusted to better follow the terrain. To have the terrain present while the navmesh is being edited make a copy of the "preop.obj" file. Open the file with Windows Notepad and delete the "mtllib materials.mtl" line at the top of the text list. With the "mtllib materials.mtl" definition missing this copy of preop.obj will always be a grey colour in Blender. Import this copy of preop.obj as a second object into Blender. The last object Imported will be the "Current" object and to edit the navmesh you will have to "Select" it by clicking anywhere on the navmesh before you do any editing. The name of the object you are editing is shown in the lower left of the work window. (Just above the Object Mode/Edit Mode menu pop-up)
EXTRUDE If there are no vertices in an area you want to add a face to you can add a face into an "empty" area with Extrude. Change to "Edge Selection Mode". Select an edge, then press: Alt E. When you move the mouse a new face will extend from the selected edge. Always extrude into an empty area. Left click to stop the process. Until you get used to creating faces with Extrude it can place the face at an angle that is up or down from the direction you thought it went. Move your viewpoint around to confirm the extruded face is where you want it to be. Usually you have to select the edge of the new face and move this edge up or down to get the face to be where you want it. Extrude will only create a 4-sided face. To make this into triangles change to "Face Selection Mode" and select the new 4-sided face. Press: Ctrl T. The face will be split into two triangles.
That is it for Navmesh editing tips.
When you have patched all the problems in the navmesh you don't Save the result, because that gives the wrong file format, you "Export" it.
There is extra processing needed to get the syntax changed so that the .obj files will work properly with "Fixnavmesh.bat". That is explained in detailed in the following tutorial:
Copy the edited navmeshes into the "<map folder name>\GTSData\Output" folder. (You did make copies of the original Infantry.obj and Vehicle.obj files? Right?) Rename the exsisting Infantry.obj and Vehicle.obj to something without the .obj extension. Then rename the edited navmeshes to Infantry.obj and Vehicle.obj so that they replace the previous files.
This will create the Quadtree files in the "Map Name" and "mod" you gave to Fixnavmesh.bat
Start Battlefield 2 and test out your newly navmeshed map.
If you're like me the bot activity during testing will point out problems you didn't know were there. So, don't be surprised if you have to re-edit the navmeshes to touch-up these previously unknown problems.
(These notes don't describe how to create the client.zip, server.zip, or Info folder for a fully finalized map.)