View Full Version : Misc Turn your Static/Overgrowth field into one StaticObject

2014-02-21, 17:43
Hi guys,

In this tutorial I'll be explaining you how to turn your overgrowth fields into singular static meshes for each field. Why would you do this? Optimization and performance.
A single field(static or overgrowth) usually consists of thousands of circular field objects that often hurt performance on low rigs quite badly.
After this tutorial each field will only be 1(or 2 if split up) static objects. Substantially improving the way it runs. As example, I had a 4k map with around 25 fields for a total of 17000 field statics. After this method I left with 25 field statics. The map went from 50 to 90FPS. So moving from 17000 statics which each 30 polygons and each one drawcall we'll move to 25 statics with around 20000 triangles each and only 25 drawcalls in total. moving from 17000 to 25 drawcalls helps amazingly with the performance :)

I'm not really good with tutorials so feel free to ask questions after :)
Also this method is not 100% working. I myself had some issues and artifacts in the end. So remember that if you run into trouble.

Also this method goes with all credit to [R-DEV]Amok@ndy of who I got the idea and method.

I will not be explaining this part as Rhino has already done that for me :)

How exactly you archive your overgrowth fields(manually or by rhino's tutorial) isn't really important, what is important is that you turn your field overgrowth into statics as by step 4 and beyond in that tutorial.
To start the method described in this post you need to at the end of rhino's tut have a staticobjects.con file consisting of only your field statics. Like this:

if v_arg1 == BF2Editor
console.allowMultipleFileLoad 0
run /objects/vegitation/pr/fields/corn/corn_maize_clump_01/corn_maize_clump_01.con
run /objects/vegitation/pr/fields/corn/corn_maize_clump_01/corn_maize_clump_01_lod.con
run /objects/vegitation/pr/fields/wheat_clump_01/wheat_clump_01.con
run /objects/vegitation/pr/fields/wheat_clump_01/wheat_clump_01_lod.con
console.allowMultipleFileLoad 1

rem *** corn_maize_clump_01 ***
Object.create corn_maize_clump_01
Object.absolutePosition -119.780/65.900/-146.483
Object.rotation -161.1/0.0/0.0
Object.layer 0

rem *** corn_maize_clump_01 ***
Object.create corn_maize_clump_01
Object.absolutePosition -99.572/65.900/-123.243
Object.rotation -76.4/0.0/0.0
Object.layer 0

rem *** corn_maize_clump_01 ***
Object.create corn_maize_clump_01
Object.absolutePosition -90.706/65.900/-142.200
Object.rotation 170.4/0.0/0.0
Object.layer 0

rem *** corn_maize_clump_01 ***
Object.create corn_maize_clump_01
Object.absolutePosition -127.209/65.900/-138.724
Object.rotation -152.3/0.0/0.0
Object.layer 0


I made a quick map with two fields for the sake of this tutorial. I am aware they look hideous :D


What we will do here is that we will turn each field into one static. To do this we will load in the field statics into 3dsmax and turn each field into one object. For this you will need
-POE BF2 Tools for 3dsMax : http://realitymodfil...smax9_0.30a.zip
-your staticobjects.con file as described in step 0.
-a little bit of experience with 3dsmax. Such as moving and selecting objects. Otherwise you'll get confused really fast.

Start your 3dsmax and start a new scene. Make sure you have the correct unit setup.
(customize --> Unit Setup --> choose generic Units --> System Unit Setup --> 1unit = 1.0 Inches)

Go to the BF2 tab(after installing POE tools successfully) and select BF2 Lightmapping.
Don't mind too much what's in these text-fields, this tool is usually used for lightmapping in max but we don't really need that now. Click
on the Load StaticObjects.con button. Navigate to your level folder and select the staticobjects.con file that contains your static fields.

Now max will load in all statics, this might take a while. Just let it do it's thing :)
Now moving around in the viewports(if you don't know how, look up some simple beginner tutorials on 3dsmax) you should be able to find the fields after they got loaded in.
TIP! For easy navigation in the viewports you can also load in your terrain into the scene. To do this load up the BF2 Lightmapping
window back in, and this time use the button Load Land and locate your Heightdata.con in your level folder.

Now you might notice that after you have loaded them all in your 3dsmax became really slow. To make our work easier, we will turn each field into it's own max scene/file. This makes working on each one easier and faster. And if you keep the files,you can easily make a change later to an individual field.
Select all field objects of one particular field(drag a box around them, ideally in Top-view as it makes it easier) and go File --> Save Selected.
This make make the selected field objects save into their own max scene. I suggest making a new folder and placing all fields with a good name in there.
So for example,based on which fields you are making call them wheat_01,wheat_02.... I got one wheat and one maize field so I'll call them wheat_field_01.max and maize_field_01.max respectively . Now if you have lots of fields, I suggest you make a little layout plan of all your fields and name them respectively, this makes it easier after
to identify which field goes where. For example this one like I did for a map I was working on: 02.21.2014-18.24.43 - wouterjansen's library (http://screencast.com/t/IafCAtYBVED)

I also suggest saving the current scene(with all fields) in-case if you make a mistake. I always call mine 'master_scene'.

Important note! Usually one saving one field is fine, but when you have really big ones, I suggest splitting them up. I have noticed that
when they go above 32000 triangles you need to split them up. Otherwise you'll 3dsmax will not be exporting the fields and you might
get odd artifacts. I suggest to keep it below 28000 and in general suggest to make small/medium fields.

Now I'll only do this for one field, obviously you need to repeat this process for each field you make.
Go ahead and open one of the separate field scenes. I'll be working with wheat_field_01.
If you were to press H(hierarchy) now you can see a list of all the field objects like here for mine:

important note: some crops have LOD1 meshes using lower-res textures. These are not needed as the fields will be so large anyway. Ideally we would keep them but that would make this tutorial even harder. So for those crop types you'll need to manually remove all LOD1's of each crop.
Which is ALOT of work. I have never done it myself as so far I have only done this on wheat and sunflower types, which don't have the lods.

Now we only need the ones that say 'typename'_clump_01=0. All the others(called helpers) are not needed and can be removed.
In the hierarchy, deselect Geometry in the List Types:
This will hide the objects that we will need and only show the unwanted helpers. Go ahead and press the All button to select them all and
then press Select in the bottom right. Now simply press delete to remove them. Go back to the hierarchy and show the geometry again.
Now you will only see the ones we needed left in the list. Go ahead and select one, it doesn't really matter which one.
Now we will use this one to combine all of them into one.

Right click somewhere in the viewport and go Convert to --> Convert to Editable Poly.

Now let's go to the Modify Tab and press the little button next to Attach.

Just like in the hierarchy screen we can nowpress All to select them all and now press Attach. This will combine all into one big static.
Now we can do a few things.

A. Name the object.
Still in the modify tab, in the top textbox you can name your object. This is important for later as it will be the name of your exported static.
Again, use a reference file to name all your fields so you now which one goes where. I name mine wheat_field_01.

B. Center the anchor and object
Now we will move the anchor to the middle of the object, so later on we can move it more easy in the BF2 Editor. let's go to the
hierarchy tab(not the window, the tab!!)

Here we will first move the pivot/anchor. So press the Affect Pivot Only button. Now press the Center to Object button to center
the pivot to the middle of the field. Now deselect the Affect Pivot Only button. Now we will move the object to the middle of our scene. this
is important for exporting the field static. Make sure you have the move tool selected on the top toolbar:

now in the bottom of the screen, in the coordinate text fields type in 0 in each one to move the object to the middle of the scene.

C. Fix the UV and apply texture.
As you recall, we used the BF2 Lightmapping tool to load in our static. This tool doesn't really care about the textures as it only cares about
lightmaps. In order for our fields to have textures we need to fix the UV map. The UV map we need is in the wrong channel. So we need to move it to thecorrect one. First let's setup our material(press M).

Press teh Standard button to change it. In here select BF2 StaticMesh2. Now we need to load in our correct texture.
you can find it by using BFMeshviewer on the original overgrowth object and look what textures it uses. I know that this wheat object
uses C:\Program Files (x86)\EA GAMES\Battlefield 2\mods\pr_edit\objects\vegitation\pr\textures\whea t_le.dds so I can go ahead
and press the Base button and to and locate that texture.

Now let's press the 3rd button from the left to assign it to our selected field. And use the 4th button from the right to show it in the viewports.

If we now go zoom in on one of the little fields, we'll notice that it looks really bad. that's cause we still haven't fixed the UV.
Go ahead and close the material window and go back tot he Modify tab. In the Modifier List go and select Unwrap UVW.


Now go down to the Parameters Part and in there change the channel to 9. This is the one that holds the correct UV map which we need to copy to
another channel.

We will now Save this UV map so go ahead and press the Save button right above. Doesn't really matter what you save it as
or where. i'll save mine just as UV.uvw . Now let's change back to channel 1,the channel which our UV map should be on. Now press Load
to load up the UV we saved from channel 9 and load it into channel 1.
If we now look at our object in the viewport you'll see the texture looking correct. We are now ready for export!

Go to the BF2 tab again and this time choose BF2 Utilities and choose StaticMesh in the wizard lists while having your field selected. This sets up
our object so it has all the right helpers.

If we now open the hierarchy window again(press H) we can see it made all the right helpers.

Now this static is ready for export. Go to the BF2 tab again and select BF2 Exporter.
Now in order to setup the Exporter right I quote Rhino's tutorial on 'Creating a Simple Structure':

[QUOTE='[R-DEV]Rhino;1432884']The Export window will popup and in the top right hand corner of it will be a small button called "Run Setup", click that.
http://realitymodfiles.com/rhino/tuts/simple_structure/tn/tut_simple_structure435.jpg ('http://realitymodfiles.com/rhino/tuts/simple_structure/tut_simple_structure435.jpg')

A new window will popup and in it, we need to define a bunch of settings. The output directory is to what modification all your exports get exported to, I would advise you to export to PR_EDIT but export to w/e mod you like, but export to the "bf2" or "pr" mod at your own risk. I have filled out in it: C:/Program Files (x86)/EA GAMES/Battlefield 2/mods/pr_edit/ Thou this will most likley be different on your PC since I'm on a 64bit system, hence the "Program Files (x86)" in the file path and you might have your BF2 installed onto a different hard drive than C: or in a different location. All in all, its best to just browse to the mod folder and select it by clicking the Browse button :)

In section 2 you need to list all the mods you might be using textures etc out of, so in my list I have:

Though you can include as many mods as you like etc. The first 2 lines, /rawData/ and /mods/bf2/ are 100% critical, as well as a bunch of others if you are exporting to pr / pr_edit.

Your settings should look like this by then end:
http://realitymodfiles.com/rhino/tuts/simple_structure/tn/tut_simple_structure436.jpg ('http://realitymodfiles.com/rhino/tuts/simple_structure/tut_simple_structure436.jpg')

Now your exporter is setup and everything should be good for exporting and with any luck you wont need to do this again, unless you reinstall etc :D

Once that is done we are good to go!
Fill in a folder in which you will want to place your fields. Now this HAS to be in the vegitation folder I found. Otherwise it won't have the 'wave'
animation. So I picked /vegitation/tutorial_fields/. the object name should already be correct(if not you did something wrong).
Change the dropdown menu from 'auto' to 'none'. Otherwise it will make lightmapsamples which you really don't need and is a big waste of time. Then
Go ahead and press export.


Now all our static is missing is a proper .tweak file. Now go ahead and locate your newly exported static. There you will have
a 'name'.con and a 'name'_col.con file. Go ahead and make another file and call it 'name'.tweak.

Normally both con files should be correct and look like this:
GeometryTemplate.create StaticMesh wheat_field_01

ObjectTemplate.create SimpleObject wheat_field_01
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.Anchor 0.0/0.0/0.0
ObjectTemplate.creator WOUTER_HOME:Wouter
ObjectTemplate.geometry wheat_field_01

include wheat_field_01.tweak

and the col one:

ObjectTemplate.create SimpleObject wheat_field_01_col
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.creator WOUTER_HOME:Wouter

include wheat_field_01_col.tweak

The tweak file we'll need to fill in ourselves.
In the end it should look like this one,for which you only need to change the 'wheat_field_01'name to what you named your object.

rem *** Generated with Bf2Editor.exe [created: 2006/5/15 12:52]
GeometryTemplate.doNotGenerateLightmaps 0
GeometryTemplate.lightmapOverride 0
GeometryTemplate.compressVertexData 1
GeometryTemplate.maxTextureRepeat 16
GeometryTemplate.glowing 0
GeometryTemplate.noLighting 0
ObjectTemplate.activeSafe SimpleObject wheat_field_01
ObjectTemplate.creator "Mineral"
ObjectTemplate.modifiedByUser "Mineral"
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.cullRadiusScale 7
ObjectTemplate.geometry wheat_field_01
ObjectTemplate.hasMobilePhysics 0

4. DONE!

Now if you go ahead you will find your new static which you can place like any other static on your map.
Now if you kept enough references and had a good layout and structure before this tutorial you'll have no trouble placing the field back in the right spot. If not you can load up your staticobjects.con file with all your separate fields and use that as reference. then later you only need to copy the new fields to your real staticobjects.con file.

I hope it works for you and that you get better performance on your map ;) I made this tutorial quite fast on request of [R-CON]Rabbit so I apologize for unclear parts or mistakes. Feel free to ask questions if something isn't clear. Although don't PM me about it, just post in this thread so everyone can see it.

2014-02-22, 08:31
Thanks for the effort! More optimization is really important for all maps & map makers.

Draw calls are the #1 performance killer in PR. [Followed closely by effects :p]

2014-03-19, 10:35
just though i share this screen with you guys.

the whole field is divided into 16 single statics unfortunately i never got the time to write a tutorial, but minerals method should work fine