This is the start of a tutorial on using Gmax, the free 3d modeling tool, to create Aimeshes for custom static objects. Aimeshes are used by the game to allow bots to use static objects, like buildings or bridges. I have not quite figured it out myself, so I am hoping that by starting this tutorial, others can help fill in the gaps.

First of all, this tutorial will go through the process of installing GMAX for use with BF1942 & BFVietnam, importing Ai meshes, and then creating custom AI meshes.

What you need:

Gmax (1.2) - download here: http://www.turbosquid.com/gmax

MDT (2.75) - Download here: http://www.planetbattlefield.com/mdt/

Installing GMAX:

Download and install the free GMAX tool. You will have to go on the website and register for free and plug in the registration number when prompted.

If the latest MDT is not installed (2.75), download and install it. You will need the GMAX plugins to make GMAX work with BF.

If you have an old copy install the latest version. The uninstaller will automatically start after a warning message.

If you allready have the latest version installed, start the MDT and click on install GMAX tools.

Now go back to the MDT, and click run GMAX tools. This will start GMAX with the BF plugins. If you start GMAX straight from windows, it will not have the BF plugin tab, and you won't be able to work with BF objects.



If we extract the Aimesh rfa file with winrfa and then import them into GMAX we see that an AImesh consists of two parts, and LOD and a COL. The LOD is level of detail, and COL is short of the Collision mesh. Usually there are multiple versions for different level of details, but the AImesh seems to only have one.

To import an Aimesh, from GMAX select the import/export tab and then choose the import option in the pop up window, and then browse to the desired file and click on the larger import button.

Note: Gmax defaults to the perspective large view. To change to multiple views, right click on the word perspective in the model view window and select configure, then the layout window and you will see lots of options. Just select how you want the views layed out.

Creating Aimeshes
(This is from a post by INXS on the Legion of the Dragon site)

Creating AI meshes for single floor plans seems fairly easy, please excuse how arrogant that sounds.

I recreated the aimesh for the barrack that started this thread using 3ds 6 and the pluggin from the latest MDT. The aimesh consists of 2 objects, COL01, LOD01, and there material is Battlefield-RS supplied by the pluggin.

First import the structure for which you wish to create and aimesh, in this case Barack_m1.sm. Then select Plane on the right and reduce the segments to 1 on both dimensions. Now using the top view drag/create a plane that just follows the outside of the structure, now slide the plane up to just above floor level using the move gizmo. From the side view draw a verticle plane arround the stairs, ensuring that a portion of it penetrates the floor plane, then right click the new plane and select clone. Repeat for the other steps. From the top view, using the move gizmo, slide each verticle plane till they align with the rails.

We are done with the Standardmesh object now so press 'H' and select the objects with m1 attached, leaving the objects with 'plane' in there name unselected. From the Edit menu select delete.

Now select all the planes you created by using the select gizmo or by using the'H' key, then right click and select Convert -> Edit Mesh. Next select Plane01 then click Attach List on the right, select all planes in the list and click Attach, you should have only one object now, Plane01.

----------------------
(This is as far as I got. Where is the convert option?)
----------

Now press 'M', select the second material (default 02) then click the button with "standard" on it, then from the list double click Battlefield-RS. Click-drag the new material onto plane01. Close the material window and rename plane01 to COL01. Right click COL01, select clone and name the clone LOD01.

Click Battlefield Tools from the menu bar, besides Export being select you should also have "Use Object Names For Export" selected. Now export using the name of the original object but replace tha 'm' with an 'a', so in this case it would read barack_a1.

How the game uses the AImeshes & standardmesh to create pathmaps.
( Warning - very technical tutorial only for advanced AI readers)

Its important to understand how the game uses the Aimesh files and standardmesh files to create pathmaps, and how the use of Aimeshes can be controlled because Aimeshes are the key to getting good game generated pathmaps.

It appears that the game will look for the Aimesh version of the standardmesh file to figured how to path the object. If there is no Aimesh the game will patharound the standardmesh file.

Note - Aimesh files are named with an ending _a1, while standardmesh files are named with an ending _m1. Questions: Can aimeshes be created for Standard mesh files that don't have the ending _m1? Do you add and ending _a1 anyway for the aimesh file?

At one time we thought that the infantry pathmap setting considerAitypes told the game to use the Aimeshes. We figured that because only infantry maps use the consdierAitypes setting and they are the only pathmaps that path the inside of buildings that the use of Aimeshes must be controlled by that settings. We though we had figured it all out until I had to throw a wrench in that idea. What about bridges? How can other pathmaps path bridges if they don't have the considerAitypes set? Also, how can vehicles use the ramp buildings in vietnam on the map Hue?

Also, when Aimeshes are present for a mod, vehicle pathmaps path a sharp outline of the buildings. Without aimeshes, a rough outline with a larger outline is pathed for vehicle pathmaps. It looks like Aimeshes are used to path the outline of the building if they are present. More to the point, it seems that the AI types setting apparently tells the game to path the building for inside use.

But that does not explain why the game paths bridges and the Hue ramp buildings differently. There has to be something different!

Camelnelle found something in the Dice AI docs that seems to be the key:
(posted from Legion of the Dragon)

