HomeTutorials Understanding the Forests.dat File

Understanding and Exploiting 
the FORESTS.DAT file

by Jim "Sniper" Ward


I thought I'd put everything I know about forest regions into a single thread.  First off, they're hard coded, so entering them in the .REF file only screws them up, you have to edit them in the FORESTS.DAT file, and they only show up in the RE object menu as "track objects" (?), no way to change the category.

Forest regions have no .S or .SD files - that's the part that's hard coded.  The Forests.dat is only used by the Route Editor - once youve installed a forest from the Route Editor it appears as an item in the World .W file.  This entry in the .W file lists the .ace file in use.

Whatever texture you apply will be a simple 2-dimensional cross shape:

This has some obvious disadvantages,  It does default to ESD 252, so any ace file you use has to be copied to all the seasonal and snow subfolders to avoid error messages (the forests.dat file is hard-coded to use the seasonal folders), and it looks pretty bad close up, especially from certain angles, depending on which texture you use. The visible distance is problematic sometimes too, they have a tendency to suddenly pop up all at once.

The big advantage is populating large areas with trees, since the shape is so simple, there's no complex lighting & geometry calculations. And it don't matter if there's one or 1000, since they're all the same shape and texture the graphics hardware runs thru the math very quickly, and treats them all as a single object for the lighting and viewing angle calculations. Framerates, baby.

So how to hack it? That's actually the simple part, open Forests.dat in wordpad. There is a number right under the header (32 in this one, circled in red), this is the total number of forest regions, and it has to match however many lines you have. I got up to 39 without errors in my latest, I don't know if there's a limit. Each line is one forest region object, and has six fields in it.

The first one, inside the quotes, "tree01", is the label that shows up in the object menu.  The second, "Tree1.ace", is the name of the ace file in \Textures that will be applied to the shape.
After that are 4 numbers. The first is overall width of the cross in meters, the second is height. The last two numbers are scaling multipliers, minimum and maximum scales for the objects. For these, if you want a tree 2 meters high and 1 meter wide, the first numbers would be 1.0f 2.0f. Making the last two numbers 1.0f 1.0f would give a uniform size, all the trees would be 2m high 1m wide. The defaults make them slightly different (0.9f 1.1f) for variety, if you made them 0.5f 2.0f, that would give a maximum multiplier of two and a minimum of one half, so the biggest tree in that region would be 4 meters high, the smallest would be one meter.

So let's get on with hacking this thing already, enough of the explanations. First I find a texture that strikes my fancy, like Jason's palm trees for example.

Hmm, no palm trees in this route, but flat people might texture OK, let's try it. Being a lazy SOB who don't like to type, I right click on the file, select "rename", and instead of renaming it, I just hit CTRL-C. That copies the filename to the clipboard so I don't make a mis\*.*\take when I type it.

I type whatever I'm gonna call this new thing between the quotation marks to replace the original label, then I click-drag to highlight their usdecidtree1.ace, and hit CTRL-V to paste in the name of the ace file. You can type it instead, just make sure you spell it right. Since these are humanoids of the female persuasion, I make them half a meter wide and 1 1/2 meters high. I don't have a pic of Darrel Hannah, so I'm not doing "attack of the 50 foot woman" here.

Hmm. Looks pretty bad, some experimenting is necessary to see what textures are suitable for this thing. It will apply whatever ace you choose to all four sides of the cross, and the transparency will be applied to each side as well.

Well I'll be a two-headed cow!

Animal, vegetable, or mineral, if you're gonna use it as a forest region object you gotta pretend it's a vegetable and copy the main ace file to all the \textures subfolders except \night if they ain't already in there.

So just to clear up the cow-nfusion, think of a forest region as a shape, with the .S file being scaleable, and instead of calling for a specific .ACE file, it will accept whatever ace file names you put in the FORESTS.DAT file. It has a top-secret hidden mystery .SD file that calls for extended shape data of "all seasons", and since you can't find it to edit it, you gotta have whatever .ACE file you use in all the seasonal folders.


Increasing Forest Density

Forests in the west can be pretty thick! I wanted to see how far I could go and still run decently. There are 6 overlapping forests on each side of the track, mostly trees, but some stumps too. I set each at a density of 5000.

From the rear of a caboose, I dropped from 26 to 20fps. with the steam engine and several cars in the view, from 22 to 15-17fps. Not too bad for a really thick forest of various trees!

Overlapping forest regions can also be done to add variety in tree species. However, overlapping two or three dense forest objects can be difficult to manipulate, if you need to make changes. All those green diamonds tend to get confusing.  Consider placing the forests at different heights. The trees will still conform to the terrain, but the green blocks will be up (or down) in relation to the red borders (Fred Huntley).

It doesn't do any good to keep increasing the forest density value because there is a minimum distance between trees.  The limitation is the pattern and spaces between.

Here's one of my old experiments using overlapping weed regions, what I found was that the smaller the object, the smaller the spaces in between, and the more densely they will pack in a single forest region. While editing the textures, I screwed up and forgot the alpha channel once, and this pic gives an idea of what the actual object looks like:

Essentially you can type in wierd numbers like 999999, but they will revert to whatever the maximum density is for the width of the individual object. Timken discovered that with his fir trees, the image was real skinny and the transparent edges were real wide, so even at max density the apparent spaces between the trees were real wide. After fattening up the image so that it extended to the edges of the ace file, thus,

He found that he was able to pack them in tighter (remember you can change their width/height parameters in the forests.dat).

Again, there are other limits to that, not only does it eat framerates like crazy, it also causes the route editor to crash more frequently than usual.

Changes to the forest.dat values will not change forests already placed (the info for the ones you already placed are written to the \World\*.w files) so you can experiment without messing up what you have already done.    You can change the size of forests manually in the world file with a quick search and replace using something simple as word pad, without going to all the trouble of removing them and planting more. Also (with a backup of course) you can play around with it and see what looks the best.



Replacing the forests.dat file with this one (click here) won't hurt anything already in the route, since the info for the ones you already placed are written to the \World\*.w files.

Placing the object, it has 3 little green boxes, the center one is for the actual object selection, right clicking gives you the properties window. It defaults to 50 trees per square km, which ain't much of a forest. The little green boxes at the edges are the handles, click on one of those and select the move icon, then you can drag the handles to shape it.

I usually hit W for wireframe mode since if you do this on a hillside the handles tend to get buried. Click on a handle, then zoom out so you can see what you're doing, stretch it out, zoom back in, click on the other handle, zoom back out and stretch the other side, position the whole mess. Too bad it's rectangular, gotta adjust that for curves.

Once I got it positioned, I select the center green box again, right click, and just type 9999, it will fall back to whatever the max is. These guys say it's 5000, I dunno, I never looked.

Place a few of my JP2bush1large regions along with the trees, it don't look half bad.



Another tip by Jim Ward:  Put a regular grass texture in all the folders except spring, put the grass texture as poppies in spring, and make a forest object out of it, something like this:

Forest ( "Poppies" "poppies.ace" 0.1f 0.2f 0.9f 1.1f)

That would give you a tenth of meter (about 3 1/2 inches) wide, two tenths of a meter (about 7 inches) high. If it ain't dense enough you could use overlapping regions. Putting the regular texture in all the folders except spring and night (don't need a night texture for a forest region, I did check that!), with the blooming poppies in spring, would give you the effect you're looking for. At least until the Wicked Witch of the West waves her magic wand to try to stop Dorothy from getting to Emerald City, then all bets are off, could show up in any season.


11 May 2003