Game Development Community

Terrain texture loading updates.

by Gregory "Centove" McLean · in RTS Starter Kit · 11/26/2004 (6:26 am) · 2 replies

Currently with the terrain texture loading code you wind up stuck with the terrain textures locked into a full path that is written in the terrain file. The loading code makes a half hearted attempt to load the texture anyway from the game path. Examination of the code leaves you scratching your head wondering what it is trying to do. Now if you stick to the default directory layout all is well and good. However if start shuffling things around to a layout you are comfortable with things start getting interesting.

This patch fixes that to be a bit more sane. What it does:

There is a new member to the terrainblock datablock, MaterialPath. What you stick in here is the path to the top directory of the terrain textures to use for this terrain.

For example say you stick all your terrains in data/textures/terrain//

What you would put in the MaterialPath in this case is:
data/textures/terrain/

(yes the last / should not be there)

Then when loading the terrain it will build a filename of:
data/textures/terrain//

And try and load that. If however that fails, it will try and load what the terrain file has in it. If that fails it will attempt to load:
/

If that happens to fail we try as a last resort:
/default

If that fails, it generates a 256x256 empty bitmap.


Next it adds two more members to the terrainblock:
SelectionTexture & DynamicLightTexture

These two fix up the loading of the hardcoded values for those two textures.

Simliar to the above, it will try the one specified in the terrain block failing that fall back to the hardcoded values.

It also drops support for loading version 1 terrain files (anyone still have those?) If you want that support, just ignore that hunk in the patch file.

The patch can be fetched from Here.

Apply it as such:
patch -p1 <terrData.patch -d <directory that contains the RTSKit>

Enjoy.
(updated link)

#1
02/05/2005 (7:44 pm)
Thanks Gregory. We really should remove all the hard-code directory references. :)
#2
08/20/2006 (1:07 pm)
That link appears dead, and the textures are still hard coded.
Does anyone have an updated link for this patch?