Well, i think i found where the meshes are read for pathing.
I have read the ai-tuts from EA/Dice. There is a line mentioned:

addTemplate.addType flag enum

Here we can put various IT names, like ITUnit, ITTransport, ITGround, ITCover, ...
There is an ITStructure too. In the tut, it reads like this:

ITStructure. This flag marks the object as a structure. This must be set for any object that should be rendered as a house on the path finding map.

Well, when i looked into the .con-files, i found that most bridges have another IT set.
That one explains like this:

ITScaleRender. If this flag is used, the object will be rendered on the path finding maps with a smaller brush than normal. This is used to make bridges possible/easier to traverse.

There are more IT's like ITNoRender and ITNoChildRender.

I think, this might need further experiments.

---------------------
Summary:

- It appears that considerAitypes tells the game to path the inside of objects that are labeled as ITStructure, in the Ai object template.

- Objects that are labled as ITScaleRender appear to be pathed for bot use for all land pathmaps, like bridges.

 

I am hoping that someone that understands how to use GMAX or 3dxmax can help make it easier to understand. smile.gif

Oh yeah that's another reason to understand how the Aimeshes are used by the game to create pathmaps. Trenches need to be pathed only for infantry pathmaps.

So based on what we know so far, they need to be set as ITstructure in the objects AItemplate, so they will be pathed. using the standard pathmap settings.

This may be the problem I was having creating working AImeshes for GC - most of the statics did not have working AItemplates, so they are missing the ITstructure setting.

Another problem is what if you want an object to be used by vehicles but not by infantry. Look at the barb wire obstacle for example. Vehicles should be pathed to ignore it, but infantry will take damage, so they should avoid it. I don't know how to generate pathmaps so this one object will be ignored by vehicles but not by infantry.

 

The aiMeshes, something I have been learning and working on for quite sometime. I will try to fill in some information here on what I have learned and hope it will be of some help. Most of what I have learned is by trail and error, working with others such as FourCentsShy, and some email conversations with Tobias Karlsson.

First lets clear up some information. You will have to build an AI Template for each object if you want the bots to use it and get it to pathmap right using a aiMesh. One or more of the following IT calls will need to be in the template.

ITStructure tells the game engine that the object is a structure and to path it as such. It also will use an aiMesh if there is one present for that structure if they are called for that vehicle type in the AIpathFinding.con file.

ITScaleRender tells the game engine to path the object with a smaller brush and is used to pathout bridges. If you use this call on other structures it with path them out in more detail weither you use an aiMesh or not.

This is a qoute from the AI documents by Tobias Karlsson of EA games on the use of IT calles and pathmapping. It will bear out the statements I just made above.

QUOTE
ITStructure. This flag marks the object as a structure. This must be set for any object that should be
rendered as a house on the path finding map.

ITNoRender. If this flag is used, the object will not be rendered on the path finding maps.

ITNoChildRender. If this flag is used, the object’s child object will not be rendered on the path finding
maps.

ITScaleRender. If this flag is used, the object will be rendered on the path finding maps with a smaller
brush than normal. This is used to make bridges possible/easier to traverse.


The aiMeshes are called during the pathing process by the "considerAITypes" call in the AIpathFinding.con file.

The aiMeshes are added to the StandardMesh file if the are present during the pathing process and are not used during game play. They are used to create pathmaps only. What happen is the aiMesh is applied to the objects Standardmesh file and anything below or perpendicular to the axis of the aiMesh is not pathed out. Think of it as a stencil that is used like you would use cardboard cutout stencils of letters or numbers and a can of spray paint to paint numbers or letters onto you mail box for example. Lets look at a image of the baracks with the aiMesh applied.

user posted image

Knotice that the aiMesh in green is set just above the floor of the barack but low enough to have the beds, and foot lockers protruding above it. Also knotice the columes extending on through the aiMesh perpendicular to its axis. Now lets look at the pathmap it produces.

user posted image

See how the pathed area looks in relationship to the position of the aiMesh to the structure?

Knotice the small sections of the aiMesh on the hand rails of the stairs and the pathmap image created and you will see the white lines extending out to path them (the hand rails) so the bots will not run into them. By the way these small aiMeshes do not have to be attached to the main aiMesh to work. This is done because even if you did extend the large main aiMesh out to cover the stairs you would not get the hand rails because they are just small vertical post. This technique is used on all stairs and rails of bridges.

more to come.

 

Ok lets make a aiMesh using the barack form the example above and the small tutorial provided by INXS that Dnamro posted.

First this is not a tutorial on how to use GMAX or 3dsmax. You need to be familiar with which ever program you use. Each program has tutorials on there use and you will need to know the basics only to accomplish this task. You will also need the Battlefield plugins installed from the lastest MDT for either program you use.

Ok lets begain. (you will need to have the StandardMesh files extracted to a working folder..if using 3dsmax you will also need the textures to get the objects to render them in max)
I am using 3dsmax but it works the same with GMAX.

Step 1. Import the Barack_m1.sm into 3Dsmax as shown. Remember you only need the main visiable LOD object so leave the COL etc out.

