OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Resource::SceneManager Class Reference

Handles loading and caching of scenes, e.g. .nif files or .osg files. More...

#include <scenemanager.hpp>

Inheritance diagram for Resource::SceneManager:
Collaboration diagram for Resource::SceneManager:

Public Member Functions

 SceneManager (const VFS::Manager *vfs, Resource::ImageManager *imageManager, Resource::NifFileManager *nifFileManager)
 
 ~SceneManager ()
 
Shader::ShaderManagergetShaderManager ()
 
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 changed. More...
 
void setForceShaders (bool force)
 
bool getForceShaders () const
 
void setClampLighting (bool clamp)
 
bool getClampLighting () const
 
void setForcePerPixelLighting (bool force)
 
bool getForcePerPixelLighting () const
 
void setAutoUseNormalMaps (bool use)
 
void setNormalMapPattern (const std::string &pattern)
 
void setNormalHeightMapPattern (const std::string &pattern)
 
void setAutoUseSpecularMaps (bool use)
 
void setSpecularMapPattern (const std::string &pattern)
 
void setShaderPath (const std::string &path)
 
osg::ref_ptr< const osg::Node > getTemplate (const std::string &name)
 
osg::ref_ptr< osg::Node > cacheInstance (const std::string &name)
 
osg::ref_ptr< osg::Node > getInstance (const std::string &name)
 
osg::ref_ptr< osg::Node > getInstance (const std::string &name, osg::Group *parentNode)
 
void attachTo (osg::Node *instance, osg::Group *parentNode) const
 
void releaseGLObjects (osg::State *state)
 
void setIncrementalCompileOperation (osgUtil::IncrementalCompileOperation *ico)
 Set up an IncrementalCompileOperation for background compiling of loaded scenes. More...
 
void notifyAttached (osg::Node *node) const
 
Resource::ImageManagergetImageManager ()
 
void setParticleSystemMask (unsigned int mask)
 
void setFilterSettings (const std::string &magfilter, const std::string &minfilter, const std::string &mipmap, int maxAnisotropy)
 
void applyFilterSettings (osg::Texture *tex)
 
void setUnRefImageDataAfterApply (bool unref)
 
virtual void updateCache (double referenceTime)
 
- Public Member Functions inherited from Resource::ResourceManager
 ResourceManager (const VFS::Manager *vfs)
 
virtual ~ResourceManager ()
 
void setExpiryDelay (double expiryDelay)
 How long to keep objects in cache after no longer being referenced. More...
 
const VFS::ManagergetVFS () const
 

Private Member Functions

osg::ref_ptr< osg::Node > createInstance (const std::string &name)
 
 SceneManager (const SceneManager &)
 
void operator= (const SceneManager &)
 

Private Attributes

std::auto_ptr
< Shader::ShaderManager
mShaderManager
 
bool mForceShaders
 
bool mClampLighting
 
bool mForcePerPixelLighting
 
bool mAutoUseNormalMaps
 
std::string mNormalMapPattern
 
std::string mNormalHeightMapPattern
 
bool mAutoUseSpecularMaps
 
std::string mSpecularMapPattern
 
osg::ref_ptr< MultiObjectCachemInstanceCache
 
OpenThreads::Mutex mSharedStateMutex
 
Resource::ImageManagermImageManager
 
Resource::NifFileManagermNifFileManager
 
osg::Texture::FilterMode mMinFilter
 
osg::Texture::FilterMode mMagFilter
 
int mMaxAnisotropy
 
bool mUnRefImageDataAfterApply
 
osg::ref_ptr
< osgUtil::IncrementalCompileOperation > 
mIncrementalCompileOperation
 
unsigned int mParticleSystemMask
 

Additional Inherited Members

- Protected Attributes inherited from Resource::ResourceManager
const VFS::ManagermVFS
 
osg::ref_ptr
< Resource::ObjectCache
mCache
 
