Jimcpp 2.1.0
Jimcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
jpp::scene::IMeshCache Class Referenceabstract

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

#include <jimcpp/core/engine/IMeshCache.hpp>

Inheritance diagram for jpp::scene::IMeshCache:
Inheritance graph
Collaboration diagram for jpp::scene::IMeshCache:
Collaboration graph

Public Member Functions

virtual ~IMeshCache ()
 Destructor.
 
virtual void addMesh (const io::path &name, IAnimatedMesh *mesh)=0
 Adds a mesh to the internal list of loaded meshes.
 
virtual void removeMesh (const IMesh *const mesh)=0
 Removes the mesh from the cache.
 
virtual u32 getMeshCount () const =0
 Returns amount of loaded meshes in the cache.
 
virtual s32 getMeshIndex (const IMesh *const mesh) const =0
 Returns current index number of the mesh or -1 when not found.
 
virtual IAnimatedMeshgetMeshByIndex (u32 index)=0
 Returns a mesh based on its index number.
 
JPP_DEPRECATED IAnimatedMeshgetMeshByFilename (const io::path &filename)
 Returns a mesh based on its name (often a filename).
 
JPP_DEPRECATED const io::pathgetMeshFilename (u32 index) const
 Get the name of a loaded mesh, based on its index. (Name is often identical to the filename).
 
JPP_DEPRECATED const io::pathgetMeshFilename (const IMesh *const mesh) const
 Get the name of a loaded mesh, if there is any. (Name is often identical to the filename).
 
JPP_DEPRECATED bool setMeshFilename (u32 index, const io::path &filename)
 Renames a loaded mesh.
 
JPP_DEPRECATED bool setMeshFilename (const IMesh *const mesh, const io::path &filename)
 Renames a loaded mesh.
 
virtual IAnimatedMeshgetMeshByName (const io::path &name)=0
 Returns a mesh based on its name.
 
virtual const io::SNamedPathgetMeshName (u32 index) const =0
 Get the name of a loaded mesh, based on its index.
 
virtual const io::SNamedPathgetMeshName (const IMesh *const mesh) const =0
 Get the name of the loaded mesh if there is any.
 
virtual bool renameMesh (u32 index, const io::path &name)=0
 Renames a loaded mesh.
 
virtual bool renameMesh (const IMesh *const mesh, const io::path &name)=0
 Renames the loaded mesh.
 
virtual bool isMeshLoaded (const io::path &name)=0
 Check if a mesh was already loaded.
 
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.
 
- Public Member Functions inherited from jpp::IReferenceCounted
 IReferenceCounted ()
 Constructor.
 
virtual ~IReferenceCounted ()
 Destructor.
 
void grab () const
 Grabs the object. Increments the reference counter by one.
 
bool drop () const
 Drops the object. Decrements the reference counter by one.
 
s32 getReferenceCount () const
 Get the reference count.
 
const c8getDebugName () const
 Returns the debug name of the object.
 

Additional Inherited Members

- Protected Member Functions inherited from jpp::IReferenceCounted
void setDebugName (const c8 *newName)
 Sets the debug name of the object.
 

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.

Member Function Documentation

◆ addMesh()

