OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
world.hpp
Go to the documentation of this file.
1 #ifndef COMPONENTS_TERRAIN_WORLD_H
2 #define COMPONENTS_TERRAIN_WORLD_H
3 
4 #include <osg/ref_ptr>
5 #include <osg/Referenced>
6 #include <osg/Vec3f>
7 
8 #include <memory>
9 #include <set>
10 
11 #include "defs.hpp"
12 #include "cellborder.hpp"
13 
14 namespace osg
15 {
16  class Group;
17  class Stats;
18  class Node;
19  class Object;
20 }
21 
22 namespace Resource
23 {
24  class ResourceSystem;
25 }
26 
27 namespace Terrain
28 {
29  class Storage;
30 
31  class TextureManager;
32  class ChunkManager;
33  class CompositeMapRenderer;
34 
39  class View : public osg::Referenced
40  {
41  public:
42  virtual ~View() {}
43 
45  virtual void reset(unsigned int frame) = 0;
46  };
47 
52  class World
53  {
54  public:
59  World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask);
60  virtual ~World();
61 
63  void setTargetFrameRate(float rate);
64 
68 
69  float getHeightAt (const osg::Vec3f& worldPos);
70 
73  virtual void clearAssociatedCaches();
74 
77  virtual void cacheCell(View* view, int x, int y) {}
78 
81  virtual void loadCell(int x, int y);
82 
85  virtual void unloadCell(int x, int y);
86 
87  virtual void enable(bool enabled) {}
88 
89  virtual void setBordersVisible(bool visible);
90 
93  virtual View* createView() { return NULL; }
94 
96  virtual void preload(View* view, const osg::Vec3f& eyePoint) {}
97 
98  virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) {}
99 
101  virtual void setDefaultViewer(osg::Object* obj) {}
102 
103  Storage* getStorage() { return mStorage; }
104 
105  protected:
107 
108  osg::ref_ptr<osg::Group> mParent;
109  osg::ref_ptr<osg::Group> mTerrainRoot;
110 
111  osg::ref_ptr<osg::Group> mCompositeMapCamera;
112  osg::ref_ptr<CompositeMapRenderer> mCompositeMapRenderer;
113 
115 
116  std::unique_ptr<TextureManager> mTextureManager;
117  std::unique_ptr<ChunkManager> mChunkManager;
118 
119  std::unique_ptr<MWRender::CellBorder> mCellBorder;
120 
122 
123  std::set<std::pair<int,int>> mLoadedCells;
124  };
125 }
126 
127 #endif
std::unique_ptr< TextureManager > mTextureManager
Definition: world.hpp:116
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:30
void updateTextureFiltering()
Definition: world.cpp:108
virtual void loadCell(int x, int y)
Definition: world.cpp:82
std::unique_ptr< ChunkManager > mChunkManager
Definition: world.hpp:117
The basic interface for a terrain world. How the terrain chunks are paged and displayed is up to the ...
Definition: world.hpp:52
virtual void clearAssociatedCaches()
Definition: world.cpp:113
std::set< std::pair< int, int > > mLoadedCells
Definition: world.hpp:123
virtual void reportStats(unsigned int frameNumber, osg::Stats *stats)
Definition: world.hpp:98
std::unique_ptr< MWRender::CellBorder > mCellBorder
Definition: world.hpp:119
virtual void cacheCell(View *view, int x, int y)
Definition: world.hpp:77
void setTargetFrameRate(float rate)
See CompositeMapRenderer::setTargetFrameRate.
Definition: world.cpp:98
Storage * mStorage
Definition: world.hpp:106
virtual void setBordersVisible(bool visible)
Definition: world.cpp:69
virtual void unloadCell(int x, int y)
Definition: world.cpp:90
World(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int nodeMask, int preCompileMask, int borderMask)
Definition: world.cpp:17
Definition: storage.hpp:22
virtual ~World()
Definition: world.cpp:56
osg::ref_ptr< osg::Group > mTerrainRoot
Definition: world.hpp:109
virtual View * createView()
Definition: world.hpp:93
A View is a collection of rendering objects that are visible from a given camera/intersection. The base View class is part of the interface for usage in conjunction with preload feature.
Definition: world.hpp:39
osg::ref_ptr< osg::Group > mCompositeMapCamera
Definition: world.hpp:111
Resource::ResourceSystem * mResourceSystem
Definition: world.hpp:114
virtual void preload(View *view, const osg::Vec3f &eyePoint)
Definition: world.hpp:96
virtual void setDefaultViewer(osg::Object *obj)
Set the default viewer (usually a Camera), used as viewpoint for any viewers that don't use their own...
Definition: world.hpp:101
Storage * getStorage()
Definition: world.hpp:103
virtual void reset(unsigned int frame)=0
Reset internal structure so that the next addition to the view will override the previous frame's con...
virtual void enable(bool enabled)
Definition: world.hpp:87
osg::ref_ptr< CompositeMapRenderer > mCompositeMapRenderer
Definition: world.hpp:112
bool mBorderVisible
Definition: world.hpp:121
float getHeightAt(const osg::Vec3f &worldPos)
Definition: world.cpp:103
virtual ~View()
Definition: world.hpp:42
osg::ref_ptr< osg::Group > mParent
Definition: world.hpp:108