double mExpiryDelay
 

Detailed Description

Handles loading and caching of scenes, e.g. .nif files or .osg files.

Note
Some methods of the scene manager can be used from any thread, see the methods documentation for more details.

Constructor & Destructor Documentation

Resource::SceneManager::SceneManager ( const VFS::Manager vfs,
Resource::ImageManager imageManager,
Resource::NifFileManager nifFileManager 
)
Resource::SceneManager::~SceneManager ( )
Resource::SceneManager::SceneManager ( const SceneManager )
private

Member Function Documentation

void Resource::SceneManager::applyFilterSettings ( osg::Texture *  tex)

Apply filter settings to the given texture. Note, when loading an object through this scene manager (i.e. calling getTemplate or createInstance) the filter settings are applied automatically. This method is provided for textures that were created outside of the SceneManager.

Here is the caller graph for this function:

void Resource::SceneManager::attachTo ( osg::Node *  instance,
osg::Group *  parentNode 
) const

Attach the given scene instance to the given parent node

Note
You should have the parentNode in its intended position before calling this method, so that world space particles of the instance get transformed correctly.
Assumes the given instance was not attached to any parents before.
Not thread safe, unless parentNode is not part of the main scene graph yet.

Here is the call graph for this function:

Here is the caller graph for this function:

osg::ref_ptr< osg::Node > Resource::SceneManager::cacheInstance ( const std::string &  name)

Create an instance of the given scene template and cache it for later use, so that future calls to getInstance() can simply return this cached object instead of creating a new one.

Note
The returned ref_ptr may be kept around by the caller to ensure that the object stays in cache for as long as needed.
Thread safe.

Here is the call graph for this function:

Here is the caller graph for this function:

osg::ref_ptr< osg::Node > Resource::SceneManager::createInstance ( const std::string &  name)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool Resource::SceneManager::getClampLighting ( ) const

Here is the caller graph for this function:

bool Resource::SceneManager::getForcePerPixelLighting ( ) const

Here is the caller graph for this function:

bool Resource::SceneManager::getForceShaders ( ) const

Here is the caller graph for this function:

Resource::ImageManager * Resource::SceneManager::getImageManager ( )

Here is the caller graph for this function:

osg::ref_ptr< osg::Node > Resource::SceneManager::getInstance ( const std::string &  name)

Get an instance of the given scene template

See Also
getTemplate
Note
Thread safe.

Here is the call graph for this function:

Here is the caller graph for this function:

osg::ref_ptr< osg::Node > Resource::SceneManager::getInstance ( const std::string &  name,
osg::Group *  parentNode 
)

Get an instance of the given scene template and immediately attach it to a parent node

See Also
getTemplate
Note
Not thread safe, unless parentNode is not part of the main scene graph yet.

Here is the call graph for this function:

Shader::ShaderManager & Resource::SceneManager::getShaderManager ( )

Here is the caller graph for this function:

osg::ref_ptr< const osg::Node > Resource::SceneManager::getTemplate ( const std::string &  name)

Get a read-only copy of this scene "template"

Note
If the given filename does not exist or fails to load, an error marker mesh will be used instead. If even the error marker mesh can not be found, an exception is thrown.
Thread safe.

Here is the call graph for this function:

Here is the caller graph for this function:

void Resource::SceneManager::notifyAttached ( osg::Node *  node) const
Note
SceneManager::attachTo calls this method automatically, only needs to be called by users if manually attaching

Here is the caller graph for this function:

void Resource::SceneManager::operator= ( const SceneManager )
private
void Resource::SceneManager::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 changed.

Here is the call graph for this function:

Here is the caller graph for this function:

void Resource::SceneManager::releaseGLObjects ( osg::State *  state)

Manually release created OpenGL objects for the given graphics context. This may be required in cases where multiple contexts are used over the lifetime of the application.

void Resource::SceneManager::setAutoUseNormalMaps ( bool  use)
See Also
ShaderVisitor::setAutoUseNormalMaps

