OpenMW
|
A quadtree-based terrain implementation suitable for large data sets.
Near cells are rendered with alpha splatting, distant cells are merged together in batches and have their layers pre-rendered onto a composite map.
Cracks at LOD transitions are avoided using stitching.
More...
#include <world.hpp>
Public Types | |
enum | IndexBufferFlags { IBF_North = 1 << 0, IBF_East = 1 << 1, IBF_South = 1 << 2, IBF_West = 1 << 3 } |
Public Member Functions | |
World (Loading::Listener *loadingListener, Ogre::SceneManager *sceneMgr, Storage *storage, int visiblityFlags, bool distantLand, bool shaders) | |
~World () | |
void | setLoadingListener (Loading::Listener *loadingListener) |
bool | getDistantLandEnabled () |
bool | getShadersEnabled () |
bool | getShadowsEnabled () |
bool | getSplitShadowsEnabled () |
float | getHeightAt (const Ogre::Vector3 &worldPos) |
void | update (const Ogre::Vector3 &cameraPos) |
Ogre::AxisAlignedBox | getWorldBoundingBox (const Ogre::Vector2 ¢er) |
Get the world bounding box of a chunk of terrain centered at center. | |
Ogre::SceneManager * | getSceneManager () |
Ogre::SceneNode * | getRootSceneNode () |
Storage * | getStorage () |
void | setVisible (bool visible) |
bool | getVisible () |
void | applyMaterials (bool shadows, bool splitShadows) |
int | getVisiblityFlags () |
int | getMaxBatchSize () |
void | enableSplattingShader (bool enabled) |
Ogre::HardwareIndexBufferSharedPtr | getIndexBuffer (int flags, size_t &numIndices) |
Ogre::HardwareVertexBufferSharedPtr | getVertexBuffer (int numVertsOneSide) |
Ogre::SceneManager * | getCompositeMapSceneManager () |
void | clearCompositeMapSceneManager () |
void | renderCompositeMap (Ogre::TexturePtr target) |
Private Member Functions | |
void | buildQuadTree (QuadTreeNode *node) |
Private Attributes | |
bool | mDistantLand |
bool | mShaders |
bool | mShadows |
bool | mSplitShadows |
bool | mVisible |
Loading::Listener * | mLoadingListener |
QuadTreeNode * | mRootNode |
Ogre::SceneNode * | mRootSceneNode |
Storage * | mStorage |
int | mVisibilityFlags |
Ogre::SceneManager * | mSceneMgr |
Ogre::SceneManager * | mCompositeMapSceneMgr |
Ogre::AxisAlignedBox | mBounds |
Bounds in cell units. | |
float | mMinBatchSize |
Minimum size of a terrain batch along one side (in cell units) | |
float | mMaxBatchSize |
Maximum size of a terrain batch along one side (in cell units) | |
std::map< int, Ogre::HardwareIndexBufferSharedPtr > | mIndexBufferMap |
std::map< int, Ogre::HardwareVertexBufferSharedPtr > | mUvBufferMap |
Ogre::RenderTarget * | mCompositeMapRenderTarget |
Ogre::TexturePtr | mCompositeMapRenderTexture |
A quadtree-based terrain implementation suitable for large data sets.
Near cells are rendered with alpha splatting, distant cells are merged together in batches and have their layers pre-rendered onto a composite map.
Cracks at LOD transitions are avoided using stitching.
Terrain::World::World | ( | Loading::Listener * | loadingListener, |
Ogre::SceneManager * | sceneMgr, | ||
Storage * | storage, | ||
int | visiblityFlags, | ||
bool | distantLand, | ||
bool | shaders | ||
) |
loadingListener | Listener to update with progress |
sceneMgr | scene manager to use |
storage | Storage instance to get terrain data from (heights, normals, colors, textures..) |
visbilityFlags | visibility flags for the created meshes |
distantLand | Whether to draw all of the terrain, or only a 3x3 grid around the camera. This is a temporary option until it can be streamlined. |
shaders | Whether to use splatting shader, or multi-pass fixed function splatting. Shader is usually faster so this is just here for compatibility. |
void Terrain::World::applyMaterials | ( | bool | shadows, |
bool | splitShadows | ||
) |
Recreate materials used by terrain chunks. This should be called whenever settings of the material factory are changed. (Relying on the factory to update those materials is not enough, since turning a feature on/off can change the number of texture units available for layer/blend textures, and to properly respond to this we may need to change the structure of the material, such as adding or removing passes. This can only be achieved by a full rebuild.)
void Terrain::World::buildQuadTree | ( | QuadTreeNode * | node | ) | [private] |
void Terrain::World::enableSplattingShader | ( | bool | enabled | ) |
Ogre::SceneManager* Terrain::World::getCompositeMapSceneManager | ( | ) | [inline] |
bool Terrain::World::getDistantLandEnabled | ( | ) | [inline] |
float Terrain::World::getHeightAt | ( | const Ogre::Vector3 & | worldPos | ) |
Ogre::HardwareIndexBufferSharedPtr Terrain::World::getIndexBuffer | ( | int | flags, |
size_t & | numIndices | ||
) |
flags | first 4*4 bits are LOD deltas on each edge, respectively (4 bits each) next 4 bits are LOD level of the index buffer (LOD 0 = don't omit any vertices) |
numIndices | number of indices that were used will be written here |
int Terrain::World::getMaxBatchSize | ( | ) | [inline] |
Ogre::SceneNode* Terrain::World::getRootSceneNode | ( | ) | [inline] |
Ogre::SceneManager* Terrain::World::getSceneManager | ( | ) | [inline] |
bool Terrain::World::getShadersEnabled | ( | ) | [inline] |
bool Terrain::World::getShadowsEnabled | ( | ) | [inline] |
bool Terrain::World::getSplitShadowsEnabled | ( | ) | [inline] |
Storage* Terrain::World::getStorage | ( | ) | [inline] |
Ogre::HardwareVertexBufferSharedPtr Terrain::World::getVertexBuffer | ( | int | numVertsOneSide | ) |
bool Terrain::World::getVisible | ( | ) |
int Terrain::World::getVisiblityFlags | ( | ) | [inline] |
Ogre::AxisAlignedBox Terrain::World::getWorldBoundingBox | ( | const Ogre::Vector2 & | center | ) |
Get the world bounding box of a chunk of terrain centered at center.
void Terrain::World::renderCompositeMap | ( | Ogre::TexturePtr | target | ) |
void Terrain::World::setLoadingListener | ( | Loading::Listener * | loadingListener | ) | [inline] |
void Terrain::World::setVisible | ( | bool | visible | ) |
Show or hide the whole terrain
void Terrain::World::update | ( | const Ogre::Vector3 & | cameraPos | ) |
Update chunk LODs according to this camera position
Ogre::AxisAlignedBox Terrain::World::mBounds [private] |
Bounds in cell units.
Ogre::RenderTarget* Terrain::World::mCompositeMapRenderTarget [private] |
Ogre::TexturePtr Terrain::World::mCompositeMapRenderTexture [private] |
Ogre::SceneManager* Terrain::World::mCompositeMapSceneMgr [private] |
bool Terrain::World::mDistantLand [private] |
std::map<int, Ogre::HardwareIndexBufferSharedPtr> Terrain::World::mIndexBufferMap [private] |
float Terrain::World::mMaxBatchSize [private] |
Maximum size of a terrain batch along one side (in cell units)
float Terrain::World::mMinBatchSize [private] |
Minimum size of a terrain batch along one side (in cell units)
QuadTreeNode* Terrain::World::mRootNode [private] |
Ogre::SceneNode* Terrain::World::mRootSceneNode [private] |
Ogre::SceneManager* Terrain::World::mSceneMgr [private] |
bool Terrain::World::mShaders [private] |
bool Terrain::World::mShadows [private] |
bool Terrain::World::mSplitShadows [private] |
Storage* Terrain::World::mStorage [private] |
std::map<int, Ogre::HardwareVertexBufferSharedPtr> Terrain::World::mUvBufferMap [private] |
int Terrain::World::mVisibilityFlags [private] |
bool Terrain::World::mVisible [private] |