|
@@ -174,6 +174,18 @@ ConsoleFunction(getTerrainUnderWorldPoint, S32, 2, 4, "(Point3F x/y/z) Gets the
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+typedef TerrainBlock::BaseTexFormat baseTexFormat;
|
|
|
|
+DefineEnumType(baseTexFormat);
|
|
|
|
+
|
|
|
|
+ImplementEnumType(baseTexFormat,
|
|
|
|
+ "Description\n"
|
|
|
|
+ "@ingroup ?\n\n")
|
|
|
|
+{ TerrainBlock::NONE, "NONE", "No cached terrain.\n" },
|
|
|
|
+{ TerrainBlock::DDS, "DDS", "Cache the terrain in a DDS format.\n" },
|
|
|
|
+{ TerrainBlock::PNG, "PNG", "Cache the terrain in a PNG format.\n" },
|
|
|
|
+{ TerrainBlock::JPG, "JPG", "Cache the terrain in a JPG format.\n" },
|
|
|
|
+EndImplementEnumType;
|
|
|
|
+
|
|
TerrainBlock::TerrainBlock()
|
|
TerrainBlock::TerrainBlock()
|
|
: mSquareSize( 1.0f ),
|
|
: mSquareSize( 1.0f ),
|
|
mCastShadows( true ),
|
|
mCastShadows( true ),
|
|
@@ -186,6 +198,7 @@ TerrainBlock::TerrainBlock()
|
|
mCell( NULL ),
|
|
mCell( NULL ),
|
|
mCRC( 0 ),
|
|
mCRC( 0 ),
|
|
mBaseTexSize( 1024 ),
|
|
mBaseTexSize( 1024 ),
|
|
|
|
+ mBaseTexFormat( TerrainBlock::JPG ),
|
|
mBaseMaterial( NULL ),
|
|
mBaseMaterial( NULL ),
|
|
mDefaultMatInst( NULL ),
|
|
mDefaultMatInst( NULL ),
|
|
mBaseTexScaleConst( NULL ),
|
|
mBaseTexScaleConst( NULL ),
|
|
@@ -269,6 +282,27 @@ bool TerrainBlock::_setBaseTexSize( void *obj, const char *index, const char *da
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool TerrainBlock::_setBaseTexFormat(void *obj, const char *index, const char *data)
|
|
|
|
+{
|
|
|
|
+ TerrainBlock *terrain = static_cast<TerrainBlock*>(obj);
|
|
|
|
+
|
|
|
|
+ EngineEnumTable eTable = _baseTexFormat::_sEnumTable;
|
|
|
|
+
|
|
|
|
+ for (U8 i = 0; i < eTable.getNumValues(); i++)
|
|
|
|
+ {
|
|
|
|
+ if (strcasecmp(eTable[i].mName, data) == 0)
|
|
|
|
+ {
|
|
|
|
+ terrain->mBaseTexFormat = (BaseTexFormat)eTable[i].mInt;
|
|
|
|
+ terrain->_updateMaterials();
|
|
|
|
+ terrain->_updateLayerTexture();
|
|
|
|
+ terrain->_updateBaseTexture(true);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
bool TerrainBlock::_setLightMapSize( void *obj, const char *index, const char *data )
|
|
bool TerrainBlock::_setLightMapSize( void *obj, const char *index, const char *data )
|
|
{
|
|
{
|
|
TerrainBlock *terrain = static_cast<TerrainBlock*>(obj);
|
|
TerrainBlock *terrain = static_cast<TerrainBlock*>(obj);
|
|
@@ -961,7 +995,7 @@ String TerrainBlock::_getBaseTexCacheFileName() const
|
|
{
|
|
{
|
|
Torque::Path basePath( mTerrFileName );
|
|
Torque::Path basePath( mTerrFileName );
|
|
basePath.setFileName( basePath.getFileName() + "_basetex" );
|
|
basePath.setFileName( basePath.getFileName() + "_basetex" );
|
|
- basePath.setExtension( "dds" );
|
|
|
|
|
|
+ basePath.setExtension( formatToExtension(mBaseTexFormat) );
|
|
return basePath.getFullPath();
|
|
return basePath.getFullPath();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1104,6 +1138,10 @@ void TerrainBlock::initPersistFields()
|
|
&TerrainBlock::_setBaseTexSize, &defaultProtectedGetFn,
|
|
&TerrainBlock::_setBaseTexSize, &defaultProtectedGetFn,
|
|
"Size of base texture size per meter." );
|
|
"Size of base texture size per meter." );
|
|
|
|
|
|
|
|
+ addProtectedField("baseTexFormat", TYPEID<baseTexFormat>(), Offset(mBaseTexFormat, TerrainBlock),
|
|
|
|
+ &TerrainBlock::_setBaseTexFormat, &defaultProtectedGetFn,
|
|
|
|
+ "");
|
|
|
|
+
|
|
addProtectedField( "lightMapSize", TypeS32, Offset( mLightMapSize, TerrainBlock ),
|
|
addProtectedField( "lightMapSize", TypeS32, Offset( mLightMapSize, TerrainBlock ),
|
|
&TerrainBlock::_setLightMapSize, &defaultProtectedGetFn,
|
|
&TerrainBlock::_setLightMapSize, &defaultProtectedGetFn,
|
|
"Light map dimensions in pixels." );
|
|
"Light map dimensions in pixels." );
|
|
@@ -1200,7 +1238,7 @@ void TerrainBlock::unpackUpdate(NetConnection* con, BitStream *stream)
|
|
{
|
|
{
|
|
mBaseTexSize = baseTexSize;
|
|
mBaseTexSize = baseTexSize;
|
|
if ( isProperlyAdded() )
|
|
if ( isProperlyAdded() )
|
|
- _updateBaseTexture( false );
|
|
|
|
|
|
+ _updateBaseTexture( NONE );
|
|
}
|
|
}
|
|
|
|
|
|
U32 lightMapSize;
|
|
U32 lightMapSize;
|