virtual void jpp::scene::IMeshCache::addMesh ( const io::path name,
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
nameName of the mesh. When calling ISceneManager::getMesh() with this name it will return the mesh set by this method.
meshPointer to a mesh which will now be referenced by this name.

◆ clear()

virtual void jpp::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.

◆ clearUnusedMeshes()

virtual void jpp::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.

◆ getMeshByFilename()

JPP_DEPRECATED IAnimatedMesh * jpp::scene::IMeshCache::getMeshByFilename ( const io::path filename)
inline

Returns a mesh based on its name (often a filename).

Deprecated:
Use getMeshByName() instead. This method may be removed by Jimcpp 1.9

◆ getMeshByIndex()

virtual IAnimatedMesh * jpp::scene::IMeshCache::getMeshByIndex ( u32  index)
pure virtual

Returns a mesh based on its index number.

Parameters
indexIndex 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.

◆ getMeshByName()

virtual IAnimatedMesh * jpp::scene::IMeshCache::getMeshByName ( const io::path name)
pure virtual

Returns a mesh based on its name.

Parameters
nameName of the mesh. Usually a filename.
Returns
Pointer to the mesh or 0 if there is none with this number.

◆ getMeshCount()

virtual u32 jpp::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 getMeshName().

Returns
Number of meshes in cache.

◆ getMeshFilename() [1/2]

JPP_DEPRECATED const io::path & jpp::scene::IMeshCache::getMeshFilename ( const IMesh *const  mesh) const
inline

Get the name of a loaded mesh, if there is any. (Name is often identical to the filename).

Deprecated:
Use getMeshName() instead. This method may be removed by Jimcpp 1.9

◆ getMeshFilename() [2/2]

JPP_DEPRECATED const io::path & jpp::scene::IMeshCache::getMeshFilename ( u32  index) const
inline

Get the name of a loaded mesh, based on its index. (Name is often identical to the filename).

Deprecated:
Use getMeshName() instead. This method may be removed by Jimcpp 1.9

◆ getMeshIndex()

virtual s32 jpp::scene::IMeshCache::getMeshIndex ( const IMesh *const  mesh) const
pure virtual

Returns current index number of the mesh or -1 when not found.

Parameters
meshPointer to the mesh to search for.
Returns
Index of the mesh in the cache, or -1 if not found.

◆ getMeshName() [1/2]

virtual const io::SNamedPath & jpp::scene::IMeshCache::getMeshName ( const IMesh *const  mesh) const
pure virtual

Get the name of the loaded mesh if there is any.

Parameters
meshPointer to mesh to query.
Returns
The name if mesh was found and has a name, else the path is empty.

◆ getMeshName() [2/2]

virtual const io::SNamedPath & jpp::scene::IMeshCache::getMeshName ( u32  index) const
pure virtual

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

Parameters
indexIndex of the mesh, number between 0 and getMeshCount()-1.
Returns
The name if mesh was found and has a name, else the path is empty.

◆ isMeshLoaded()

virtual bool jpp::scene::IMeshCache::isMeshLoaded ( const io::path name)
pure virtual

Check if a mesh was already loaded.

Parameters
nameName of the mesh. Usually a filename.
Returns
True if the mesh has been loaded, else false.

◆ removeMesh()

virtual void jpp::scene::IMeshCache::removeMesh ( const IMesh *const  mesh)
pure virtual

Removes the 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
meshPointer to the mesh which shall be removed.

◆ renameMesh() [1/2]

virtual bool jpp::scene::IMeshCache::renameMesh ( const IMesh *const  mesh,
const io::path name 
)
pure virtual

Renames the 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
meshMesh to be renamed.
nameNew name for the mesh.
Returns
True if mesh was renamed.

◆ renameMesh() [2/2]

virtual bool jpp::scene::IMeshCache::renameMesh ( u32  index,
const io::path name 
)
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
indexThe index of the mesh in the cache.
nameNew name for the mesh.
Returns
True if mesh was renamed.

◆ setMeshFilename() [1/2]

JPP_DEPRECATED bool jpp::scene::IMeshCache::setMeshFilename ( const IMesh *const  mesh,
const io::path filename 
)
inline

Renames a loaded mesh.

Deprecated:
Use renameMesh() instead. This method may be removed by Jimcpp 1.9

◆ setMeshFilename() [2/2]

JPP_DEPRECATED bool jpp::scene::IMeshCache::setMeshFilename ( u32  index,
const io::path filename 
)
inline

Renames a loaded mesh.

Deprecated:
Use renameMesh() instead. This method may be removed by Jimcpp 1.9

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

Jimcpp    @cppfx.xyz

K