OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreTerrain.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __Ogre_Terrain_H__
30 #define __Ogre_Terrain_H__
31 
33 #include "OgreCommon.h"
34 #include "OgreVector3.h"
35 #include "OgreAxisAlignedBox.h"
36 #include "OgreSceneManager.h"
37 #include "OgreFrameListener.h"
40 #include "OgreWorkQueue.h"
41 #include "OgreTerrainLodManager.h"
42 
43 namespace Ogre
44 {
45  class NameGenerator;
46 
267  {
268  public:
269  friend class TerrainLodManager;
270 
274  Terrain(SceneManager* sm);
275  virtual ~Terrain();
276 
277  static const uint32 TERRAIN_CHUNK_ID;
281 
294 
295  static const size_t LOD_MORPH_CUSTOM_PARAM;
296 
298 
302  {
307 
309  : worldSize(100) {}
310  };
312 
315  {
317  ALIGN_X_Z = 0,
319  ALIGN_X_Y = 1,
321  ALIGN_Y_Z = 2
322  };
323 
327  struct ImportData
328  {
350 
356 
359 
366 
371  float* inputFloat;
372 
377 
386 
391 
402 
404  : terrainAlign(ALIGN_X_Z)
405  , terrainSize(1025)
406  , maxBatchSize(65)
407  , minBatchSize(17)
408  , pos(Vector3::ZERO)
409  , worldSize(1000)
410  , inputImage(0)
411  , inputFloat(0)
412  , constantHeight(0)
413  , deleteInputData(false)
414  , inputScale(1.0)
415  , inputBias(0.0)
416  {
417 
418  }
419 
420  ImportData(const ImportData& rhs)
421  : terrainAlign(ALIGN_X_Z)
422  , terrainSize(1025)
423  , maxBatchSize(65)
424  , minBatchSize(17)
425  , pos(Vector3::ZERO)
426  , worldSize(1000)
427  , inputImage(0)
428  , inputFloat(0)
429  , constantHeight(0)
430  , deleteInputData(false)
431  , inputScale(1.0)
432  , inputBias(0.0)
433  {
434  *this = rhs;
435  }
436 
438  {
439  // basic copy
440  terrainAlign = rhs.terrainAlign;
441  terrainSize = rhs.terrainSize;
442  maxBatchSize = rhs.maxBatchSize;
443  minBatchSize = rhs.minBatchSize;
444  pos = rhs.pos;
445  worldSize = rhs.worldSize;
446  constantHeight = rhs.constantHeight;
447  deleteInputData = rhs.deleteInputData;
448  inputScale = rhs.inputScale;
449  inputBias = rhs.inputBias;
450  layerDeclaration = rhs.layerDeclaration;
451  layerList = rhs.layerList;
452 
453  // By-value copies in ownership cases
454  if (rhs.deleteInputData)
455  {
456  if (rhs.inputImage)
457  inputImage = OGRE_NEW Image(*rhs.inputImage);
458  else
459  inputImage = 0;
460 
461  if (rhs.inputFloat)
462  {
463  inputFloat = OGRE_ALLOC_T(float, terrainSize*terrainSize, MEMCATEGORY_GEOMETRY);
464  memcpy(inputFloat, rhs.inputFloat, sizeof(float) * terrainSize*terrainSize);
465  }
466  else
467  inputFloat = 0;
468  }
469  else
470  {
471  // re-use pointers
472  inputImage = rhs.inputImage;
473  inputFloat = rhs.inputFloat;
474  }
475  return *this;
476  }
477 
479  void destroy()
480  {
481  if (deleteInputData)
482  {
483  OGRE_DELETE inputImage;
484  OGRE_FREE(inputFloat, MEMCATEGORY_GEOMETRY);
485  inputImage = 0;
486  inputFloat = 0;
487  }
488 
489  }
490 
492  {
493  destroy();
494  }
495 
496  };
497 
500  {
501  NEIGHBOUR_EAST = 0,
502  NEIGHBOUR_NORTHEAST = 1,
503  NEIGHBOUR_NORTH = 2,
504  NEIGHBOUR_NORTHWEST = 3,
505  NEIGHBOUR_WEST = 4,
506  NEIGHBOUR_SOUTHWEST = 5,
507  NEIGHBOUR_SOUTH = 6,
508  NEIGHBOUR_SOUTHEAST = 7,
509 
510  NEIGHBOUR_COUNT = 8
511  };
512 
513  SceneManager* getSceneManager() const { return mSceneMgr; }
514 
516  enum Space
517  {
519  WORLD_SPACE = 0,
521  LOCAL_SPACE = 1,
525  TERRAIN_SPACE = 2,
529  POINT_SPACE = 3
530  };
531 
537  {
538  public:
540  virtual ~GpuBufferAllocator() {}
541 
547  virtual void allocateVertexBuffers(Terrain* forTerrain, size_t numVertices, HardwareVertexBufferSharedPtr& destPos, HardwareVertexBufferSharedPtr& destDelta) = 0;
550  virtual void freeVertexBuffers(const HardwareVertexBufferSharedPtr& posbuf, const HardwareVertexBufferSharedPtr& deltabuf) = 0;
551 
566  virtual HardwareIndexBufferSharedPtr getSharedIndexBuffer(uint16 batchSize,
567  uint16 vdatasize, size_t vertexIncrement, uint16 xoffset, uint16 yoffset, uint16 numSkirtRowsCols,
568  uint16 skirtRowColSkip) = 0;
569 
571  virtual void freeAllBuffers() = 0;
572 
573  };
576  {
577  public:
579  virtual ~DefaultGpuBufferAllocator();
580  void allocateVertexBuffers(Terrain* forTerrain, size_t numVertices, HardwareVertexBufferSharedPtr& destPos, HardwareVertexBufferSharedPtr& destDelta);
581  void freeVertexBuffers(const HardwareVertexBufferSharedPtr& posbuf, const HardwareVertexBufferSharedPtr& deltabuf);
582  HardwareIndexBufferSharedPtr getSharedIndexBuffer(uint16 batchSize,
583  uint16 vdatasize, size_t vertexIncrement, uint16 xoffset, uint16 yoffset, uint16 numSkirtRowsCols,
584  uint16 skirtRowColSkip);
585  void freeAllBuffers();
586 
590  void warmStart(size_t numInstances, uint16 terrainSize, uint16 maxBatchSize,
591  uint16 minBatchSize);
592 
593  protected:
599 
600  uint32 hashIndexBuffer(uint16 batchSize,
601  uint16 vdatasize, size_t vertexIncrement, uint16 xoffset, uint16 yoffset, uint16 numSkirtRowsCols,
602  uint16 skirtRowColSkip);
603  HardwareVertexBufferSharedPtr getVertexBuffer(VBufList& list, size_t vertexSize, size_t numVertices);
604 
605  };
606 
607  virtual bool frameStarted(const FrameEvent& evt);
608 
613  void setGpuBufferAllocator(GpuBufferAllocator* alloc);
614 
616  GpuBufferAllocator* getGpuBufferAllocator();
617 
619  static size_t _getNumIndexesForBatchSize(uint16 batchSize);
631  static void _populateIndexBuffer(uint16* pIndexes, uint16 batchSize,
632  uint16 vdatasize, size_t vertexIncrement, uint16 xoffset, uint16 yoffset, uint16 numSkirtRowsCols,
633  uint16 skirtRowColSkip);
634 
636  static uint16 _calcSkirtVertexIndex(uint16 mainIndex, uint16 vdatasize, bool isCol,
637  uint16 numSkirtRowsCols, uint16 skirtRowColSkip);
638 
645  void convertPosition(Space inSpace, const Vector3& inPos, Space outSpace, Vector3& outPos) const;
652  Vector3 convertPosition(Space inSpace, const Vector3& inPos, Space outSpace) const;
659  void convertDirection(Space inSpace, const Vector3& inDir, Space outSpace, Vector3& outDir) const;
666  Vector3 convertDirection(Space inSpace, const Vector3& inDir, Space outSpace) const;
667 
672  void setResourceGroup(const String& resGroup) { mResourceGroup = resGroup; }
673 
677  const String& getResourceGroup() const { return mResourceGroup; }
678 
681  const String& _getDerivedResourceGroup() const;
682 
691  void save(const String& filename);
697  void save(StreamSerialiser& stream);
698 
705  bool prepare(const String& filename);
712  bool prepare(DataStreamPtr& stream);
719  bool prepare(StreamSerialiser& stream);
720 
726  bool prepare(const ImportData& importData);
727 
733  void load(const String& filename);
734 
740  void load(StreamSerialiser& stream);
741 
748  void load(int lodLevel = 0, bool synchronous = true);
749 
755  bool isLoaded() const { return mIsLoaded; }
756 
761  bool isModified() const { return mModified; }
762 
763 
768  bool isHeightDataModified() const { return mHeightDataModified; }
769 
770 
775  void unload();
776 
781  void unprepare();
782 
783 
793  float* getHeightData() const;
794 
797  float* getHeightData(long x, long y) const;
798 
803  float getHeightAtPoint(long x, long y) const;
804 
811  void setHeightAtPoint(long x, long y, float h);
812 
816  float getHeightAtTerrainPosition(Real x, Real y) const;
817 
823  float getHeightAtWorldPosition(Real x, Real y, Real z) const;
824 
830  float getHeightAtWorldPosition(const Vector3& pos) const;
831 
838  const float* getDeltaData() const;
839 
842  const float* getDeltaData(long x, long y) const;
843 
848  void getPoint(long x, long y, Vector3* outpos) const;
849 
855  void getPointFromSelfOrNeighbour(long x, long y, Vector3* outpos) const;
856 
861  void getPoint(long x, long y, float height, Vector3* outpos) const;
865  void getPointTransform(Matrix4* outXform) const;
870  void getTerrainVector(const Vector3& inVec, Vector3* outVec) const;
875  void getTerrainVectorAlign(const Vector3& inVec, Alignment align, Vector3* outVec) const;
876 
881  void getTerrainVector(Real x, Real y, Real z, Vector3* outVec) const;
886  void getTerrainVectorAlign(Real x, Real y, Real z, Alignment align, Vector3* outVec) const;
887 
892  void getVector(const Vector3& inVec, Vector3* outVec) const;
897  void getVectorAlign(const Vector3& inVec, Alignment align, Vector3* outVec) const;
898 
903  void getVector(Real x, Real y, Real z, Vector3* outVec) const;
908  void getVectorAlign(Real x, Real y, Real z, Alignment align, Vector3* outVec) const;
909 
910 
918  void getPosition(const Vector3& TSpos, Vector3* outWSpos) const;
926  void getPosition(Real x, Real y, Real z, Vector3* outWSpos) const;
927 
934  void getTerrainPosition(const Vector3& WSpos, Vector3* outTSpos) const;
941  void getTerrainPosition(Real x, Real y, Real z, Vector3* outTSpos) const;
948  void getPositionAlign(const Vector3& TSpos, Alignment align, Vector3* outWSpos) const;
955  void getPositionAlign(Real x, Real y, Real z, Alignment align, Vector3* outWSpos) const;
956 
963  void getTerrainPositionAlign(const Vector3& WSpos, Alignment align, Vector3* outTSpos) const;
970  void getTerrainPositionAlign(Real x, Real y, Real z, Alignment align, Vector3* outTSpos) const;
971 
972 
974  Alignment getAlignment() const;
976  uint16 getSize() const;
981  void setSize(uint16 newSize);
983  uint16 getMaxBatchSize() const;
985  uint16 getMinBatchSize() const;
987  Real getWorldSize() const;
991  void setWorldSize(Real newWorldSize);
992 
994  uint8 getLayerCount() const { return static_cast<uint8>(mLayers.size()); }
995 
997  const TerrainLayerDeclaration& getLayerDeclaration() const { return mLayerDecl; }
998 
1005  void addLayer(Real worldSize = 0, const StringVector* textureNames = 0);
1006 
1014  void addLayer(uint8 index, Real worldSize = 0, const StringVector* textureNames = 0);
1015 
1018  void removeLayer(uint8 index);
1019 
1029  void replaceLayer(uint8 index, bool keepBlends, Real worldSize = 0, const StringVector* textureNames = 0);
1030 
1034  uint8 getMaxLayers() const;
1035 
1040  Real getLayerWorldSize(uint8 index) const;
1046  void setLayerWorldSize(uint8 index, Real size);
1047 
1056  Real getLayerUVMultiplier(uint8 index) const;
1057 
1063  const String& getLayerTextureName(uint8 layerIndex, uint8 samplerIndex) const;
1070  void setLayerTextureName(uint8 layerIndex, uint8 samplerIndex, const String& textureName);
1071 
1078  uint16 getLayerBlendMapSize() const { return mLayerBlendMapSize; }
1079 
1085  uint16 getLightmapSize() const { return mLightmapSize; }
1086 
1088  const TexturePtr& getLightmap() const { return mLightmap; }
1089 
1095  uint16 getCompositeMapSize() const { return mCompositeMapSize; }
1096 
1098  const TexturePtr& getCompositeMap() const { return mCompositeMap; }
1099 
1101  const Vector3& getPosition() const { return mPos; }
1103  void setPosition(const Vector3& pos);
1105  SceneNode* _getRootSceneNode() const;
1112  void dirty();
1113 
1122  void dirtyRect(const Rect& rect);
1123 
1129  void _dirtyCompositeMapRect(const Rect& rect);
1130 
1141  void dirtyLightmapRect(const Rect& rect);
1142 
1153  void dirtyLightmap();
1154 
1177  void update(bool synchronous = false);
1178 
1183  void updateGeometry();
1189  void updateGeometryWithoutNotifyNeighbours();
1190 
1191  // Used as a type mask for updateDerivedData
1195  static const uint8 DERIVED_DATA_ALL;
1196 
1208  void updateDerivedData(bool synchronous = false, uint8 typeMask = 0xFF);
1209 
1218  void updateCompositeMap();
1219 
1233  void updateCompositeMapWithDelay(Real delay = 2);
1234 
1235 
1239  Real getSkirtSize() const { return mSkirtSize; }
1240 
1242  uint16 getNumLodLevels() const { return mNumLodLevels; }
1243 
1245  uint16 getNumLodLevelsPerLeaf() const { return mNumLodLevelsPerLeafNode; }
1246 
1254  Rect calculateHeightDeltas(const Rect& rect);
1255 
1263  void finaliseHeightDeltas(const Rect& rect, bool cpuData);
1264 
1270  PixelBox* calculateNormals(const Rect& rect, Rect& outFinalRect);
1271 
1279  void finaliseNormals(const Rect& rect, PixelBox* normalsBox);
1280 
1288  PixelBox* calculateLightmap(const Rect& rect, const Rect& extraTargetRect, Rect& outFinalRect);
1289 
1297  void finaliseLightmap(const Rect& rect, PixelBox* lightmapBox);
1298 
1302  uint16 getResolutionAtLod(uint16 lodLevel) const;
1303 
1315  std::pair<bool, Vector3> rayIntersects(const Ray& ray,
1316  bool cascadeToNeighbours = false, Real distanceLimit = 0); //const;
1317 
1319  const AxisAlignedBox& getAABB() const;
1321  AxisAlignedBox getWorldAABB() const;
1323  Real getMinHeight() const;
1325  Real getMaxHeight() const;
1327  Real getBoundingRadius() const;
1328 
1330  const MaterialPtr& getMaterial() const;
1332  const MaterialPtr& _getMaterial() const { return mMaterial; }
1334  const MaterialPtr& getCompositeMapMaterial() const;
1336  const MaterialPtr& _getCompositeMapMaterial() const { return mCompositeMapMaterial; }
1337 
1339  const String& getMaterialName() const { return mMaterialName; }
1340 
1342  void preFindVisibleObjects(SceneManager* source,
1345  void sceneManagerDestroyed(SceneManager* source);
1346 
1348  uint8 getRenderQueueGroup(void) const { return mRenderQueueGroup; }
1352  void setRenderQueueGroup(uint8 grp) { mRenderQueueGroup = grp; }
1353 
1355  uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
1359  void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
1360 
1362  uint32 getQueryFlags(void) const { return mQueryFlags; }
1366  void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
1367 
1369  void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
1370 
1371  /* As setQueryFlags, except the flags passed as parameters are removed from the existing flags on this object. */
1372  void removeQueryFlags(uint32 flags) { mQueryFlags &= ~flags; }
1373 
1374 
1387  TerrainLayerBlendMap* getLayerBlendMap(uint8 layerIndex);
1388 
1394  uint8 getBlendTextureIndex(uint8 layerIndex) const;
1395 
1397  uint8 getBlendTextureCount() const;
1399  uint8 getBlendTextureCount(uint8 numLayers) const;
1400 
1401 
1406  const String& getBlendTextureName(uint8 textureIndex) const;
1407 
1420  void setGlobalColourMapEnabled(bool enabled, uint16 size = 0);
1422  bool getGlobalColourMapEnabled() const { return mGlobalColourMapEnabled; }
1424  uint16 getGlobalColourMapSize() const { return mGlobalColourMapSize; }
1426  const TexturePtr& getGlobalColourMap() const { return mColourMap; }
1427 
1433  void widenRectByVector(const Vector3& vec, const Rect& inRect, Rect& outRect);
1434 
1442  void widenRectByVector(const Vector3& vec, const Rect& inRect,
1443  Real minHeight, Real maxHeight, Rect& outRect);
1444 
1454  void freeTemporaryResources();
1455 
1460  const TexturePtr& getLayerBlendTexture(uint8 index) const;
1461 
1468  std::pair<uint8,uint8> getLayerBlendTextureIndex(uint8 layerIndex) const;
1469 
1480  void _setMorphRequired(bool morph) { mLodMorphRequired = morph; }
1482  bool _getMorphRequired() const { return mLodMorphRequired; }
1483 
1495  void _setNormalMapRequired(bool normalMap);
1496 
1510  void _setLightMapRequired(bool lightMap, bool shadowsOnly = false);
1511 
1530  void _setCompositeMapRequired(bool compositeMap);
1531 
1533  bool _getUseVertexCompression() const;
1534 
1536  bool canHandleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
1538  WorkQueue::Response* handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
1540  bool canHandleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
1542  void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
1544  void handleGenerateMaterialResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
1545 
1548 
1550  uint16 getLODLevelWhenVertexEliminated(long x, long y) const;
1552  uint16 getLODLevelWhenVertexEliminated(long rowOrColulmn) const;
1553 
1554 
1556  TerrainQuadTreeNode* getQuadTree() { return mQuadTree; }
1557 
1559  TexturePtr getTerrainNormalMap() const { return mTerrainNormalMap; }
1560 
1568  Terrain* getNeighbour(NeighbourIndex index) const;
1569 
1587  void setNeighbour(NeighbourIndex index, Terrain* neighbour, bool recalculate = false, bool notifyOther = true);
1588 
1593  static NeighbourIndex getOppositeNeighbour(NeighbourIndex index);
1594 
1597  static NeighbourIndex getNeighbourIndex(long offsetx, long offsety);
1598 
1606  void notifyNeighbours();
1607 
1615  void neighbourModified(NeighbourIndex index, const Rect& edgerect, const Rect& shadowrect);
1616 
1622  Terrain* raySelectNeighbour(const Ray& ray, Real distanceLimit = 0);
1623 
1628  void _dumpTextures(const String& prefix, const String& suffix);
1629 
1631  bool isDerivedDataUpdateInProgress() const { return mDerivedDataUpdateInProgress; }
1632 
1633 
1635  static void convertWorldToTerrainAxes(Alignment align, const Vector3& worldVec, Vector3* terrainVec);
1637  static void convertTerrainToWorldAxes(Alignment align, const Vector3& terrainVec, Vector3* worldVec);
1638 
1640  static void writeLayerDeclaration(const TerrainLayerDeclaration& decl, StreamSerialiser& ser);
1642  static bool readLayerDeclaration(StreamSerialiser& ser, TerrainLayerDeclaration& targetdecl);
1644  static void writeLayerInstanceList(const Terrain::LayerInstanceList& lst, StreamSerialiser& ser);
1646  static bool readLayerInstanceList(StreamSerialiser& ser, size_t numSamplers, Terrain::LayerInstanceList& targetlst);
1647 
1648  // This mutex is write-locked by neighbours if they are in the process of deleting themselves.
1649  // It should be read-locked whenever using neighbours in calculations which are possibly running in a
1650  // background thread.
1651  OGRE_RW_MUTEX(mNeighbourMutex);
1652 
1653  protected:
1656  uint getGeoDataSizeAtLod(uint16 lodLevel) const;
1662  inline int getPositiveLodLevel( int lodLevel ) const
1663  {
1664  return (lodLevel>=0) ? lodLevel : mNumLodLevels+lodLevel;
1665  }
1666  void freeLodData();
1667 
1668  void freeCPUResources();
1669  void freeGPUResources();
1670  void determineLodLevels();
1671  void distributeVertexData();
1672  void updateBaseScale();
1673  void createGPUBlendTextures();
1674  void createLayerBlendMaps();
1675  void createOrDestroyGPUNormalMap();
1676  void createOrDestroyGPUColourMap();
1677  void createOrDestroyGPULightmap();
1678  void createOrDestroyGPUCompositeMap();
1679  void waitForDerivedProcesses();
1680  void convertSpace(Space inSpace, const Vector3& inVec, Space outSpace, Vector3& outVec, bool translation) const;
1681  Vector3 convertWorldToTerrainAxes(const Vector3& inVec) const;
1682  Vector3 convertTerrainToWorldAxes(const Vector3& inVec) const;
1686  void getPointAlign(long x, long y, Alignment align, Vector3* outpos) const;
1691  void getPointAlign(long x, long y, float height, Alignment align, Vector3* outpos) const;
1692  void calculateCurrentLod(Viewport* vp);
1694  std::pair<bool, Vector3> checkQuadIntersection(int x, int y, const Ray& ray); //const;
1695 
1697  void deleteBlendMaps(uint8 lowIndex);
1699  void shiftUpGPUBlendChannels(uint8 index);
1701  void shiftDownGPUBlendChannels(uint8 index);
1703  void copyBlendTextureChannel(uint8 srcIndex, uint8 srcChannel, uint8 destIndex, uint8 destChannel );
1705  void clearGPUBlendChannel(uint8 index, uint channel);
1706 
1707  void copyGlobalOptions();
1708  void checkLayers(bool includeGPUResources);
1709  void checkDeclaration();
1710  void deriveUVMultipliers();
1711  PixelFormat getBlendTextureFormat(uint8 textureIndex, uint8 numLayers) const;
1712 
1713  void updateDerivedDataImpl(const Rect& rect, const Rect& lightmapExtraRect, bool synchronous, uint8 typeMask);
1714 
1715  void getEdgeRect(NeighbourIndex index, long range, Rect* outRect) const;
1716  // get the equivalent of the passed in edge rectangle in neighbour
1717  void getNeighbourEdgeRect(NeighbourIndex index, const Rect& inRect, Rect* outRect) const;
1718  // get the equivalent of the passed in edge point in neighbour
1719  void getNeighbourPoint(NeighbourIndex index, long x, long y, long *outx, long *outy) const;
1720  // overflow a point into a neighbour index and point
1721  void getNeighbourPointOverflow(long x, long y, NeighbourIndex *outindex, long *outx, long *outy) const;
1722 
1724  void removeFromNeighbours();
1725 
1733 
1735  float* mHeightData;
1737  float* mDeltaData;
1755 
1760 
1768 
1771  mutable bool mPrepareInProgress;
1774  {
1776  // types requested
1780  _OgreTerrainExport friend std::ostream& operator<<(std::ostream& o, const DerivedDataRequest& r)
1781  { return o; }
1782  };
1783 
1786  {
1799  _OgreTerrainExport friend std::ostream& operator<<(std::ostream& o, const DerivedDataResponse& r)
1800  { return o; }
1801  };
1802 
1805  GEN_COMPOSITE_MAP_MATERIAL
1806  };
1809  {
1811  unsigned long startTime;
1814  _OgreTerrainExport friend std::ostream& operator<<(std::ostream& o, const GenerateMaterialRequest& r)
1815  { return o; }
1816  };
1817 
1821  mutable unsigned long long int mMaterialGenerationCount;
1822  mutable bool mMaterialDirty;
1823  mutable bool mMaterialParamsDirty;
1824 
1833 
1838 
1843 
1850  unsigned long mLastMillis;
1854 
1855 
1860 
1868 
1871 
1873  unsigned long mLastLODFrame;
1875 
1876  Terrain* mNeighbours[NEIGHBOUR_COUNT];
1877 
1880 
1881  size_t getPositionBufVertexSize() const;
1882  size_t getDeltaBufVertexSize() const;
1883 
1885 
1886  public:
1890  void increaseLodLevel(bool synchronous = false);
1894  void decreaseLodLevel();
1895 
1896  int getHighestLodPrepared() const { return (mLodManager) ? mLodManager->getHighestLodPrepared() : -1; };
1897  int getHighestLodLoaded() const { return (mLodManager) ? mLodManager->getHighestLodLoaded() : -1; };
1898  int getTargetLodLevel() const { return (mLodManager) ? mLodManager->getTargetLodLevel() : -1; };
1899  };
1900 
1901 
1911  class _OgreTerrainExport TerrainGlobalOptions : public TerrainAlloc, public Singleton<TerrainGlobalOptions>
1912  {
1913  protected:
1914 
1934 
1935  public:
1938 
1939 
1943  Real getSkirtSize() const { return mSkirtSize; }
1949  void setSkirtSize(Real skirtSz) { mSkirtSize = skirtSz; }
1951  const Vector3& getLightMapDirection() const { return mLightMapDir; }
1953  void setLightMapDirection(const Vector3& v) { mLightMapDir = v; }
1955  const ColourValue& getCompositeMapAmbient() const { return mCompositeMapAmbient; }
1957  void setCompositeMapAmbient(const ColourValue& c) { mCompositeMapAmbient = c; }
1959  const ColourValue& getCompositeMapDiffuse() const { return mCompositeMapDiffuse; }
1961  void setCompositeMapDiffuse(const ColourValue& c) { mCompositeMapDiffuse = c; }
1963  Real getCompositeMapDistance() const { return mCompositeMapDistance; }
1965  void setCompositeMapDistance(Real c) { mCompositeMapDistance = c; }
1966 
1967 
1971  bool getCastsDynamicShadows() const { return mCastsShadows; }
1972 
1978  void setCastsDynamicShadows(bool s) { mCastsShadows = s; }
1979 
1981  Real getMaxPixelError() const { return mMaxPixelError; }
1982 
1988  void setMaxPixelError(Real pixerr) { mMaxPixelError = pixerr; }
1989 
1991  uint8 getRenderQueueGroup(void) const { return mRenderQueueGroup; }
1996  void setRenderQueueGroup(uint8 grp) { mRenderQueueGroup = grp; }
1997 
1999  uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
2004  void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
2005 
2010  void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
2013  uint32 getQueryFlags(void) const { return mQueryFlags; }
2014 
2016  void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
2017 
2018  /* As setQueryFlags, except the flags passed as parameters are removed from the existing flags on this object. */
2019  void removeQueryFlags(uint32 flags) { mQueryFlags &= ~flags; }
2020 
2025  bool getUseRayBoxDistanceCalculation() const { return mUseRayBoxDistanceCalculation; }
2026 
2038  void setUseRayBoxDistanceCalculation(bool rb) { mUseRayBoxDistanceCalculation = rb; }
2039 
2042  TerrainMaterialGeneratorPtr getDefaultMaterialGenerator();
2043 
2046  void setDefaultMaterialGenerator(TerrainMaterialGeneratorPtr gen);
2047 
2050  uint16 getLayerBlendMapSize() const { return mLayerBlendMapSize; }
2051 
2056  void setLayerBlendMapSize(uint16 sz) { mLayerBlendMapSize = sz;}
2057 
2060  Real getDefaultLayerTextureWorldSize() const { return mDefaultLayerTextureWorldSize; }
2061 
2064  void setDefaultLayerTextureWorldSize(Real sz) { mDefaultLayerTextureWorldSize = sz; }
2065 
2068  uint16 getDefaultGlobalColourMapSize() const { return mDefaultGlobalColourMapSize; }
2069 
2073  void setDefaultGlobalColourMapSize(uint16 sz) { mDefaultGlobalColourMapSize = sz;}
2074 
2075 
2078  uint16 getLightMapSize() const { return mLightmapSize; }
2079 
2082  void setLightMapSize(uint16 sz) { mLightmapSize = sz;}
2083 
2086  uint16 getCompositeMapSize() const { return mCompositeMapSize; }
2087 
2090  void setCompositeMapSize(uint16 sz) { mCompositeMapSize = sz;}
2091 
2094  void setDefaultResourceGroup(const String& grp) { mResourceGroup = grp; }
2095 
2098  const String& getDefaultResourceGroup() const { return mResourceGroup; }
2099 
2103  bool getUseVertexCompressionWhenAvailable() const { return mUseVertexCompressionWhenAvailable; }
2104 
2112  void setUseVertexCompressionWhenAvailable(bool enable) { mUseVertexCompressionWhenAvailable = enable; }
2113 
2129  static TerrainGlobalOptions& getSingleton(void);
2145  static TerrainGlobalOptions* getSingletonPtr(void);
2146 
2147 
2148  };
2149 
2150 
2153 }
2154 
2155 
2156 
2157 
2158 #endif
Representation of a ray in space, i.e.
Definition: OgreRay.h:45
A data holder for communicating with the background derived data update.
Definition: OgreTerrain.h:1785
unsigned char uint8
Definition: OgrePlatform.h:422
bool isModified() const
Returns whether this terrain has been modified since it was first loaded / defined.
Definition: OgreTerrain.h:761
void setLayerBlendMapSize(uint16 sz)
Sets the default size of blend maps for a new terrain.
Definition: OgreTerrain.h:2056
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
int getTargetLodLevel() const
Definition: OgreTerrain.h:1898
static const uint32 TERRAIN_CHUNK_ID
Definition: OgreTerrain.h:277
Structure encapsulating import data that you may use to bootstrap the terrain without loading from a ...
Definition: OgreTerrain.h:327
uint8 getLayerCount() const
Get the number of layers in this terrain.
Definition: OgreTerrain.h:994
#define OGRE_ALLOC_T(T, count, category)
Allocate a block of memory for a primitive type, and indicate the category of usage.
unsigned long long int mMaterialGenerationCount
Definition: OgreTerrain.h:1821
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
_OgreTerrainExport friend std::ostream & operator<<(std::ostream &o, const GenerateMaterialRequest &r)
Definition: OgreTerrain.h:1814
static const uint16 TERRAINLAYERINSTANCE_CHUNK_VERSION
Definition: OgreTerrain.h:289
uint16 getLayerBlendMapSize() const
Get the default size of the blend maps for a new terrain.
Definition: OgreTerrain.h:2050
float * inputFloat
Optional list of terrainSize * terrainSize floats defining the terrain.
Definition: OgreTerrain.h:371
float Real
Software floating point type.
bool getGlobalColourMapEnabled() const
Get whether a global colour map is enabled on this terrain.
Definition: OgreTerrain.h:1422
uint16 mCompositeMapSizeActual
Definition: OgreTerrain.h:1845
NeighbourIndex
Neighbour index enumeration - indexed anticlockwise from East like angles.
Definition: OgreTerrain.h:499
const String & getResourceGroup() const
Get the resource group to use when loading / saving.
Definition: OgreTerrain.h:677
unsigned int uint32
Definition: OgrePlatform.h:420
bool isLoaded() const
Return whether the terrain is loaded.
Definition: OgreTerrain.h:755
void setSkirtSize(Real skirtSz)
method - the default size of 'skirts' used to hide terrain cracks (default 10)
Definition: OgreTerrain.h:1949
Alignment mAlign
Definition: OgreTerrain.h:1738
uint16 mMinBatchSize
Definition: OgreTerrain.h:1742
Utility class to generate a sequentially numbered series of names.
const ColourValue & getCompositeMapAmbient() const
Get the composite map ambient light to use.
Definition: OgreTerrain.h:1955
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:265
vector< LayerInstance >::type LayerInstanceList
Definition: OgreTerrain.h:311
SceneNode * mRootNode
Definition: OgreTerrain.h:1728
void addQueryFlags(uint32 flags)
As setQueryFlags, except the flags passed as parameters are appended to the existing flags on this ob...
Definition: OgreTerrain.h:2016
bool mHeightDataModified
Definition: OgreTerrain.h:1732
General purpose request structure.
Definition: OgreWorkQueue.h:84
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
static const uint16 TERRAINGENERALINFO_CHUNK_VERSION
Definition: OgreTerrain.h:293
uint16 getGlobalColourMapSize() const
Get the size of the global colour map (if used)
Definition: OgreTerrain.h:1424
uint16 getLightMapSize() const
Get the default size of the lightmaps for a new terrain.
Definition: OgreTerrain.h:2078
Rect lightmapUpdateRect
The area of lightmap that was updated.
Definition: OgreTerrain.h:1795
int mLastViewportHeight
Definition: OgreTerrain.h:1874
uint16 mTreeDepth
Definition: OgreTerrain.h:1747
const Vector3 & getPosition() const
Get the world position of the terrain centre.
Definition: OgreTerrain.h:1101
Class representing colour.
static const uint16 WORKQUEUE_DERIVED_DATA_REQUEST
Definition: OgreTerrain.h:1546
General purpose response structure.
TexturePtr mCompositeMap
Definition: OgreTerrain.h:1846
const Vector3 & getLightMapDirection() const
Get the shadow map light direction to use (world space)
Definition: OgreTerrain.h:1951
Manages the organisation and rendering of a 'scene' i.e.
static const uint32 TERRAINDERIVEDDATA_CHUNK_ID
Definition: OgreTerrain.h:290
ColourValue mCompositeMapDiffuse
Definition: OgreTerrain.h:1930
uint16 mLayerBlendMapSize
Definition: OgreTerrain.h:1825
bool isDerivedDataUpdateInProgress() const
Query whether a derived data update is in progress or not.
Definition: OgreTerrain.h:1631
uint8 * mCpuLightmapStorage
Definition: OgreTerrain.h:1842
_OgreTerrainExport friend std::ostream & operator<<(std::ostream &o, const DerivedDataResponse &r)
Definition: OgreTerrain.h:1799
static const uint8 DERIVED_DATA_LIGHTMAP
Definition: OgreTerrain.h:1194
const MaterialPtr & _getMaterial() const
Internal getting of material.
Definition: OgreTerrain.h:1332
uint16 mGlobalColourMapSize
Definition: OgreTerrain.h:1834
static const uint8 DERIVED_DATA_ALL
Definition: OgreTerrain.h:1195
Real getDefaultLayerTextureWorldSize() const
Get the default world size for a layer 'splat' texture to cover.
Definition: OgreTerrain.h:2060
ColourValue mCompositeMapAmbient
Definition: OgreTerrain.h:1929
TerrainLayerBlendMapList mLayerBlendMapList
Definition: OgreTerrain.h:1832
void _setMorphRequired(bool morph)
Request internal implementation options for the terrain material to use, in this case vertex morphing...
Definition: OgreTerrain.h:1480
uint16 getNumLodLevels() const
Get the total number of LOD levels in the terrain.
Definition: OgreTerrain.h:1242
static const uint16 TERRAIN_CHUNK_VERSION
Definition: OgreTerrain.h:278
Shared pointer implementation used to share vertex buffers.
A 3D box aligned with the x/y/z axes.
Rect deltaUpdateRect
The area of deltas that was updated.
Definition: OgreTerrain.h:1791
Real mScale
Relationship between one point on the terrain and world size.
Definition: OgreTerrain.h:1751
SceneManager * mSceneMgr
Definition: OgreTerrain.h:1727
static const uint16 TERRAIN_MAX_BATCH_SIZE
Definition: OgreTerrain.h:279
static NameGenerator msBlendTextureGenerator
Definition: OgreTerrain.h:1856
uint16 mLightmapSize
Definition: OgreTerrain.h:1839
const String & getMaterialName() const
Get the name of the material being used for the terrain.
Definition: OgreTerrain.h:1339
unsigned long mCompositeMapUpdateCountdown
Definition: OgreTerrain.h:1849
IlluminationRenderStage
Describes the stage of rendering when performing complex illumination.
Class that allows listening in on the various stages of SceneManager processing, so that custom behav...
int getPositiveLodLevel(int lodLevel) const
Get the real lod level.
Definition: OgreTerrain.h:1662
bool mLodMorphRequired
Definition: OgreTerrain.h:1861
uint32 mQueryFlags
Definition: OgreTerrain.h:1759
bool deleteInputData
Whether this structure should 'own' the input data (inputImage and inputFloat), and therefore delete ...
Definition: OgreTerrain.h:385
Real getCompositeMapDistance() const
Get the distance at which to start using a composite map if present.
Definition: OgreTerrain.h:1963
void setResourceGroup(const String &resGroup)
Set the resource group to use when loading / saving.
Definition: OgreTerrain.h:672
float * mDeltaData
The delta information defining how a vertex moves before it is removed at a lower LOD...
Definition: OgreTerrain.h:1737
TexturePtrList mBlendTextureList
Definition: OgreTerrain.h:1831
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:53
bool mDerivedDataUpdateInProgress
Definition: OgreTerrain.h:1765
static const uint8 DERIVED_DATA_DELTAS
Definition: OgreTerrain.h:1192
bool mGlobalColourMapEnabled
Definition: OgreTerrain.h:1835
void removeQueryFlags(uint32 flags)
Definition: OgreTerrain.h:2019
static const uint32 TERRAINLAYERSAMPLERELEMENT_CHUNK_ID
Definition: OgreTerrain.h:286
uint16 minBatchSize
Minimum batch size (along one edge) in vertices; must be 2^n+1.
Definition: OgreTerrain.h:349
void removeQueryFlags(uint32 flags)
Definition: OgreTerrain.h:1372
void setRenderQueueGroup(uint8 grp)
Set the render queue group that this terrain will be rendered into.
Definition: OgreTerrain.h:1352
static const uint64 TERRAIN_GENERATE_MATERIAL_INTERVAL_MS
Definition: OgreTerrain.h:280
static const uint16 TERRAINLAYERDECLARATION_CHUNK_VERSION
Definition: OgreTerrain.h:283
BytePointerList mCpuBlendMapStorage
Staging post for blend map data.
Definition: OgreTerrain.h:1829
void setQueryFlags(uint32 flags)
Set the default query flags for terrains.
Definition: OgreTerrain.h:2010
vector< TexturePtr >::type TexturePtrList
Definition: OgreTerrain.h:1830
A data holder for communicating with the background GetMaterial.
Definition: OgreTerrain.h:1808
uint8 getRenderQueueGroup(void) const
Get the render queue group that this terrain will be rendered into.
Definition: OgreTerrain.h:1348
Shared pointer implementation used to share index buffers.
Alignment terrainAlign
The alignment of the terrain.
Definition: OgreTerrain.h:330
void setQueryFlags(uint32 flags)
Set the query flags for this terrain.
Definition: OgreTerrain.h:1366
void addQueryFlags(uint32 flags)
As setQueryFlags, except the flags passed as parameters are appended to the existing flags on this ob...
Definition: OgreTerrain.h:1369
const TerrainLayerDeclaration & getLayerDeclaration() const
Get the declaration which describes the layers in this terrain.
Definition: OgreTerrain.h:997
uint16 getDefaultGlobalColourMapSize() const
Get the default size of the terrain global colour map for a new terrain.
Definition: OgreTerrain.h:2068
void setCastsDynamicShadows(bool s)
Whether the terrain will be able to cast shadows (texture shadows only are supported, and you must be using depth shadow maps).
Definition: OgreTerrain.h:1978
void destroy()
Delete any input data if this struct is set to do so.
Definition: OgreTerrain.h:479
const TexturePtr & getLightmap() const
Get access to the lightmap, if enabled (as requested by the material generator)
Definition: OgreTerrain.h:1088
TerrainLayerDeclaration layerDeclaration
Definition of the contents of each layer (required).
Definition: OgreTerrain.h:396
Rect normalUpdateRect
The area of normals that was updated.
Definition: OgreTerrain.h:1793
TerrainLodManager * mLodManager
Definition: OgreTerrain.h:1884
uint16 terrainSize
Terrain size (along one edge) in vertices; must be 2^n+1.
Definition: OgreTerrain.h:332
vector< Real >::type RealVector
Definition: OgreTerrain.h:297
uint32 getQueryFlags(void) const
Get the default query flags for terrains.
Definition: OgreTerrain.h:2013
Rect mDirtyLightmapFromNeighboursRect
Definition: OgreTerrain.h:1764
void setDefaultLayerTextureWorldSize(Real sz)
Set the default world size for a layer 'splat' texture to cover.
Definition: OgreTerrain.h:2064
bool getUseVertexCompressionWhenAvailable() const
Get whether to allow vertex compression to be used when the material generator states that it support...
Definition: OgreTerrain.h:2103
Interface definition for a handler of requests.
void setLightMapSize(uint16 sz)
Sets the default size of lightmaps for a new terrain.
Definition: OgreTerrain.h:2082
Real worldSize
The world size of the terrain.
Definition: OgreTerrain.h:358
PixelFormat
The pixel format used for images, textures, and render surfaces.
int getHighestLodPrepared() const
Definition: OgreTerrain.h:1896
Class exposing an interface to a blend map for a given layer.
bool mCompositeMapDirtyRectLightmapUpdate
True if the updates included lightmap changes (widen)
Definition: OgreTerrain.h:1852
void setCompositeMapSize(uint16 sz)
Sets the default size of composite maps for a new terrain.
Definition: OgreTerrain.h:2090
void setCompositeMapDistance(Real c)
Set the distance at which to start using a composite map if present.
Definition: OgreTerrain.h:1965
Space
Enumeration of relative spaces that you might want to use to address the terrain. ...
Definition: OgreTerrain.h:516
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
bool mNormalMapRequired
Definition: OgreTerrain.h:1862
Interface used to by the Terrain instance to allocate GPU buffers.
Definition: OgreTerrain.h:536
MaterialPtr mCompositeMapMaterial
Definition: OgreTerrain.h:1853
#define _OgreTerrainExport
unsigned long long uint64
Definition: OgrePlatform.h:431
void setRenderQueueGroup(uint8 grp)
Set the render queue group that terrains will be rendered into.
Definition: OgreTerrain.h:1996
TerrainQuadTreeNode * mQuadTree
Definition: OgreTerrain.h:1744
RealVector mLayerUVMultiplier
Definition: OgreTerrain.h:1754
TerrainLayerDeclaration mLayerDecl
Definition: OgreTerrain.h:1752
StringVector textureNames
List of texture names to import; must match with TerrainLayerDeclaration.
Definition: OgreTerrain.h:306
Alignment
The alignment of the terrain.
Definition: OgreTerrain.h:314
A interface class defining a listener which can be used to receive notifications of frame events...
const Camera * mLastLODCamera
Definition: OgreTerrain.h:1872
ImportData(const ImportData &rhs)
Definition: OgreTerrain.h:420
Utility class providing helper methods for reading / writing structured data held in a DataStream...
uint16 mNumLodLevelsPerLeafNode
Definition: OgreTerrain.h:1746
vector< String >::type StringVector
uint16 mLayerBlendMapSizeActual
Definition: OgreTerrain.h:1826
static const uint8 DERIVED_DATA_NORMALS
Definition: OgreTerrain.h:1193
static const uint16 TERRAINDERIVEDDATA_CHUNK_VERSION
Definition: OgreTerrain.h:291
Rect mCompositeMapDirtyRect
Definition: OgreTerrain.h:1848
uint16 maxBatchSize
Maximum batch size (along one edge) in vertices; must be 2^n+1 and <= 65.
Definition: OgreTerrain.h:338
#define OGRE_DELETE
vector< TerrainLayerBlendMap * >::type TerrainLayerBlendMapList
void setVisibilityFlags(uint32 flags)
Set the visbility flags that terrains will be rendered with.
Definition: OgreTerrain.h:2004
String mMaterialName
Definition: OgreTerrain.h:1818
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
uint16 getLightmapSize() const
Get the requested size of lightmap for this terrain.
Definition: OgreTerrain.h:1085
Interface definition for a handler of responses.
Image * inputImage
Optional heightmap providing the initial heights for the terrain.
Definition: OgreTerrain.h:365
The definition of the information each layer will contain in this terrain.
Class representing an image file.
Definition: OgreImage.h:60
static NameGenerator msCompositeMapNameGenerator
Definition: OgreTerrain.h:1859
int getHighestLodLoaded() const
Definition: OgreTerrain.h:1897
Real getSkirtSize() const
The default size of 'skirts' used to hide terrain cracks (default 10)
Definition: OgreTerrain.h:1943
TerrainMaterialGeneratorPtr mMaterialGenerator
Definition: OgreTerrain.h:1820
PixelBox * mCpuTerrainNormalMap
Pending data.
Definition: OgreTerrain.h:1870
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:56
uint32 getVisibilityFlags(void) const
Get the visibility flags for this terrain.
Definition: OgreTerrain.h:1355
float * mHeightData
The height data (world coords relative to mPos)
Definition: OgreTerrain.h:1735
uint32 mVisibilityFlags
Definition: OgreTerrain.h:1758
uint8 * mCpuColourMapStorage
Definition: OgreTerrain.h:1837
TerrainMaterialGeneratorPtr mDefaultMaterialGenerator
Definition: OgreTerrain.h:1923
uint8 * mCpuCompositeMapStorage
Definition: OgreTerrain.h:1847
unsigned long mLastMillis
Definition: OgreTerrain.h:1850
uint16 mMaxBatchSize
Definition: OgreTerrain.h:1741
void setLightMapDirection(const Vector3 &v)
Set the shadow map light direction to use (world space).
Definition: OgreTerrain.h:1953
bool isHeightDataModified() const
Returns whether terrain heights have been modified since the terrain was first loaded / defined...
Definition: OgreTerrain.h:768
bool mMaterialParamsDirty
Definition: OgreTerrain.h:1823
static const uint32 TERRAINLAYERSAMPLER_CHUNK_ID
Definition: OgreTerrain.h:284
Options class which just stores default options for the terrain.
Definition: OgreTerrain.h:1911
PixelBox * normalMapBox
All CPU-side data, independent of textures; to be blitted in main thread.
Definition: OgreTerrain.h:1797
ImportData & operator=(const ImportData &rhs)
Definition: OgreTerrain.h:437
uint32 getQueryFlags(void) const
Get the query flags for this terrain.
Definition: OgreTerrain.h:1362
uint16 mWorkQueueChannel
Definition: OgreTerrain.h:1726
void setUseRayBoxDistanceCalculation(bool rb)
Sets whether to use an accurate ray / box intersection to determine distance from a terrain tile...
Definition: OgreTerrain.h:2038
Terrain LOD data manager.
Rect mDirtyDerivedDataRect
Definition: OgreTerrain.h:1762
void setDefaultResourceGroup(const String &grp)
Set the default resource group to use to load / save terrains.
Definition: OgreTerrain.h:2094
TexturePtr mTerrainNormalMap
Texture storing normals for the whole terrrain.
Definition: OgreTerrain.h:1867
static const uint16 TERRAINLAYERSAMPLERELEMENT_CHUNK_VERSION
Definition: OgreTerrain.h:287
LayerInstanceList layerList
List of layer structures, one for each layer required.
Definition: OgreTerrain.h:401
#define OGRE_NEW
uint16 getCompositeMapSize() const
Get the default size of the composite maps for a new terrain.
Definition: OgreTerrain.h:2086
Real inputScale
How to scale the input values provided (if any)
Definition: OgreTerrain.h:388
Geometry held in main memory.
String mResourceGroup
Definition: OgreTerrain.h:1729
Vector3 pos
Position of the terrain.
Definition: OgreTerrain.h:355
bool _getMorphRequired() const
Get whether LOD morphing is needed.
Definition: OgreTerrain.h:1482
void setVisibilityFlags(uint32 flags)
Set the visibility flags for this terrain.
Definition: OgreTerrain.h:1359
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
uint16 getNumLodLevelsPerLeaf() const
Get the number of LOD levels in a leaf of the terrain quadtree.
Definition: OgreTerrain.h:1245
GpuBufferAllocator * mCustomGpuBufferAllocator
Definition: OgreTerrain.h:1878
static NameGenerator msLightmapNameGenerator
Definition: OgreTerrain.h:1858
const String & getDefaultResourceGroup() const
Get the default resource group to use to load / save terrains.
Definition: OgreTerrain.h:2098
DefaultGpuBufferAllocator mDefaultGpuBufferAllocator
Definition: OgreTerrain.h:1879
Standard implementation of a buffer allocator which re-uses buffers.
Definition: OgreTerrain.h:575
Struct containing information about a frame event.
uint16 mNumLodLevels
Definition: OgreTerrain.h:1745
#define OGRE_RW_MUTEX(name)
void setMaxPixelError(Real pixerr)
Set the maximum screen pixel error that should be allowed when rendering.
Definition: OgreTerrain.h:1988
TexturePtr mColourMap
Definition: OgreTerrain.h:1836
bool mLightMapRequired
Definition: OgreTerrain.h:1863
Real worldSize
The world size of the texture to be applied in this layer.
Definition: OgreTerrain.h:304
_StringBase String
Definition: OgreCommon.h:53
bool getUseRayBoxDistanceCalculation() const
Returns whether or not to use an accurate calculation of camera distance from a terrain tile (ray / A...
Definition: OgreTerrain.h:2025
TexturePtr mLightmap
Definition: OgreTerrain.h:1841
Rect mDirtyGeometryRect
Definition: OgreTerrain.h:1761
uint8 mDerivedUpdatePendingMask
If another update is requested while one is already running.
Definition: OgreTerrain.h:1767
const TexturePtr & getGlobalColourMap() const
Get access to the global colour map, if enabled.
Definition: OgreTerrain.h:1426
vector< uint8 * >::type BytePointerList
Definition: OgreTerrain.h:1827
static const uint16 WORKQUEUE_GENERATE_MATERIAL_REQUEST
Definition: OgreTerrain.h:1547
static const uint32 TERRAINLAYERDECLARATION_CHUNK_ID
Definition: OgreTerrain.h:282
A data holder for communicating with the background derived data update.
Definition: OgreTerrain.h:1773
Real mBase
Base position in world space, relative to mPos.
Definition: OgreTerrain.h:1749
unsigned short uint16
Definition: OgrePlatform.h:421
map< uint32, HardwareIndexBufferSharedPtr >::type IBufMap
Definition: OgreTerrain.h:597
const MaterialPtr & _getCompositeMapMaterial() const
Internal getting of material for the terrain composite map.
Definition: OgreTerrain.h:1336
float constantHeight
If neither inputImage or inputFloat are supplied, the constant height at which the initial terrain sh...
Definition: OgreTerrain.h:376
static const size_t LOD_MORPH_CUSTOM_PARAM
Definition: OgreTerrain.h:295
unsigned long mLastLODFrame
Definition: OgreTerrain.h:1873
void setUseVertexCompressionWhenAvailable(bool enable)
Set whether to allow vertex compression to be used when the material generator states that it support...
Definition: OgreTerrain.h:2112
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:71
uint32 getVisibilityFlags(void) const
Get the visbility flags that terrains will be rendered with.
Definition: OgreTerrain.h:1999
const TexturePtr & getCompositeMap() const
Get access to the composite map, if enabled (as requested by the material generator) ...
Definition: OgreTerrain.h:1098
uint8 getRenderQueueGroup(void) const
Get the render queue group that this terrain will be rendered into.
Definition: OgreTerrain.h:1991
A node in a quad tree used to store a patch of terrain.
void setDefaultGlobalColourMapSize(uint16 sz)
Set the default size of the terrain global colour map for a new terrain.
Definition: OgreTerrain.h:2073
list< HardwareVertexBufferSharedPtr >::type VBufList
Definition: OgreTerrain.h:594
void setCompositeMapAmbient(const ColourValue &c)
Set the composite map ambient light to use.
Definition: OgreTerrain.h:1957
uint16 getLayerBlendMapSize() const
Get the requested size of the blend maps used to blend between layers for this terrain.
Definition: OgreTerrain.h:1078
An instance of a layer, with specific texture names.
Definition: OgreTerrain.h:301
void setCompositeMapDiffuse(const ColourValue &c)
Set the composite map diffuse light to use.
Definition: OgreTerrain.h:1961
uint16 mLightmapSizeActual
Definition: OgreTerrain.h:1840
uint16 getCompositeMapSize() const
Get the requested size of composite map for this terrain.
Definition: OgreTerrain.h:1095
SceneManager * getSceneManager() const
Definition: OgreTerrain.h:513
TerrainQuadTreeNode * getQuadTree()
Get the top level of the quad tree which is used to divide up the terrain.
Definition: OgreTerrain.h:1556
static const uint16 TERRAINLAYERSAMPLER_CHUNK_VERSION
Definition: OgreTerrain.h:285
_OgreTerrainExport friend std::ostream & operator<<(std::ostream &o, const DerivedDataRequest &r)
Definition: OgreTerrain.h:1780
Real inputBias
How to bias the input values provided (if any)
Definition: OgreTerrain.h:390
bool getCastsDynamicShadows() const
Whether the terrain will be able to cast shadows (texture shadows only are supported, and you must be using depth shadow maps).
Definition: OgreTerrain.h:1971
uint16 mCompositeMapSize
Definition: OgreTerrain.h:1844
static NameGenerator msNormalMapNameGenerator
Definition: OgreTerrain.h:1857
TexturePtr getTerrainNormalMap() const
Get the (global) normal map texture.
Definition: OgreTerrain.h:1559
static const uint32 TERRAINLAYERINSTANCE_CHUNK_ID
Definition: OgreTerrain.h:288
LayerInstanceList mLayers
Definition: OgreTerrain.h:1753
Real getMaxPixelError() const
Get the maximum screen pixel error that should be allowed when rendering.
Definition: OgreTerrain.h:1981
uint8 remainingTypeMask
Remaining types not yet processed.
Definition: OgreTerrain.h:1789
Rect mDirtyGeometryRectForNeighbours
Definition: OgreTerrain.h:1763
static const uint32 TERRAINGENERALINFO_CHUNK_ID
Definition: OgreTerrain.h:292
bool mPrepareInProgress
Don't release Height/DeltaData when preparing.
Definition: OgreTerrain.h:1771
unsigned int uint
bool mGenerateMaterialInProgress
Definition: OgreTerrain.h:1769
MaterialPtr mMaterial
Definition: OgreTerrain.h:1819
uint8 mRenderQueueGroup
Definition: OgreTerrain.h:1757
bool mCompositeMapRequired
Definition: OgreTerrain.h:1865
const ColourValue & getCompositeMapDiffuse() const
Get the composite map iffuse light to use.
Definition: OgreTerrain.h:1959
bool mLightMapShadowsOnly
Definition: OgreTerrain.h:1864
Real getSkirtSize() const
The default size of 'skirts' used to hide terrain cracks (default 10, set for new Terrain using Terra...
Definition: OgreTerrain.h:1239