Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# irr::scene::IMeshCache Class Reference

The mesh cache stores already loaded meshes and provides an interface to them. More...

`#include <IMeshCache.h>`

Inheritance diagram for irr::scene::IMeshCache:

List of all members.

## Public Member Functions
virtual void | addMesh (const io::path &filename, IAnimatedMesh *mesh)=0
| Adds a mesh to the internal list of loaded meshes.
virtual void | clear ()=0
| Clears the whole mesh cache, removing all meshes.
virtual void | clearUnusedMeshes ()=0
| Clears all meshes that are held in the mesh cache but not used anywhere else.
virtual IAnimatedMesh * | getMeshByFilename (const io::path &filename)=0
| Returns a mesh based on its filename.
virtual IAnimatedMesh * | getMeshByIndex (u32 index)=0
| Returns a mesh based on its index number.
virtual u32 | getMeshCount () const =0
| Returns amount of loaded meshes in the cache.
virtual const io::path & | getMeshFilename (const IMesh *const mesh) const =0
| Get the filename of a loaded mesh, if there is any.
virtual const io::path & | getMeshFilename (const IAnimatedMesh *const mesh) const =0
| Get the filename of a loaded mesh, if there is any.
virtual const io::path & | getMeshFilename (u32 index) const =0
| Get the filename of a loaded mesh, based on its index.
virtual s32 | getMeshIndex (const IMesh *const mesh) const =0
| Returns current index number of the mesh, and -1 if it is not in the cache.
virtual s32 | getMeshIndex (const IAnimatedMesh *const mesh) const =0
| Returns current index number of the mesh, and -1 if it is not in the cache.
virtual bool | isMeshLoaded (const io::path &filename)=0
| Check if a mesh was already loaded.
virtual void | removeMesh (const IMesh *const mesh)=0
| Removes a mesh from the cache.
virtual void | removeMesh (const IAnimatedMesh *const mesh)=0
| Removes a mesh from the cache.
virtual bool | setMeshFilename (const IMesh *const mesh, const io::path &filename)=0
| Renames a loaded mesh.
virtual bool | setMeshFilename (const IAnimatedMesh *const mesh, const io::path &filename)=0
| Renames a loaded mesh.
virtual bool | setMeshFilename (u32 index, const io::path &filename)=0
| Renames a loaded mesh.
virtual | ~IMeshCache ()
| Destructor.

## Detailed Description

The mesh cache stores already loaded meshes and provides an interface to them.

You can access it using ISceneManager::getMeshCache(). All existing scene managers will return a pointer to the same mesh cache, because it is shared between them. With this interface, it is possible to manually add new loaded meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate through already loaded meshes.

Definition at line 27 of file IMeshCache.h.

## Constructor & Destructor Documentation

virtual irr::scene::IMeshCache::~IMeshCache | ( |  | ) | `[inline, virtual]`

Destructor.

Definition at line 32 of file IMeshCache.h.

## Member Function Documentation

virtual void irr::scene::IMeshCache::addMesh | ( | const io::path & | filename,
|  | IAnimatedMesh * | mesh |
| ) |  |  | `[pure virtual]`

Adds a mesh to the internal list of loaded meshes.

Usually, ISceneManager::getMesh() is called to load a mesh from a file. That method searches the list of loaded meshes if a mesh has already been loaded and returns a pointer to if it is in that list and already in memory. Otherwise it loads the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already has been loaded. This method can be used for example by mesh loaders who need to load more than one mesh with one call. They can add additional meshes with this method to the scene manager. The COLLADA loader for example uses this method.

Parameters:

  | filename | Filename of the mesh. When calling ISceneManager::getMesh() with this name it will return the mesh set by this method.
  | mesh | Pointer to a mesh which will now be referenced by this name.

virtual void irr::scene::IMeshCache::clear | ( |  | ) | `[pure virtual]`

Clears the whole mesh cache, removing all meshes.

All meshes will be reloaded completely when using ISceneManager::getMesh() after calling this method. Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh() and you did not grab them, then they may become invalid.

virtual void irr::scene::IMeshCache::clearUnusedMeshes | ( |  | ) | `[pure virtual]`

Clears all meshes that are held in the mesh cache but not used anywhere else.

Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh() and you did not grab them, then they may become invalid.

virtual IAnimatedMesh* irr::scene::IMeshCache::getMeshByFilename | ( | const io::path & | filename | ) | `[pure virtual]`

Returns a mesh based on its filename.

Parameters:

  | filename | Name of the mesh.

Returns:
  Pointer to the mesh or 0 if there is none with this number.

virtual IAnimatedMesh* irr::scene::IMeshCache::getMeshByIndex | ( | u32 | index | ) | `[pure virtual]`

Returns a mesh based on its index number.

