Automatic blended terrain texture property map generation
by Konrad Kiss · 08/04/2008 (12:48 pm) · 2 comments
So for the puffs and sounds to work - aside from engine tweaks - you need the property maps.
What we'll do is find all the textures (.jpg and .png) in the scriptsAndAssets/data/terrains directory and assign default values to them. Then, if we need to change the color for a puff (ie. snow), we just redefine the property map and override the default declaration the usual way. (search for a propertyMap.cs to see what that looks like). Once the mapping is done, the rest of the propertyMap.cs files that override the defaults are loaded much like material.cs files are loaded in TGEA.
Anyway, create a propertyMaps.cs in your scriptsAndAssets/data directory with the following code:
Let's make sure it runs, so in scriptsAndAssets/client/init.cs after the loadMaterials(); call, insert the following code:
That's it. Read my other resource about how to use this to finally have vehicle puffs and player foot puffs working here. I tested this in TGEA 1.7.1, but this should work in other versions.
What we'll do is find all the textures (.jpg and .png) in the scriptsAndAssets/data/terrains directory and assign default values to them. Then, if we need to change the color for a puff (ie. snow), we just redefine the property map and override the default declaration the usual way. (search for a propertyMap.cs to see what that looks like). Once the mapping is done, the rest of the propertyMap.cs files that override the defaults are loaded much like material.cs files are loaded in TGEA.
Anyway, create a propertyMaps.cs in your scriptsAndAssets/data directory with the following code:
//-----------------------------------------------------------------------------
// Torque Game Engine Advanced
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
function loadPropertyMaps()
{
// first, autocreate property maps
// for jpegs
for( %file = findFirstFile( "./terrains/*.jpg" ); %file !$= ""; %file = findNextFile( "./terrains/*.jpg" ))
{
addMaterialMapping( FileBase( %file ) , "sound: 0" , "color: 0.4 0.4 0.4 0.4 0.0" );
}
// for pngs
for( %file = findFirstFile( "./terrains/*.png" ); %file !$= ""; %file = findNextFile( "./terrains/*.png" ))
{
addMaterialMapping( FileBase( %file ) , "sound: 0" , "color: 0.4 0.4 0.4 0.4 0.0" );
}
// now load property map overrides
for( %file = findFirstFile( "./terrains/*/propertyMap.cs" ); %file !$= ""; %file = findNextFile( "./terrains/*/propertyMap.cs" ))
{
exec( %file );
}
}Let's make sure it runs, so in scriptsAndAssets/client/init.cs after the loadMaterials(); call, insert the following code:
exec("~/data/propertyMaps.cs");
loadPropertyMaps();That's it. Read my other resource about how to use this to finally have vehicle puffs and player foot puffs working here. I tested this in TGEA 1.7.1, but this should work in other versions.
About the author
Lead Developer at Bitgap Games (www.bitgap.com) currently working on Xenocell (www.xenocell.com) a massively multiplayer action strategy game based on Torque 3D technology.
Torque 3D Owner Daniel Buckmaster
Per-material friction for vehicles is also something I'll be looking into.