user posted image

Now lets goto the Top view and zoom and pan till the whole building is in view and centered in the viewport like so.

user posted image

Step 2.

Now on the panel to the right make sure you have Geomentry and Standard Primitives selected. Now select plane. You will see a roll out drop down..the first area will be name and color..it should say LOD01_barack_m1-1 and the color square will show what color the plane will be..it doesn't matter the color, what ever your preference. Next down will be Creation Method and you want Rectangular for this object. Now the area we are concerned with here is in the Parameters. You will see where the is a selection for "length Segs and Width Segs, SET BOTH OF THESE TO 2.
Place your pointer near the top left corner of the baracks and left click and hold left button down..dragging to the lower right corner and let go of the mouse button. You will se the plane created. You can press the "H" key and make sure the plane1 is selected and rt click the image and select "Move, Rotate, or Scale" from the Quad menu to adjust it if need be. It should look something like this.

user posted image

Step 3.

Now extend\change to the Perspective viewport, select Move form the Quad menu (make sure the plane1 is selected! hit the "H" key to be sure) and use the Gizmo to raise the plane up on the barack till it is just above the floor or where you want it to be. You may have to select the barack and rotate or pan it to get the best view. You can also scale it to better fit now also by selecting scale from the Quad menu (make sure the plane and not the barack is selected!) It should look like this now.

user posted image

Step 4.

Now lets do the small meshes for the Hand rails. Extend\change to the left or right viewport and once again scale or pan the object in the viewport till all of it is visible. Select plane form the objects type making sure the same values we set prior when making the main plane for the barack. Now on each side of the barack make a small plane around the hand rails of the stairs like so.

user posted image

Now lets extend\change back to the top viewport. Select one of the small planes you just made, left or right side..don't matter by clicking on it and chose Move from the quad menu or main tool bar and move it to the closest hand rail and center it best you can. Now select clone then move, either from the Quad menu or tool bar and move the clone to the other hand rail. Now do the same thing for the stairs on the other side of the baracks. Now switch back to perspective view and it should look like this.

user posted image


Step 4.

Now hit the "H" key and select the Baracks ONLY and then delete it. (3dsmax 5..edit..delete, 3dsmax 6..rt click..delete and what ever it is in GMAX) and you shouls have the following.

user posted image

Again using the "H" key click on "All" in the window then "Select". Now click the planes and rt click and in the Quad menu, the "Convert To" them select "Editable Mesh".
Now click on the main or Plane 1 and and look at the panel to the right. Near the bottom you will see a button that says "Attach All" click on this and a window will pop up, chose "All" then "Attach". Now you should have one object called Plane 01 and it should look something like this.

user posted image

Step 5.

Now lets add the material to it. Hit the "M" key and it will bring up the material Manager. At the top you will some square boxes with little sphere's in them. Select the next UNUSED one, usally the 2nd one then the "Standard" button just below the sphere's then select "Battlefield RS" from the drop down list that comes up on the right. Ok now with the left mouse button click on the sphere you just added the material to and drag it ontop of the "Plane 01" it will turn grey as the material is added. You can close the material editor at this point. It will look like this.

user posted image

Step 6.

Now if its not selected selected select the Plane 01 and in the window to the top right in the side panel and rename it to "COL01". Now select "Clone" from the edit menu and name the clone to "LOD01". Now you have made the aiMesh and are ready to export it. Chose Battlefield Tool' from the tool bar and then Export (it by default will be already selected. These are the settings I use.

user posted image

The most important one is "Use Object Names for Export". Now click on the Export button and the file save dialog box pops up. You want to save it to the SAME NAME it was EXCEPT change the _M1 on the end to a _A1 like so.

user posted image

I would suggest saving to a seperate directory. Now you have created a aiMesh for the baracks. This will need to go into the aiMesh directory in the games archive.

Ok here is the next thing I need to tell you about. Not all objects will work well with an aiMesh. It largely depends on how the modeler made them. Some will have structure below your mesh and it will path out on the pathmaps. You will have to get creative on some objects. I suggest looking at many of the aiMeshes that EA\Dice people have created by first importing the object then the aiMesh to get some ideas.
Another major thing I have found out is this. To get the meshes to work in a mod you are going to have to "Compile " them. To do this extract the aiMeshes folder to the game root..ie C:\Program Files\EA GAMES\Battlefield 1942. Now crank up Battlefield 1942 debugger and load into any map in SP or coop..it doesnt matter. Once in game hit the "P" key to pause the game the hit the "~" key to drop the console and type the following.

ai.compileAIMeshes

It will work abit and tell you this has been done. Quit the game and look in the aiMeshes folder in the game root and you will see a new set of StandardMesh files of the same names as the meshes but with an ".aim" extension. Once I did this my custom aiMeshes started working for me in mods. I just leave the extracted aiMeshes file where it is in the game root directory. No need to pack it back as an .rfa. It works better for me where it is unpacked.

I hope this is of some help.

One last thing. I have never found that the game pathing engine will produce pathmaps that do not need editing. This is weither your using aiMeshes or not..no matter the way you run the maps. I ALWAYS hand edit all my pathmaps.

More to come on this.