OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
scenemanager.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_RESOURCE_SCENEMANAGER_H
2 #define OPENMW_COMPONENTS_RESOURCE_SCENEMANAGER_H
3 
4 #include <string>
5 #include <map>
6 #include <memory>
7 
8 #include <osg/ref_ptr>
9 #include <osg/Node>
10 #include <osg/Texture>
11 
12 #include "resourcemanager.hpp"
13 
14 namespace Resource
15 {
16  class ImageManager;
17  class NifFileManager;
18 }
19 
20 namespace osgUtil
21 {
22  class IncrementalCompileOperation;
23 }
24 
25 namespace Shader
26 {
27  class ShaderManager;
28 }
29 
30 namespace Resource
31 {
32 
33  class MultiObjectCache;
34 
38  {
39  public:
40  SceneManager(const VFS::Manager* vfs, Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager);
41  ~SceneManager();
42 
44 
46  void recreateShaders(osg::ref_ptr<osg::Node> node);
47 
49  void setForceShaders(bool force);
50  bool getForceShaders() const;
51 
53  void setClampLighting(bool clamp);
54  bool getClampLighting() const;
55 
57  void setForcePerPixelLighting(bool force);
58  bool getForcePerPixelLighting() const;
59 
61  void setAutoUseNormalMaps(bool use);
62 
64  void setNormalMapPattern(const std::string& pattern);
65 
67  void setNormalHeightMapPattern(const std::string& pattern);
68 
69  void setAutoUseSpecularMaps(bool use);
70 
71  void setSpecularMapPattern(const std::string& pattern);
72 
73  void setShaderPath(const std::string& path);
74 
79  osg::ref_ptr<const osg::Node> getTemplate(const std::string& name);
80 
85  osg::ref_ptr<osg::Node> cacheInstance(const std::string& name);
86 
90  osg::ref_ptr<osg::Node> getInstance(const std::string& name);
91 
95  osg::ref_ptr<osg::Node> getInstance(const std::string& name, osg::Group* parentNode);
96 
102  void attachTo(osg::Node* instance, osg::Group* parentNode) const;
103 
106  void releaseGLObjects(osg::State* state);
107 
109  void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation* ico);
110 
112  void notifyAttached(osg::Node* node) const;
113 
115 
117  void setParticleSystemMask(unsigned int mask);
118 
120  void setFilterSettings(const std::string &magfilter, const std::string &minfilter,
121  const std::string &mipmap, int maxAnisotropy);
122 
125  void applyFilterSettings (osg::Texture* tex);
126 
129  void setUnRefImageDataAfterApply(bool unref);
130 
132  virtual void updateCache(double referenceTime);
133 
134  private:
135 
136  osg::ref_ptr<osg::Node> createInstance(const std::string& name);
137 
138  std::auto_ptr<Shader::ShaderManager> mShaderManager;
143  std::string mNormalMapPattern;
146  std::string mSpecularMapPattern;
147 
148  osg::ref_ptr<MultiObjectCache> mInstanceCache;
149 
150  OpenThreads::Mutex mSharedStateMutex;
151 
154 
155  osg::Texture::FilterMode mMinFilter;
156  osg::Texture::FilterMode mMagFilter;
159 
160  osg::ref_ptr<osgUtil::IncrementalCompileOperation> mIncrementalCompileOperation;
161 
162  unsigned int mParticleSystemMask;
163 
164  SceneManager(const SceneManager&);
165  void operator = (const SceneManager&);
166  };
167 
168 }
169 
170 #endif
Shader::ShaderManager & getShaderManager()
Definition: scenemanager.cpp:264
void releaseGLObjects(osg::State *state)
Definition: scenemanager.cpp:453
std::string mNormalMapPattern
Definition: scenemanager.hpp:143
void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation *ico)
Set up an IncrementalCompileOperation for background compiling of loaded scenes.
Definition: scenemanager.cpp:459
Resource::ImageManager * mImageManager
Definition: scenemanager.hpp:152
bool mAutoUseNormalMaps
Definition: scenemanager.hpp:142
void setClampLighting(bool clamp)
Definition: scenemanager.cpp:214
Handles loading and caching of scenes, e.g. .nif files or .osg files.
Definition: scenemanager.hpp:37
void operator=(const SceneManager &)
void setAutoUseNormalMaps(bool use)
Definition: scenemanager.cpp:234
void setSpecularMapPattern(const std::string &pattern)
Definition: scenemanager.cpp:254
void setFilterSettings(const std::string &magfilter, const std::string &minfilter, const std::string &mipmap, int maxAnisotropy)
Definition: scenemanager.cpp:480
osg::ref_ptr< MultiObjectCache > mInstanceCache
Definition: scenemanager.hpp:148
~SceneManager()
Definition: scenemanager.cpp:259
void notifyAttached(osg::Node *node) const
Definition: scenemanager.cpp:464
void setAutoUseSpecularMaps(bool use)
Definition: scenemanager.cpp:249
void setShaderPath(const std::string &path)
Definition: scenemanager.cpp:269
void applyFilterSettings(osg::Texture *tex)
Definition: scenemanager.cpp:524
void setNormalMapPattern(const std::string &pattern)
Definition: scenemanager.cpp:239
bool getForceShaders() const
Definition: scenemanager.cpp:199
void setParticleSystemMask(unsigned int mask)
Definition: scenemanager.cpp:475
std::string mNormalHeightMapPattern
Definition: scenemanager.hpp:144
osg::ref_ptr< const osg::Node > getTemplate(const std::string &name)
Definition: scenemanager.cpp:339
Handles loading/caching of Images.
Definition: imagemanager.hpp:23
osg::ref_ptr< osg::Node > getInstance(const std::string &name)
Definition: scenemanager.cpp:427
SceneManager(const VFS::Manager *vfs, Resource::ImageManager *imageManager, Resource::NifFileManager *nifFileManager)
Definition: scenemanager.cpp:175
osg::ref_ptr< osgUtil::IncrementalCompileOperation > mIncrementalCompileOperation
Definition: scenemanager.hpp:160
bool getClampLighting() const
Definition: scenemanager.cpp:219
std::auto_ptr< Shader::ShaderManager > mShaderManager
Definition: scenemanager.hpp:138
bool mForceShaders
Definition: scenemanager.hpp:139
osg::ref_ptr< osg::Node > cacheInstance(const std::string &name)
Definition: scenemanager.cpp:406
bool mForcePerPixelLighting
Definition: scenemanager.hpp:141
unsigned int mParticleSystemMask
Definition: scenemanager.hpp:162
Reads shader template files and turns them into a concrete shader, based on a list of define's...
Definition: shadermanager.hpp:18
bool mUnRefImageDataAfterApply
Definition: scenemanager.hpp:158
Resource::ImageManager * getImageManager()
Definition: scenemanager.cpp:470
bool mClampLighting
Definition: scenemanager.hpp:140
void setUnRefImageDataAfterApply(bool unref)
Definition: scenemanager.cpp:531
bool getForcePerPixelLighting() const
Definition: scenemanager.cpp:229
std::string mSpecularMapPattern
Definition: scenemanager.hpp:146
Handles caching of NIFFiles.
Definition: niffilemanager.hpp:15
osg::Texture::FilterMode mMinFilter
Definition: scenemanager.hpp:155
State
Definition: state.hpp:6
osg::ref_ptr< osg::Node > createInstance(const std::string &name)
Definition: scenemanager.cpp:416
virtual void updateCache(double referenceTime)
Definition: scenemanager.cpp:536
void recreateShaders(osg::ref_ptr< osg::Node > node)
Re-create shaders for this node, need to call this if texture stages or vertex color mode have change...
Definition: scenemanager.cpp:204
The main class responsible for loading files from a virtual file system.
Definition: manager.hpp:20
osg::Texture::FilterMode mMagFilter
Definition: scenemanager.hpp:156
void setNormalHeightMapPattern(const std::string &pattern)
Definition: scenemanager.cpp:244
OpenThreads::Mutex mSharedStateMutex
Definition: scenemanager.hpp:150
Base class for managers that require a virtual file system and object cache.
Definition: resourcemanager.hpp:17
Resource::NifFileManager * mNifFileManager
Definition: scenemanager.hpp:153
void attachTo(osg::Node *instance, osg::Group *parentNode) const
Definition: scenemanager.cpp:447
void setForcePerPixelLighting(bool force)
Definition: scenemanager.cpp:224
void setForceShaders(bool force)
Definition: scenemanager.cpp:194
int mMaxAnisotropy
Definition: scenemanager.hpp:157
bool mAutoUseSpecularMaps
Definition: scenemanager.hpp:145
const char * name
Definition: crashcatcher.cpp:59