Pārlūkot izejas kodu

Expose new formats to the editor.

Lukas Joergensen 11 gadi atpakaļ
vecāks
revīzija
ef11b565bf
2 mainītis faili ar 43 papildinājumiem un 1 dzēšanām
  1. 37 0
      Engine/source/terrain/terrData.cpp
  2. 6 1
      Engine/source/terrain/terrData.h

+ 37 - 0
Engine/source/terrain/terrData.cpp

@@ -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()
  : mSquareSize( 1.0f ),
    mCastShadows( true ),
@@ -270,6 +282,27 @@ bool TerrainBlock::_setBaseTexSize( void *obj, const char *index, const char *da
    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 )
 {
    TerrainBlock *terrain = static_cast<TerrainBlock*>(obj);
@@ -1105,6 +1138,10 @@ void TerrainBlock::initPersistFields()
          &TerrainBlock::_setBaseTexSize, &defaultProtectedGetFn,
          "Size of base texture size per meter." );
 
+      addProtectedField("baseTexFormat", TYPEID<baseTexFormat>(), Offset(mBaseTexFormat, TerrainBlock),
+         &TerrainBlock::_setBaseTexFormat, &defaultProtectedGetFn,
+         "");
+
       addProtectedField( "lightMapSize", TypeS32, Offset( mLightMapSize, TerrainBlock ),
          &TerrainBlock::_setLightMapSize, &defaultProtectedGetFn,
          "Light map dimensions in pixels." );

+ 6 - 1
Engine/source/terrain/terrData.h

@@ -74,6 +74,8 @@ protected:
       NextFreeMask = Parent::NextFreeMask << 6,
    };
 
+public:
+
    enum BaseTexFormat
    {
       NONE, DDS, PNG, JPG
@@ -94,6 +96,8 @@ protected:
       }
    };
 
+protected:
+
    Box3F mBounds;
 
    ///
@@ -235,7 +239,8 @@ protected:
    // Protected fields
    static bool _setTerrainFile( void *obj, const char *index, const char *data );
    static bool _setSquareSize( void *obj, const char *index, const char *data );
-   static bool _setBaseTexSize( void *obj, const char *index, const char *data );
+   static bool _setBaseTexSize(void *obj, const char *index, const char *data);
+   static bool _setBaseTexFormat(void *obj, const char *index, const char *data);
    static bool _setLightMapSize( void *obj, const char *index, const char *data );
 
 public: