TerrainAsset.h

Engine/source/T3D/assets/TerrainAsset.h

More...

Classes:

Public Defines

Public Functions

DefineConsoleType(TypeTerrainAssetId , String )
DefineConsoleType(TypeTerrainAssetPtr , TerrainAsset )

Detailed Description

Public Defines

TERRAINASSET_H() 

Public Functions

DefineConsoleType(TypeTerrainAssetId , String )

DefineConsoleType(TypeTerrainAssetPtr , TerrainAsset )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2013 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23#pragma once
 24#ifndef TERRAINASSET_H
 25#define TERRAINASSET_H
 26
 27#ifndef _ASSET_BASE_H_
 28#include "assets/assetBase.h"
 29#endif
 30
 31#ifndef _ASSET_DEFINITION_H_
 32#include "assets/assetDefinition.h"
 33#endif
 34
 35#ifndef _STRINGUNIT_H_
 36#include "string/stringUnit.h"
 37#endif
 38
 39#ifndef _ASSET_FIELD_TYPES_H_
 40#include "assets/assetFieldTypes.h"
 41#endif
 42
 43#ifndef _GFXDEVICE_H_
 44#include "gfx/gfxDevice.h"
 45#endif
 46
 47#ifndef _GUI_INSPECTOR_TYPES_H_
 48#include "gui/editor/guiInspectorTypes.h"
 49#endif
 50
 51//#include "terrain/terrData.h"
 52#include "assets/assetPtr.h"
 53#include "terrain/terrFile.h"
 54
 55class TerrainMaterialAsset;
 56
 57//-----------------------------------------------------------------------------
 58class TerrainAsset : public AssetBase
 59{
 60   typedef AssetBase Parent;
 61
 62   StringTableEntry        mTerrainFileName;
 63   StringTableEntry        mTerrainFilePath;
 64   Resource<TerrainFile>   mTerrainFile;
 65
 66   //Material assets we're dependent on and use
 67   Vector<StringTableEntry> mTerrMaterialAssetIds;
 68   Vector<AssetPtr<TerrainMaterialAsset>> mTerrMaterialAssets;
 69
 70public:
 71   TerrainAsset();
 72   virtual ~TerrainAsset();
 73
 74   /// Engine.
 75   static void initPersistFields();
 76   virtual void copyTo(SimObject* object);
 77
 78   virtual void setDataField(StringTableEntry slotName, const char* array, const char* value);
 79
 80   void                    setTerrainFileName(const char* pTerrainFile);
 81   inline StringTableEntry getTerrainFileName(void) const { return mTerrainFileName; };
 82   inline StringTableEntry getTerrainFilePath(void) const { return mTerrainFilePath; };
 83
 84   inline Resource<TerrainFile> getTerrainResource(void) const { return mTerrainFile; };
 85
 86   bool loadTerrain();
 87
 88   static bool getAssetByFilename(StringTableEntry fileName, AssetPtr<TerrainAsset>* shapeAsset);
 89   static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
 90   static bool getAssetById(StringTableEntry assetId, AssetPtr<TerrainAsset>* shapeAsset);
 91
 92   /// Declare Console Object.
 93   DECLARE_CONOBJECT(TerrainAsset);
 94
 95protected:
 96   virtual void initializeAsset();
 97   virtual void onAssetRefresh(void);
 98
 99   static bool setTerrainFileName(void *obj, const char *index, const char *data) { static_cast<TerrainAsset*>(obj)->setTerrainFileName(data); return false; }
100   static const char* getTerrainFileName(void* obj, const char* data) { return static_cast<TerrainAsset*>(obj)->getTerrainFileName(); }
101};
102
103DefineConsoleType(TypeTerrainAssetPtr, TerrainAsset)
104DefineConsoleType(TypeTerrainAssetId, String)
105
106//-----------------------------------------------------------------------------
107// TypeAssetId GuiInspectorField Class
108//-----------------------------------------------------------------------------
109class GuiInspectorTypeTerrainAssetPtr : public GuiInspectorTypeFileName
110{
111   typedef GuiInspectorTypeFileName Parent;
112public:
113
114   GuiBitmapButtonCtrl* mShapeEdButton;
115
116   DECLARE_CONOBJECT(GuiInspectorTypeTerrainAssetPtr);
117   static void consoleInit();
118
119   virtual GuiControl* constructEditControl();
120   virtual bool updateRects();
121};
122
123class GuiInspectorTypeTerrainAssetId : public GuiInspectorTypeTerrainAssetPtr
124{
125   typedef GuiInspectorTypeTerrainAssetPtr Parent;
126public:
127
128   DECLARE_CONOBJECT(GuiInspectorTypeTerrainAssetId);
129   static void consoleInit();
130};
131
132#endif // _ASSET_BASE_H_
133
134