Parameters:

  | index,: | Index of the mesh, number between 0 and getMeshCount()-1. Note that this number is only valid until a new mesh is loaded or removed.

Returns:
  Pointer to the mesh or 0 if there is none with this number.

virtual u32 irr::scene::IMeshCache::getMeshCount | ( |  | ) | const`[pure virtual]`

Returns amount of loaded meshes in the cache.

You can load new meshes into the cache using getMesh() and addMesh(). If you ever need to access the internal mesh cache, you can do this using removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename().

Returns:
  Number of meshes in cache.

virtual const io::path& irr::scene::IMeshCache::getMeshFilename | ( | const IMesh *const | mesh | ) | const`[pure virtual]`

Get the filename of a loaded mesh, if there is any.

Parameters:

  | mesh | Pointer to mesh to query.

Returns:
  String with name if mesh was found and has a name, else 0.

virtual const io::path& irr::scene::IMeshCache::getMeshFilename | ( | const IAnimatedMesh *const | mesh | ) | const`[pure virtual]`

Get the filename of a loaded mesh, if there is any.

Parameters:

  | mesh | Pointer to mesh to query.

Returns:
  String with name if mesh was found and has a name, else 0.

virtual const io::path& irr::scene::IMeshCache::getMeshFilename | ( | u32 | index | ) | const`[pure virtual]`

Get the filename of a loaded mesh, based on its index.

Parameters:

  | index,: | Index of the mesh, number between 0 and getMeshCount()-1.

Returns:
  String with name if mesh was found and has a name, else 0.

virtual s32 irr::scene::IMeshCache::getMeshIndex | ( | const IMesh *const | mesh | ) | const`[pure virtual]`

Returns current index number of the mesh, and -1 if it is not in the cache.

Parameters:

  | mesh | Pointer to the mesh to search for.

Returns:
  Index of the mesh in the cache, or -1 if not found.

virtual s32 irr::scene::IMeshCache::getMeshIndex | ( | const IAnimatedMesh *const | mesh | ) | const`[pure virtual]`

Returns current index number of the mesh, and -1 if it is not in the cache.

Parameters:

  | mesh | Pointer to the mesh to search for.

Returns:
  Index of the mesh in the cache, or -1 if not found.

virtual bool irr::scene::IMeshCache::isMeshLoaded | ( | const io::path & | filename | ) | `[pure virtual]`

Check if a mesh was already loaded.

Parameters:

  | filename | Name of the mesh.

Returns:
  True if the mesh has been loaded, else false.

virtual void irr::scene::IMeshCache::removeMesh | ( | const IMesh *const | mesh | ) | `[pure virtual]`

Removes a mesh from the cache.

After loading a mesh with getMesh(), the mesh can be removed from the cache using this method, freeing a lot of memory.

Parameters:

  | mesh | Pointer to the mesh which shall be removed.

virtual void irr::scene::IMeshCache::removeMesh | ( | const IAnimatedMesh *const | mesh | ) | `[pure virtual]`

Removes a mesh from the cache.

After loading a mesh with getMesh(), the mesh can be removed from the cache using this method, freeing a lot of memory.

Parameters:

  | mesh | Pointer to the mesh which shall be removed.

virtual bool irr::scene::IMeshCache::setMeshFilename | ( | const IMesh *const | mesh,
|  | const io::path & | filename |
| ) |  |  | `[pure virtual]`

Renames a loaded mesh.

Note that renaming meshes might change the ordering of the meshes, and so the index of the meshes as returned by getMeshIndex() or taken by some methods will change.

Parameters:

  | mesh | Mesh to be renamed.
  | filename | New name for the mesh.

Returns:
  True if mesh was renamed.

virtual bool irr::scene::IMeshCache::setMeshFilename | ( | const IAnimatedMesh *const | mesh,
|  | const io::path & | filename |
| ) |  |  | `[pure virtual]`

Renames a loaded mesh.

Note that renaming meshes might change the ordering of the meshes, and so the index of the meshes as returned by getMeshIndex() or taken by some methods will change.

Parameters:

  | mesh | Mesh to be renamed.
  | filename | New name for the mesh.

Returns:
  True if mesh was renamed.

virtual bool irr::scene::IMeshCache::setMeshFilename | ( | u32 | index,
|  | const io::path & | filename |
| ) |  |  | `[pure virtual]`

Renames a loaded mesh.

Note that renaming meshes might change the ordering of the meshes, and so the index of the meshes as returned by getMeshIndex() or taken by some methods will change.

Parameters:

  | index | The index of the mesh in the cache.
  | filename | New name for the mesh.

Returns:
  True if mesh was renamed.

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

- IMeshCache.h

| The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:13 2010 by Doxygen (1.5.6)