OpenMW
|
00001 #ifndef COMPONENTS_TERRAIN_H 00002 #define COMPONENTS_TERRAIN_H 00003 00004 #include <OgreHardwareIndexBuffer.h> 00005 #include <OgreHardwareVertexBuffer.h> 00006 #include <OgreAxisAlignedBox.h> 00007 #include <OgreTexture.h> 00008 00009 namespace Loading 00010 { 00011 class Listener; 00012 } 00013 00014 namespace Ogre 00015 { 00016 class Camera; 00017 } 00018 00019 namespace Terrain 00020 { 00021 00022 class QuadTreeNode; 00023 class Storage; 00024 00032 class World 00033 { 00034 public: 00044 World(Loading::Listener* loadingListener, Ogre::SceneManager* sceneMgr, 00045 Storage* storage, int visiblityFlags, bool distantLand, bool shaders); 00046 ~World(); 00047 00048 void setLoadingListener(Loading::Listener* loadingListener) { mLoadingListener = loadingListener; } 00049 00050 bool getDistantLandEnabled() { return mDistantLand; } 00051 bool getShadersEnabled() { return mShaders; } 00052 bool getShadowsEnabled() { return mShadows; } 00053 bool getSplitShadowsEnabled() { return mSplitShadows; } 00054 00055 float getHeightAt (const Ogre::Vector3& worldPos); 00056 00060 void update (const Ogre::Vector3& cameraPos); 00061 00063 Ogre::AxisAlignedBox getWorldBoundingBox (const Ogre::Vector2& center); 00064 00065 Ogre::SceneManager* getSceneManager() { return mSceneMgr; } 00066 00067 Ogre::SceneNode* getRootSceneNode() { return mRootSceneNode; } 00068 00069 Storage* getStorage() { return mStorage; } 00070 00073 void setVisible(bool visible); 00074 bool getVisible(); 00075 00081 void applyMaterials(bool shadows, bool splitShadows); 00082 00083 int getVisiblityFlags() { return mVisibilityFlags; } 00084 00085 int getMaxBatchSize() { return mMaxBatchSize; } 00086 00087 void enableSplattingShader(bool enabled); 00088 00089 private: 00090 bool mDistantLand; 00091 bool mShaders; 00092 bool mShadows; 00093 bool mSplitShadows; 00094 bool mVisible; 00095 00096 Loading::Listener* mLoadingListener; 00097 00098 QuadTreeNode* mRootNode; 00099 Ogre::SceneNode* mRootSceneNode; 00100 Storage* mStorage; 00101 00102 int mVisibilityFlags; 00103 00104 Ogre::SceneManager* mSceneMgr; 00105 Ogre::SceneManager* mCompositeMapSceneMgr; 00106 00108 Ogre::AxisAlignedBox mBounds; 00109 00111 float mMinBatchSize; 00113 float mMaxBatchSize; 00114 00115 void buildQuadTree(QuadTreeNode* node); 00116 00117 public: 00118 // ----INTERNAL---- 00119 00120 enum IndexBufferFlags 00121 { 00122 IBF_North = 1 << 0, 00123 IBF_East = 1 << 1, 00124 IBF_South = 1 << 2, 00125 IBF_West = 1 << 3 00126 }; 00127 00131 Ogre::HardwareIndexBufferSharedPtr getIndexBuffer (int flags, size_t& numIndices); 00132 00133 Ogre::HardwareVertexBufferSharedPtr getVertexBuffer (int numVertsOneSide); 00134 00135 Ogre::SceneManager* getCompositeMapSceneManager() { return mCompositeMapSceneMgr; } 00136 00137 // Delete all quads 00138 void clearCompositeMapSceneManager(); 00139 void renderCompositeMap (Ogre::TexturePtr target); 00140 00141 private: 00142 // Index buffers are shared across terrain batches where possible. There is one index buffer for each 00143 // combination of LOD deltas and index buffer LOD we may need. 00144 std::map<int, Ogre::HardwareIndexBufferSharedPtr> mIndexBufferMap; 00145 00146 std::map<int, Ogre::HardwareVertexBufferSharedPtr> mUvBufferMap; 00147 00148 Ogre::RenderTarget* mCompositeMapRenderTarget; 00149 Ogre::TexturePtr mCompositeMapRenderTexture; 00150 }; 00151 00152 } 00153 00154 #endif