Class TMeshCache

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TMeshCache = class(TReferenceCounted)

Description

The mesh cache stores already loaded meshes and provides an interface to them.
You can access it using TSceneManager.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 TSceneManager.GetMesh() is not sufficient), to remove them and to iterate through already loaded meshes.

Hierarchy

Overview

Methods

Public function GetMeshByIndex(Index: LongWord): TAnimatedMesh; inline;
Public function GetMeshByName(const Name: StringType): TAnimatedMesh; inline;
Public function GetMeshIndex(Mesh: TMesh): LongInt; overload; inline;
Public function GetMeshIndex(Mesh: TAnimatedMesh): LongInt; overload; inline;
Public function GetMeshName(Mesh: TAnimatedMesh): StringType; overload; inline;
Public function GetMeshName(Mesh: TMesh): StringType; overload; inline;
Public function GetMeshName(Index: LongWord): StringType; overload; inline;
Public function IsMeshLoaded(const Name: StringType): Boolean; inline;
Public procedure AddMesh(const Name: StringType; Mesh: TAnimatedMesh); inline;
Public procedure Clear; inline;
Public procedure ClearUnusedMeshes; inline;
Public procedure RemoveMesh(Mesh: TAnimatedMesh); overload; inline;
Public procedure RemoveMesh(Mesh: TMesh); overload; inline;
Public procedure RenameMesh(Index: LongWord; const Name: StringType); overload; inline;
Public procedure RenameMesh(Mesh: TAnimatedMesh; const Name: StringType); overload; inline;
Public procedure RenameMesh(Mesh: TMesh; const Name: StringType); overload; inline;

Properties

Public property MeshCount: LongWord read GetMeshCount;

Description

Methods

Public function GetMeshByIndex(Index: LongWord): TAnimatedMesh; inline;

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

The mesh or nil if there is none with this number.

Public function GetMeshByName(const Name: StringType): TAnimatedMesh; inline;

Returns a mesh based on its name.

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

The mesh or nil if there is no such mesh.

Public function GetMeshIndex(Mesh: TMesh): LongInt; overload; inline;

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

Parameters
Mesh
The mesh to search for.
Returns

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

Public function GetMeshIndex(Mesh: TAnimatedMesh): LongInt; overload; inline;

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

Parameters
Mesh
The mesh to search for.
Returns

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

Public function GetMeshName(Mesh: TAnimatedMesh): StringType; overload; inline;

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

Parameters
Mesh
The mesh to query.
Returns

The name if mesh was found and has a name, else the path is empty.

Public function GetMeshName(Mesh: TMesh): StringType; overload; inline;

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

Parameters
Mesh
The mesh to query.
Returns

The name if mesh was found and has a name, else the path is empty.

Public function GetMeshName(Index: LongWord): StringType; overload; inline;

Get the name of a loaded mesh by index.

Parameters
Mesh
The mesh to query.
Returns

The name if mesh was found and has a name, else the path is empty.

Public function IsMeshLoaded(const Name: StringType): Boolean; inline;

Check if a mesh was already loaded.

Parameters
Name
Name of the mesh. Usually a filename.
Returns

True if the mesh has been loaded, else false.

Public procedure AddMesh(const Name: StringType; Mesh: TAnimatedMesh); inline;

Adds a mesh to the internal list of loaded meshes.
Usually, TSceneManager.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
Name
Name of the mesh. When calling TSceneManager.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.
Public procedure Clear; inline;

Clears the whole mesh cache, removing all meshes.
All meshes will be reloaded completely when using TSceneManager.GetMesh() after calling this method. Warning: If you have pointers to meshes that were loaded with TSceneManager.GetMesh() and you did not grab them, then they may become invalid.

Public procedure ClearUnusedMeshes; inline;

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 TSceneManager.GetMesh() and you did not grab them, then they may become invalid.

Public procedure RemoveMesh(Mesh: TAnimatedMesh); overload; inline;

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.
Public procedure RemoveMesh(Mesh: TMesh); overload; inline;

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.
Public procedure RenameMesh(Index: LongWord; const Name: StringType); overload; inline;

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
Index of the Mesh to be renamed.
Name
New name for the mesh.
Returns

True if mesh was renamed.

Public procedure RenameMesh(Mesh: TAnimatedMesh; const Name: StringType); overload; inline;

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.
Name
New name for the mesh.
Returns

True if mesh was renamed.

Public procedure RenameMesh(Mesh: TMesh; const Name: StringType); overload; inline;

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.
Name
New name for the mesh.
Returns

True if mesh was renamed.

Properties

Public property MeshCount: LongWord read GetMeshCount;

The number of loaded meshes in the cache.


Generated by PasDoc 0.12.1 on 2012-09-14 17:32:22