"@brief The TerrainMaterial class orginizes the material settings "
"for a single terrain material layer.\n\n"
"@note You should not be creating TerrainMaterials by hand in code. "
"All TerrainMaterials should be created in the editors, as intended "
"by the system.\n\n"
"@tsexample\n"
"// Created by the Terrain Painter tool in the World Editor\n"
"new TerrainMaterial()\n"
"{\n"
" internalName = \"grass1\";\n"
" diffuseMap = \"art/terrains/Test/grass1\";\n"
" detailMap = \"art/terrains/Test/grass1_d\";\n"
" detailSize = \"10\";\n"
" isManaged = \"1\";\n"
" detailBrightness = \"1\";\n"
" Enabled = \"1\";\n"
" diffuseSize = \"200\";\n"
"};\n"
"@endtsexample\n\n"
"@see Materials\n"
"@ingroup enviroMisc\n");
TerrainMaterial::TerrainMaterial()
:mSideProjection(false),
mDiffuseSize(500.0f),
mDetailSize(5.0f),
mDetailStrength(1.0f),
mDetailDistance(50.0f),
mParallaxScale(0.0f)
{
}
TerrainMaterial::~TerrainMaterial()
{
}
voidTerrainMaterial::initPersistFields()
{
addField("diffuseMap",TypeStringFilename,Offset(mDiffuseMap,TerrainMaterial),"Base texture for the material");
addField("diffuseSize",TypeF32,Offset(mDiffuseSize,TerrainMaterial),"Used to scale the diffuse map to the material square");
addField("normalMap",TypeStringFilename,Offset(mNormalMap,TerrainMaterial),"Bump map for the material");
addField("detailMap",TypeStringFilename,Offset(mDetailMap,TerrainMaterial),"Detail map for the material");
addField("detailSize",TypeF32,Offset(mDetailSize,TerrainMaterial),"Used to scale the detail map to the material square");
addField("detailStrength",TypeF32,Offset(mDetailStrength,TerrainMaterial),"Exponentially sharpens or lightens the detail map rendering on the material");
addField("detailDistance",TypeF32,Offset(mDetailDistance,TerrainMaterial),"Changes how far camera can see the detail map rendering on the material");
addField("useSideProjection",TypeBool,Offset(mSideProjection,TerrainMaterial),"Makes that terrain material project along the sides of steep "
"slopes instead of projected downwards");
addField("parallaxScale",TypeF32,Offset(mParallaxScale,TerrainMaterial),"Used to scale the height from the normal map to give some self "
"occlusion effect (aka parallax) to the terrain material");
Parent::initPersistFields();
// Gotta call this at least once or it won't get created!
Sim::getTerrainMaterialSet();
}
boolTerrainMaterial::onAdd()
{
if(!Parent::onAdd())
returnfalse;
SimSet*set=Sim::getTerrainMaterialSet();
// Make sure we have an internal name set.
if(!mInternalName||!mInternalName[0])
Con::warnf("TerrainMaterial::onAdd() - No internal name set!");