Here is the caller graph for this function:

void Resource::SceneManager::setAutoUseSpecularMaps ( bool  use)

Here is the caller graph for this function:

void Resource::SceneManager::setClampLighting ( bool  clamp)
See Also
ShaderVisitor::setClampLighting

Here is the caller graph for this function:

void Resource::SceneManager::setFilterSettings ( const std::string &  magfilter,
const std::string &  minfilter,
const std::string &  mipmap,
int  maxAnisotropy 
)
Warning
It is unsafe to call this method while the draw thread is using textures! call Viewer::stopThreading first.

Here is the caller graph for this function:

void Resource::SceneManager::setForcePerPixelLighting ( bool  force)
See Also
ShaderVisitor::setForcePerPixelLighting

Here is the caller graph for this function:

void Resource::SceneManager::setForceShaders ( bool  force)
See Also
ShaderVisitor::setForceShaders

Here is the caller graph for this function:

void Resource::SceneManager::setIncrementalCompileOperation ( osgUtil::IncrementalCompileOperation *  ico)

Set up an IncrementalCompileOperation for background compiling of loaded scenes.

Here is the caller graph for this function:

void Resource::SceneManager::setNormalHeightMapPattern ( const std::string &  pattern)
See Also
ShaderVisitor::setNormalHeightMapPattern

Here is the caller graph for this function:

void Resource::SceneManager::setNormalMapPattern ( const std::string &  pattern)
See Also
ShaderVisitor::setNormalMapPattern

Here is the caller graph for this function:

void Resource::SceneManager::setParticleSystemMask ( unsigned int  mask)
Parameters
maskThe node mask to apply to loaded particle system nodes.

Here is the caller graph for this function:

void Resource::SceneManager::setShaderPath ( const std::string &  path)

Here is the caller graph for this function:

void Resource::SceneManager::setSpecularMapPattern ( const std::string &  pattern)

Here is the caller graph for this function:

void Resource::SceneManager::setUnRefImageDataAfterApply ( bool  unref)

Keep a copy of the texture data around in system memory? This is needed when using multiple graphics contexts, otherwise should be disabled to reduce memory usage.

void Resource::SceneManager::updateCache ( double  referenceTime)
virtual
See Also
ResourceManager::updateCache

Reimplemented from Resource::ResourceManager.

Here is the call graph for this function:

Member Data Documentation

bool Resource::SceneManager::mAutoUseNormalMaps
private
bool Resource::SceneManager::mAutoUseSpecularMaps
private
bool Resource::SceneManager::mClampLighting
private
bool Resource::SceneManager::mForcePerPixelLighting
private
bool Resource::SceneManager::mForceShaders
private
Resource::ImageManager* Resource::SceneManager::mImageManager
private
osg::ref_ptr<osgUtil::IncrementalCompileOperation> Resource::SceneManager::mIncrementalCompileOperation
private
osg::ref_ptr<MultiObjectCache> Resource::SceneManager::mInstanceCache
private
osg::Texture::FilterMode Resource::SceneManager::mMagFilter
private
int Resource::SceneManager::mMaxAnisotropy
private
osg::Texture::FilterMode Resource::SceneManager::mMinFilter
private
Resource::NifFileManager* Resource::SceneManager::mNifFileManager
private
std::string Resource::SceneManager::mNormalHeightMapPattern
private
std::string Resource::SceneManager::mNormalMapPattern
private
unsigned int Resource::SceneManager::mParticleSystemMask
private
std::auto_ptr<Shader::ShaderManager> Resource::SceneManager::mShaderManager
private
OpenThreads::Mutex Resource::SceneManager::mSharedStateMutex
private
std::string Resource::SceneManager::mSpecularMapPattern
private
bool Resource::SceneManager::mUnRefImageDataAfterApply
private

The documentation for this class was generated from the following files: