OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
terraingrid.hpp
Go to the documentation of this file.
1 #ifndef COMPONENTS_TERRAIN_TERRAINGRID_H
2 #define COMPONENTS_TERRAIN_TERRAINGRID_H
3 
4 #include <osg/Vec2f>
5 
6 #include "world.hpp"
7 
8 namespace SceneUtil
9 {
10  class UnrefQueue;
11 }
12 
13 namespace Shader
14 {
15  class ShaderManager;
16 }
17 
18 namespace osg
19 {
20  class Texture2D;
21 }
22 
23 namespace Terrain
24 {
25 
27  class TerrainGrid : public Terrain::World
28  {
29  public:
30  TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask, Shader::ShaderManager* shaderManager = NULL, SceneUtil::UnrefQueue* unrefQueue = NULL);
31  ~TerrainGrid();
32 
36  virtual osg::ref_ptr<osg::Node> cacheCell(int x, int y);
37 
39  virtual void loadCell(int x, int y);
40 
42  virtual void unloadCell(int x, int y);
43 
46  void updateCache();
47 
51 
52  private:
53  osg::ref_ptr<osg::Node> buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter);
54 
55  // split each ESM::Cell into mNumSplits*mNumSplits terrain chunks
56  unsigned int mNumSplits;
57 
58  typedef std::map<std::string, osg::ref_ptr<osg::Texture2D> > TextureCache;
60  OpenThreads::Mutex mTextureCacheMutex;
61 
62  typedef std::map<std::pair<int, int>, osg::ref_ptr<osg::Node> > Grid;
64 
66  OpenThreads::Mutex mGridCacheMutex;
67 
69 
70  osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;
71 
73  };
74 
75 }
76 
77 #endif
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:24
Simple terrain implementation that loads cells in a grid, with no LOD.
Definition: terraingrid.hpp:27
The basic interface for a terrain world. How the terrain chunks are paged and displayed is up to the ...
Definition: world.hpp:32
Shader::ShaderManager * mShaderManager
Definition: terraingrid.hpp:72
std::map< std::string, osg::ref_ptr< osg::Texture2D > > TextureCache
Definition: terraingrid.hpp:58
Implements creation and caching of vertex buffers for terrain chunks.
Definition: buffercache.hpp:14
unsigned int mNumSplits
Definition: terraingrid.hpp:56
osg::ref_ptr< osg::Node > buildTerrain(osg::Group *parent, float chunkSize, const osg::Vec2f &chunkCenter)
Definition: terraingrid.cpp:87
OpenThreads::Mutex mGridCacheMutex
Definition: terraingrid.hpp:66
We keep storage of terrain data abstract here since we need different implementations for game and ed...
Definition: storage.hpp:21
Grid mGrid
Definition: terraingrid.hpp:63
virtual void loadCell(int x, int y)
Definition: terraingrid.cpp:238
void updateTextureFiltering()
Definition: terraingrid.cpp:310
Reads shader template files and turns them into a concrete shader, based on a list of define's...
Definition: shadermanager.hpp:18
void updateCache()
Definition: terraingrid.cpp:285
osg::ref_ptr< SceneUtil::UnrefQueue > mUnrefQueue
Definition: terraingrid.hpp:70
OpenThreads::Mutex mTextureCacheMutex
Definition: terraingrid.hpp:60
Grid mGridCache
Definition: terraingrid.hpp:65
BufferCache mCache
Definition: terraingrid.hpp:68
~TerrainGrid()
Definition: terraingrid.cpp:64
TerrainGrid(osg::Group *parent, Resource::ResourceSystem *resourceSystem, osgUtil::IncrementalCompileOperation *ico, Storage *storage, int nodeMask, Shader::ShaderManager *shaderManager=NULL, SceneUtil::UnrefQueue *unrefQueue=NULL)
Definition: terraingrid.cpp:52
virtual void unloadCell(int x, int y)
Definition: terraingrid.cpp:270
Handles unreferencing of objects through the WorkQueue. Typical use scenario would be the main thread...
Definition: unrefqueue.hpp:19
TextureCache mTextureCache
Definition: terraingrid.hpp:59
std::map< std::pair< int, int >, osg::ref_ptr< osg::Node > > Grid
Definition: terraingrid.hpp:62
virtual osg::ref_ptr< osg::Node > cacheCell(int x, int y)
Definition: terraingrid.cpp:72