My Project
Terrain.h
1 #pragma once
2 #include "IAttributeFields.h"
3 #include "TerrainBuffer.h"
4 #define INVALID_TEXTURE_ID (1000000)
5 
263 namespace ParaTerrain
264 {
265  class ReloadMaskRequest;
266  class CRegionLayer;
267  class CTerrainRegions;
268 
271 
273  enum DIRECTION
274  {
276  DIR_CENTER = 0,
278  DIR_NORTH = 1,
280  DIR_NORTHEAST = 2,
282  DIR_EAST = 3,
284  DIR_SOUTHEAST = 4,
286  DIR_SOUTH = 5,
288  DIR_SOUTHWEST = 6,
290  DIR_WEST = 7,
292  DIR_NORTHWEST = 8,
294  DIR_INVALID = 9
295  };
296 
298  enum TERRAIN_MODIFIED_BITS
299  {
300  MODIFIED_NONE = 0,
301 
302  // detailed terrain texture(with mask) has been modified.
303  MODIFIED_TEXTURE = 0x1,
304  // height map has modified
305  MODIFIED_HEIGHTMAP = 0x1<<1,
306  // configuration such as base texture, common file, holes, etc has been modified.
307  MODIFIED_CONFIGURATION = 0x1<<2,
308  // holes have been changed. this should mean the same thing as MODIFIED_CONFIGURATION
309  MODIFIED_HOLES = 0x1<<3,
310  // if static objects have been modified, so that we will need to update the on load script
311  MODIFIED_ON_LOAD_SCRIPT = 0x1<<4,
312 
313  MODIFIED_ALL = 0xffff
314  };
315 
316  class TerrainBlock;
317  class Terrain;
318  class Texture;
319  class TextureFactory;
320  class TextureSet;
321  class TextureCell;
322  class TriangleStrip;
323  class TriangleFan;
324  class TextureGenerator;
325  class DetailTexture;
326 }
327 
328 #include "TerrainCommon.h"
329 #include "TerrainException.h"
330 #include "Settings.h"
331 #include "Texture.h"
332 #include "ShapeAABB.h"
333 #include "TextureFactory.h"
334 #include "TextureCell.h"
335 #include "TextureSet.h"
336 #include "TextureGenerator.h"
337 #include "TerrainBlock.h"
338 #include "TriangleStrip.h"
339 #include "TriangleFan.h"
340 #include "TerrainLattice.h"
341 #include "TerrainVertex.h"
342 #include "DetailTextureFactory.h"
343 #include "IAttributeFields.h"
344 #include <vector>
345 #include <set>
346 
347 namespace ParaEngine
348 {
349  struct TextureEntity;
350  class CShapeAABB;
351  class CShapeFrustum;
352  struct AssetFileEntry;
353 }
354 namespace ParaTerrain
355 {
356  using namespace ParaEngine;
357  class Terrain;
358  class CDetailTextureFactory;
359 
361  class CTerrainMaskFileCallbackData : public boost::signals2::trackable
362  {
363  public:
364  CTerrainMaskFileCallbackData(Terrain *pTerrain) : m_pTerrain(pTerrain){}
365 
366  Terrain * m_pTerrain;
367 
368  void OnMaskFileDownloaded(int nResult, AssetFileEntry* pAssetFileEntry);
369  // void operator()(int nResult, AssetFileEntry* pAssetFileEntry);
370  };
371 
372  enum TerrainInfoType
373  {
374  tit_none = 0,
375  tit_walkRegion = 1,
376  tit_walkWaypoint = 2,
377  };
378 
379 
386  class Terrain : public IAttributeFields
387  {
388  public:
390  Terrain();
392 
423  Terrain(const float *pElevations, int elevWidth, int elevHeight, const uint8 * pTextureImage, int textureWidth, int textureHeight, const uint8 * pDetailTextureImage, int detailWidth, int detailHeight, float vertexSpacing, float elevationScale, int maxNumTriangles, float offsetX = 0.0f, float offsetY = 0.0f);
424 
439  Terrain(int widthVertices, int heightVertices, float vertexSpacing, int maxNumTriangles);
448  Terrain(int maxNumTriangles, float offsetX, float offsetY);
449  ~Terrain();
450  public:
452  // implementation of IAttributeFields
453 
455  virtual int GetAttributeClassID(){return ATTRIBUTE_CLASSID_CTerrainObject;}
457  virtual const char* GetAttributeClassName(){static const char name[] = "CTerrain"; return name;}
459  virtual const char* GetAttributeClassDescription(){static const char desc[] = ""; return desc;}
461  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
468  virtual bool InvokeEditor(int nFieldID, const string& sParameters);
469 
470  ATTRIBUTE_METHOD1(Terrain, IsModified_s, bool*) {*p1 = cls->IsModified(); return S_OK;}
471  ATTRIBUTE_METHOD1(Terrain, SetModified_s, bool) {cls->SetModified(p1); return S_OK;}
472 
473  ATTRIBUTE_METHOD1(Terrain, IsEmpty_s, bool*) {*p1 = cls->IsEmpty(); return S_OK;}
474 
475  ATTRIBUTE_METHOD1(Terrain, GetSize_s, float*) {*p1 = cls->GetWidth(); return S_OK;}
476 
477  ATTRIBUTE_METHOD1(Terrain, GetOnloadScript_s, const char**) {*p1 = cls->GetOnloadScript().c_str(); return S_OK;}
478 
479  ATTRIBUTE_METHOD1(Terrain, GetTerrainElevFile_s, const char**) {*p1 = cls->GetTerrainElevFile().c_str(); return S_OK;}
480 
481  ATTRIBUTE_METHOD1(Terrain, GetTerrainConfigFile_s, const char**) {*p1 = cls->GetTerrainConfigFile().c_str(); return S_OK;}
482 
483  ATTRIBUTE_METHOD1(Terrain, GetTerrainBaseTextureFile_s, const char**) {*p1 = cls->GetTerrainBaseTextureFile().c_str(); return S_OK;}
484  ATTRIBUTE_METHOD1(Terrain, SetTerrainBaseTextureFile_s, const char*) {cls->SetTerrainBaseTextureFile(p1); return S_OK;}
485 
486  ATTRIBUTE_METHOD1(Terrain, GetTerrainCommonTextureFile_s, const char**) {*p1 = cls->GetTerrainCommonTextureFile().c_str(); return S_OK;}
487  ATTRIBUTE_METHOD1(Terrain, SetTerrainCommonTextureFile_s, const char*) {cls->SetTerrainCommonTextureFile(p1); return S_OK;}
488 
489  ATTRIBUTE_METHOD1(Terrain, GetNumOfRegions_s, int*) {*p1 = cls->GetNumOfRegions(); return S_OK;}
490 
491  ATTRIBUTE_METHOD1(Terrain, GetCurrentRegionIndex_s, int*) {*p1 = cls->GetCurrentRegionIndex(); return S_OK;}
492  ATTRIBUTE_METHOD1(Terrain, SetCurrentRegionIndex_s, int) {cls->SetCurrentRegionIndex(p1); return S_OK;}
493 
494  ATTRIBUTE_METHOD1(Terrain, GetCurrentRegionName_s, const char**) {*p1 = cls->GetCurrentRegionName().c_str(); return S_OK;}
495  ATTRIBUTE_METHOD1(Terrain, SetCurrentRegionName_s, const char*) {cls->SetCurrentRegionName(p1); return S_OK;}
496 
497  ATTRIBUTE_METHOD1(Terrain, GetCurrentRegionFilepath_s, const char**) {*p1 = cls->GetCurrentRegionFilepath().c_str(); return S_OK;}
498  ATTRIBUTE_METHOD1(Terrain, SetCurrentRegionFilepath_s, const char*) {cls->SetCurrentRegionFilepath(p1); return S_OK;}
499 
503  void Cleanup();
504 
506  bool IsModified();
509  bool IsModified(DWORD dwModifiedBits);
513  void SetModified(bool bIsModified, DWORD dwModifiedBits);
514 
516  bool IsEmpty();
517 
519  void SetModified(bool bIsModified);
520 
522  void InitDeviceObjects();
524  void DeleteDeviceObjects();
526  void InvalidateDeviceObjects();
527 
535  int Tessellate();
543  void RepairCracks();
549  void RebuildRenderBuffer();
556  void Render();
557 
558 
560  string GetRenderReport();
561 
563 
569  void SetDetailThreshold(float threshold);
571  float GetDetailThreshold() const;
573 
578  void SetMaximumVisibleBlockSize(int stride);
579  int GetMaximumVisibleBlockSize();
581  int GetWidthVertices() const;
583  int GetHeightVertices() const;
585  float GetWidth() const;
587  float GetHeight() const;
589  float GetVertexSpacing() const;
594  float GetElevation(float x, float y) const;
599  float GetElevationW(float x, float y) const;
600 
605  DWORD GetRegionValue(const string& sLayerName, float x, float y);
606 
611  DWORD GetRegionValueW(const string& sLayerName, float x, float y);
612 
613 
616  float GetElevation(int index) const;
623  void GetNormal(float x, float y, float &normalX, float &normalY, float &normalZ) const;
630  void GetNormalW(float x, float y, float &normalX, float &normalY, float &normalZ) const;
632  float GetMaxElevation() const;
636  int GetVertex(float x, float y) const;
640  int GetVertexW(float x, float y) const;
643  float GetVertexElevation(int index) const;
648  void SetVertexElevation(int index, float newElevation, bool recalculate_geometry = true);
653  void SetVertexElevation(float x, float y, float newElevation);
654 
661  void SetHole(float x, float y, bool bIsHold);
662 
669  void SetHoleLocal(float x, float y, bool bIsHold);
670 
672  void UpdateHoles();
673 
677  void SetHoleScale(int nHoleScale);
678 
684  bool IsHole(float x, float y);
690  bool IsHoleW(float x, float y);
691 
695  void CreateHoleMap(BYTE* pHoleData=NULL, int nLength = 0);
696 
700  void RecalcGeometry(int index1, int index2);
702  void RecalcGeometry();
706  void RecalcNormal(float x, float y);
709  void RecalcNormal(int vertexIndex);
720  void SetAllElevations(const float *pElevations, int elevWidth, int elevHeight, float fTerrainSize, float elevationScale = 1.0f);
722  int GetNumberOfVertices() const;
724  float GetTextureTileWidth() const;
726  float GetTextureTileHeight() const;
728  int GetNumberOfTextureTilesWidth() const;
730  int GetNumberOfTextureTilesHeight() const;
732 
743  bool SetTexture(const uint8 * pTextureImage, int width, int height);
750  bool SetBaseTexture(const string& filename, int numTextureCellsX=8, int numTextureCellsY=8);
753 
764  bool SetCommonTexture(const uint8 * pImage, int width, int height);
767 
774  void SetCommonTexture(const char* fileName);
775 
781  void SetCommonTexture(Texture * pTexture);
783  Texture *GetCommonTexture() const;
784 
791  int ModelViewMatrixChanged();
792 
801  int CuboidInFrustum(const CShapeBox & cuboid) const;
806  bool CuboidInFogRadius(const CShapeBox & cuboid) const;
807 
809  Plane::Side GetCuboidFogSide(const CShapeBox & cuboid) const;
810 
812  void BoxToRenderCoordinate(CShapeBox & cuboid) const;
813 
815  float GetBoxToEyeMatrics(const CShapeBox & cuboid) const;
816 
831  float IntersectRayW(float startX, float startY, float startZ, float dirX, float dirY, float dirZ, float &intersectX, float &intersectY, float &intersectZ, float fMaxDistance = INFINITY);
832 
847  float IntersectRay(float startX, float startY, float startZ, float dirX, float dirY, float dirZ, float &intersectX, float &intersectY, float &intersectZ, float fMaxDistance = INFINITY);
865  float IntersectRay(float startX, float startY, float startZ, float dirX, float dirY, float dirZ, float &intersectX, float &intersectY, float &intersectZ, int &textureCellX, int &textureCellY, float &texU, float &texV, float fMaxDistance = INFINITY);
867 
878  bool Pick(int screenX, int screenY, float &pickedX, float &pickedY, float &pickedZ) const;
880 
895  bool Pick(int screenX, int screenY, float &pickedX, float &pickedY, float &pickedZ, int &textureCellX, int &textureCellY, float &texU, float &texV) const;
903  void GetTextureCoordinates(float x, float y, int &textureCellX, int &textureCellY, float &texU, float &texV) const;
905 
914  void Paint(ParaEngine::TextureEntity* detailTexture, float brushRadius, float brushIntensity, float maxIntensity, bool erase, float x, float y);
915  void Paint(int detailTextureIndex, float brushRadius, float brushIntensity, float maxIntensity, bool erase, float x, float y);
917  bool IsMultiTextureSupported() const;
921  void SetLatticePosition(int x, int y);
925  void GetLatticePosition(int &x, int &y);
929  void SetTextureFactory(TextureFactory * pFactory);
932  TextureCell * GetTextureCell(int index);
936  TextureCell * GetTextureCellW(float x, float y);
940  TextureCell * GetTextureCell(int textureCellX, int textureCellY);
944  void Write(char *szFilename);
948  void Read(char *szFilename);
950  TextureSet *GetTextureSet();
954  void SetTextureSet(TextureSet * pTextureSet);
959  void SetTextureCell(int index, TextureCell * pCell);
962  void WriteRawTextures(const char *szTerrainName);
965  void WriteRawElevations(const char *szFilename);
967 
982  void AllocateTextureCells(int numTextureCellsX, int numTextureCellsY);
984  void GenerateTexture(int widthTexels, int heightTexels, const char *szGeneratorName);
986  void GenerateTexture(int widthTexels, int heightTexels, TextureGenerator * pGenerator);
988  static void RegisterTextureGenerator(std::string name, TextureGenerator * pGenerator);
990  static void RegisterDefaultGenerators();
992  int GetBaseTextureWidth();
994  int GetBaseTextureHeight();
995 
997 
999  inline void ref() const
1000  {
1001  ++m_refCount;
1002  }
1004 
1008  inline void unref() const
1009  {
1010  --m_refCount;
1011  if (m_refCount <= 0)
1012  delete this;
1013  }
1015  uint8 *GetMaskBits(int textureCellX, int textureCellY, int detailIndex, int &maskWidth, int &maskHeight);
1017  void ReloadMask(int textureCellX, int textureCellY, int detailIndex);
1018 
1023  void LoadMaskFromDisk(bool bForceReload = false);
1024 
1032  int NormalizeMask(int textureCellX, int textureCellY, int detailIndex, bool bReload=true);
1033 
1036  void SetOffset(float x, float y);
1038 
1040  float GetOffsetX() const;
1042 
1044  float GetOffsetY() const;
1045 
1046  void DigCrater(float centerX, float centerY, float radius, int textureId = -1);
1047 
1048  void GetVertices(float centerX, float centerY, float radius, std::vector < TerrainVertex > &vertices);
1049 
1051  const string& GetOnloadScript();
1052 
1054  const string& GetTerrainElevFile();
1055 
1057  const string& GetTerrainConfigFile() {return m_sConfigFile;};
1058 
1060  const string& GetTerrainBaseTextureFile(){return m_sBaseTextureFile; };
1061  void SetTerrainBaseTextureFile(const string& str);
1062 
1064  const string& GetTerrainCommonTextureFile(){return m_sCommonTextureFile; };
1065  void SetTerrainCommonTextureFile(const string& str);
1066 
1067 
1069  CShapeBox GetBoundingBoxW();
1070 
1080  void GetBoundingBoxes(vector<CShapeAABB>& boxes, const Matrix4* modelView, const CShapeFrustum& frustum, int nMaxBoxesNum=1024, int nSmallestBoxStride=4);
1081 
1083  DetailTexture* GetDefaultBaseLayerMask();
1084 
1086  CTerrainRegions* GetRegions();
1088  CTerrainRegions* CreateGetRegions();
1089 
1091  int GetNumOfRegions();
1092 
1095  void SetCurrentRegionIndex(int nRegion);
1099  int GetCurrentRegionIndex();
1100 
1104  void SetCurrentRegionName(const string& name);
1105 
1107  const string& GetCurrentRegionName();
1108 
1110  void SetCurrentRegionFilepath(const string& filename);
1111 
1113  const string& GetCurrentRegionFilepath();
1114 
1115  private:
1116 
1117  // the terrain configuration file.
1118  string m_sConfigFile;
1119  // the base terrain texture file.
1120  string m_sBaseTextureFile;
1121  // the common terrain texture file.
1122  string m_sCommonTextureFile;
1123  // the on load script file name of this terrain
1124  string m_sOnLoadScript;
1125  // elevation file
1126  string m_sElevFile;
1127 
1129  DetailTexture* m_pDefaultBaseLayerMask;
1131  CShapeBox m_BoundingBox;
1132  //void RenderTextureGroup(int i);
1133  int m_WidthVertices;
1134  int m_HeightVertices;
1136  float m_fHighResTextureRadius;
1137  float m_DetailThreshold;
1138  float m_VertexSpacing;
1140  TerrainBlock *m_pRootBlock;
1141  byte* m_pVertexStatus;
1143  CTerrainRegions* m_pRegions;
1145  int m_nNumOfHoleVertices;
1149  bool* m_pHolemap;
1153  short m_nHoleScale;
1155  int m_NumberOfVertices;
1157  Vector3 *m_pVertices;
1159  std::vector < TextureCell * >m_TextureCells;
1160  float m_TextureTileWidth, m_TextureTileHeight;
1161  uint32 m_NumberOfTextureTilesWidth;
1162  uint32 m_NumberOfTextureTilesHeight;
1163  int m_TileSize;
1164  uint8 **m_pTiles;
1165  uint32 m_NumberOfTextureTiles;
1166  Texture *m_pCommonTexture;
1167  float m_FogColorRed, m_FogColorGreen, m_FogColorBlue, m_FogColorAlpha;
1168  int m_MaximumVisibleBlockSize;
1169  vector<TriangleStrip> m_pTriangleStrips;
1170  vector<TriangleFan> m_pTriangleFans;
1171  uint32 m_CountStrips, m_CountFans;
1172  bool m_bMultiTextureSupported;
1173  uint32 m_MaxNumberOfPrimitives;
1174  float m_MaxElevation;
1175  float m_OffsetX, m_OffsetY;
1176  int m_LatticePositionX, m_LatticePositionY;
1177  float m_fTerrainSize;
1178  TextureSet *m_pTextureSet;
1179  float *m_pTextureMain;
1180  float *m_pTextureDetail;
1181  Vector3 *m_pNormals;
1182  mutable int m_refCount;
1183  CTerrainMaskFileCallbackData* m_pMaskFileCallbackData;
1184 
1185  static std::map < std::string, TextureGenerator * >m_TextureGenerators;
1186  int m_BaseTextureWidth, m_BaseTextureHeight;
1187  std::map < std::string, ReloadMaskRequest * >m_ReloadMaskRequests;
1189  float m_fLowestVisibleHeight;
1190  DWORD m_dwModified;
1191  static float m_DetailTextureRepeats;
1192  // whether to draw terrain in the fog in the distance
1193  bool m_bFogEnabled;
1194  bool m_bMaskFileInited;
1195 
1196 
1198  TerrainBuffer m_TerrainBuffer;
1200  Vector3 m_vEye;
1203  Vector3 m_vRenderOffset;
1205  Vector3 m_vRenderOffset_internal;
1206 
1209  inline void SetRenderOffset(const Vector3& vOffset)
1210  {
1211  m_vRenderOffset = vOffset;
1212  m_vRenderOffset_internal.x = vOffset.x;
1213  m_vRenderOffset_internal.y = vOffset.z;
1214  m_vRenderOffset_internal.z = vOffset.y;
1215  }
1218  void SetEyePosition(const Vector3& vEye);
1219 
1220  void Init(int maxNumPrims, float offX, float offY);
1221  void Init(const uint8 * pTextureImage, int textureWidth, int textureHeight, const uint8 * pDetailTextureImage, int detailWidth, int detailHeight, float offsetX = 0.0f, float offsetY = 0.0f);
1222  void UpdateNeighbor(Terrain * pTerrain, DIRECTION direction);
1223 
1224  inline void SetVertexStatus(int index, byte status){if(m_pVertexStatus != NULL) m_pVertexStatus[index] = status;};
1225  inline byte GetVertexStatus(int index){return m_pVertexStatus[index];};
1226 
1227  void BuildBlocks();
1228  void ChopTexture(const uint8 * pImage, int width, int height, int tileSize);
1229  void PreloadTextures();
1230  void BuildVertices(int widthVertices, int heightVertices, float vertexSpacing);
1236  inline void GetRenderVertex(int nIndex, Vector3& v){
1237  Vector3& vec = m_pVertices[nIndex];
1238  v.x = vec.x+m_vRenderOffset.x;
1239  v.y = vec.z+m_vRenderOffset.y;
1240  v.z = vec.y+m_vRenderOffset.z;
1241  }
1246  void GetRenderNorm(int nIndex, Vector3& v)
1247  {
1248  Vector3& vec= m_pNormals[nIndex];
1249  v.x = vec.x;
1250  v.y = vec.z;
1251  v.z = vec.y;
1252  }
1253 
1254  inline TriangleStrip* GetTriStrip(int nIndex){return &(m_pTriangleStrips[nIndex]);}
1255  inline TriangleStrip* GetSafeTriStrip(int nIndex){
1256  if(nIndex< (int)m_pTriangleStrips.size())
1257  return &(m_pTriangleStrips[nIndex]);
1258  else{
1259  m_pTriangleStrips.resize(nIndex+100);
1260  return &(m_pTriangleStrips[nIndex]);
1261  }
1262  }
1263  inline TriangleFan* GetTriFan(int nIndex){return &(m_pTriangleFans[nIndex]);}
1264  inline TriangleFan* GetSafeTriFan(int nIndex){
1265  if(nIndex< (int)m_pTriangleFans.size())
1266  return &(m_pTriangleFans[nIndex]);
1267  else{
1268  m_pTriangleFans.resize(nIndex+100);
1269  return &(m_pTriangleFans[nIndex]);
1270  }
1271  }
1272  public:
1273 
1279  int GetTextureIDbyPoint(float x, float y, float& tileX, float& tileY);
1280 
1282  //void LoadDetailedTextures(const char * filename);
1284  inline void GetLowResTexCord(int nIndex, float& u, float& v){
1285  const Vector2& uv = s_LowResTexCords[nIndex];
1286  u = uv.x;
1287  v = uv.y;
1288  }
1290  inline void GetHighResTexCord(int nIndex, float& u, float& v){
1291  const Vector2& uv = s_HighResTexCords[nIndex];
1292  u = uv.x;
1293  v = uv.y;
1294  }
1296  inline void GetTexCord(int nIndex, float& lowU, float& lowV, float& detailU, float& detailV){
1297  const Vector2& uv = s_LowResTexCords[nIndex];
1298  lowU = uv.x;
1299  lowV = uv.y;
1300  const Vector2& uv2 = s_HighResTexCords[nIndex];
1301  detailU = uv2.x;
1302  detailV = uv2.y;
1303  }
1304 
1309 
1311  static void StaticInitUV(int nWidthVertices, int nNumberOfTextureTiles, int nDetailTextureRepeats);
1312 
1315  {
1318  {
1319  SAFE_DELETE_ARRAY(Terrain::s_LowResTexCords);
1320  SAFE_DELETE_ARRAY(Terrain::s_HighResTexCords);
1321  }
1322  };
1323 
1325  void SetHighResTextureRadius(float radius);
1327  float GetHighResTextureRadius();
1329  void SetDetailTextureRepeats(float repeats);
1331  float GetDetailTextureRepeats();
1332 
1334  void SetLowestVisibleHeight(float fHeight);
1336  float GetLowestVisibleHeight();
1342  void GetMaskFile(string& sMaskFile, const string& sConfigFile);
1343 
1347  bool SaveConfig(const string& filePath);
1348 
1352  bool SaveElevation(const string& filePath);
1353 
1357  bool SaveDetailTexture(const string& filePath);
1358 
1366  bool LoadFromConfigFile(const char* sFileName, float fSize=0, const char* relativePath=NULL);
1367 
1373  void OnLoad();
1374 
1385  bool SaveToFile(const char* filename=NULL);
1386 
1388  bool ReadMaskFile(CParaFile& fileMask);
1389 
1391  void ResizeTextureMaskWidth(int nWidth);
1392 
1395  protected:
1401  bool GenerateTerrainNormal(bool bForceRegenerate=false);
1402 
1403  friend class Triangle;
1404  friend class TriangleStrip;
1405  friend class TerrainBlock;
1406  friend class TriangleFan;
1407  friend class TerrainLattice;
1408  friend class TerrainBuffer;
1409  friend class Loader;
1410  friend class TextureSet;
1411 
1412 
1413  private:
1414  GeoMipmapIndicesGroup* m_pGeoMipmapIndicesGroup;
1415  TerrainBlock* m_pBlocks;
1416  private:
1417  ParaIndexBuffer m_pIndexBuffer;
1418  ParaVertexBuffer m_pCollisionBuffer;
1419  ParaVertexBuffer m_pEditorMeshVB;
1420  public:
1421  void SetSharedIB(ParaIndexBuffer ib){ m_pIndexBuffer = ib; }
1422  void SwitchLodStyle(bool useGeoMipmap, ParaIndexBuffer pSharedIndices, GeoMipmapIndicesGroup* geoMipmapIndicesGroup);
1423 
1424  public:
1425  bool m_useGeoMipmap;
1426  void SetSharedIndexInfoGroup(GeoMipmapIndicesGroup* geoMipmapIndicesGroup){m_pGeoMipmapIndicesGroup = geoMipmapIndicesGroup;}
1427  void BuildGeoMipmapBuffer();
1428  void RenderGeoMipmap();
1429  void TessellateGeoMipmap();
1430  void BuildGeoMipmapBlocks();
1431  void SetBlockLod(int indexX,int indexY,int level,GeoMipmapChunkType chunkType);
1432 
1433  bool IsWalkable(float x,float y) const;
1434  bool IsWalkableW(float x,float y) const;
1435 
1436  //terrain editor code --clayman
1437  private:
1438  bool m_isEditorMode;
1439  bool m_enableTerrainCollision;
1441  bool m_bChopBaseTexture;
1442  string m_terrInfoFile;
1443 
1444 
1445 
1446  uint32* m_pTerrainInfoData;
1447 
1448  void BuildHelperMeshBuffer();
1449  void SaveInfoData(const string& filePath);
1450  void CreateTerrainInfoData();
1451 
1452  int m_visibleEditorMeshFlag;
1453  uint32 m_visibleDataMask;
1454  uint8 m_visibleDataBitOffset;
1455 
1456  public:
1457  void SetTerrainInfoData(const uint32* pInfoData,int width);
1458  void SetVertexInfo(int idx,uint32 data,uint32 bitMask,uint32 bitOffset);
1459  uint32 GetVertexInfo(int idx,uint32 bitMask,uint8 bitOffset);
1460  void RefreshTerrainInfo();
1461  bool IsWalkable(float x, float y,Vector3& oNormal) const;
1462  void SetVisibleDataMask(uint32 mask,uint8 bitOffset);
1463  void SetEditorMode(bool enable);
1464  };
1465 
1466 
1468  {
1469  public:
1470  ReloadMaskRequest(int textureCellX, int textureCellY, int detailIndex);
1471  ~ReloadMaskRequest();
1472  int m_TextureCellX, m_TextureCellY, m_DetailIndex;
1473  };
1474 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
this is a dummy object that to ensure static objects are destroyed properly
Definition: Terrain.h:1314
Definition: SceneObject.h:15
Definition: TerrainGeoMipmapIndices.h:36
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
void unref() const
Decrement the reference count by one, indicating that a pointer to this object is referencing it...
Definition: Terrain.h:1008
light-weighted file record header in memory.
Definition: AssetManifest.h:10
The Loader is a Singleton object that provides access to ElevationLoaders and TextureLoaders.
Definition: Loader.h:14
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: Terrain.h:455
A TextureSet is a pool of Texture objects that are used by a Terrain to do detail texture rendering...
Definition: TextureSet.h:29
ParaTerrain::CDetailTextureFactory * m_pDetailedTextureFactory
for high-res texture of terrain surfaces
Definition: Terrain.h:1394
Definition: mdx.h:48
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: Terrain.h:459
this class implements a texture factory class for detailed tile based terrain surface texture...
Definition: DetailTextureFactory.h:27
cross platform vertex/index buffer.
Definition: ParaVertexBuffer.h:18
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
void GetLowResTexCord(int nIndex, float &u, float &v)
load detailed (high-res) textures, which is usually a large collection of files
Definition: Terrain.h:1284
Definition: mdx.h:14
terrain mask file callback data
Definition: Terrain.h:361
An abstract factory for managing terrain textures.
Definition: TextureFactory.h:25
Side
The "positive side" of the plane is the half space to which the plane normal points.
Definition: ParaPlane.h:32
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
void GetTexCord(int nIndex, float &lowU, float &lowV, float &detailU, float &detailV)
get both low resolution and detailed texture coordinates
Definition: Terrain.h:1296
Definition: Terrain.h:1467
Represents a square region on a Terrain surface that is textured.
Definition: TextureCell.h:26
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object&#39;s name
Definition: Terrain.h:457
in OpenGL, there is no different between vertex and index buffer.
Definition: ParaVertexBuffer.h:78
it contains all the necessary dynamic information to render the terrain for the current frame...
Definition: TerrainBuffer.h:31
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
it presents a real or virtual file in ParaEngine.
Definition: ParaFile.h:31
void ref() const
Increment the reference count by one, indicating that this object has another pointer which is refere...
Definition: Terrain.h:999
A DetailTexture is a "layer" that can be painted onto to put texture "splats" on a terrain surface...
Definition: DetailTexture.h:23
const string & GetTerrainCommonTextureFile()
get the terrain common texture file
Definition: Terrain.h:1064
Definition: TriangleFan.h:8
it represents the quad tree node of LOD terrain data
Definition: TerrainBlock.h:22
the editable terrain regions associated with a terrain tile.
Definition: TerrainRegions.h:57
This class represents a single, contiguous chunk of terrain and is the primary public interface to De...
Definition: Terrain.h:386
Definition: TriangleStrip.h:9
void GetHighResTexCord(int nIndex, float &u, float &v)
Get the high-res texture coordinate at a specified vertex index.
Definition: Terrain.h:1290
const string & GetTerrainConfigFile()
get the terrain elevation file
Definition: Terrain.h:1057
static Vector2 * s_LowResTexCords
array of low resolution texture coordinates.
Definition: Terrain.h:1306
const string & GetTerrainBaseTextureFile()
get the terrain base texture file
Definition: Terrain.h:1060
Manages a network of Terrain objects arranged in a grid pattern to model extremely large worlds that ...
Definition: TerrainLattice.h:57
a general view frustum class.
Definition: ShapeFrustum.h:9
static Vector2 * s_HighResTexCords
array of high resolution texture coordinates.
Definition: Terrain.h:1308
Definition: TextureGenerator.h:7
a min max box.
Definition: ShapeAABB.h:190