Classes | Private Member Functions | Static Private Attributes

VR3MeshManager Class Reference

The mesh managing static class. More...

#include <VR3MeshManager.h>

List of all members.

Classes

struct  MapElement
 An element in the mesh map. More...

Static Public Member Functions

Mesh Loading Functions
static void LoadAAM (const char *file_name, VR3Mesh *mesh, const char *mesh_name=0, int objID=-1)
 Loads a mesh from a specified AAM file.
Mesh Discovery Function
static int ListMeshesAAM (const char *file_name, int ids[], std::string mesh_names[], int count)
 Lists the names and the ids of the meshes available in a given file.

Private Member Functions

 VR3MeshManager ()
 Private constructor to avoid explicit instantiation.

Static Private Attributes

static std::map< std::string,
std::map< int, MapElement >
, VR3Map::Less
ms_meshes
 Mapping of mesh file names and object IDs to mesh object references.

Mesh Management Functions

static VR3MeshFindMesh (const char *file_name, const char *mesh_name=0, int objID=-1)
 Searches the current mesh pool for the provided mesh clues.
static void DeleteReference (VR3Mesh *mesh)
 Notifies the deletion of a reference to a mesh.
static void AddReference (VR3Mesh *mesh)
 Notifies that a reference has been instantiated.
static void CreateMesh (VR3Mesh *mesh)
 Notifies the creation of a new mesh.

Detailed Description

The mesh managing static class.

This class can be viewed as a namespace with private data members, it cannot be instantiated explicitly and should only be used through the static mesh loading methods.

The VR3MeshManager class works as the mesh manager class, notice that 2 entities may have references to mesh objects:

This manager class is used to ensure that duplicated mesh objects representing the same mesh are never created.

This class also provides the mesh loading functions, so it is the mesh loader and manager class.

Definition at line 47 of file VR3MeshManager.h.


Constructor & Destructor Documentation

VR3MeshManager::VR3MeshManager (  ) [private]

Private constructor to avoid explicit instantiation.


Member Function Documentation

static void VR3MeshManager::AddReference ( VR3Mesh mesh ) [static]

Notifies that a reference has been instantiated.

When a previously created VR3Mesh object is linked to one or more VR3Obj the VR3MeshManager is notified that not only the programmer (first entity) but also some VR3Obj (more entities) have obtained a reference to this mesh. This ensures that the VR3Mesh object referenced by those entities won't be precociously deleted.

Parameters:
[in]meshThe referenced mesh
static void VR3MeshManager::CreateMesh ( VR3Mesh mesh ) [static, private]

Notifies the creation of a new mesh.

When a new mesh is created, this function is called inside the mesh loading function to notify the VR3MeshManager that a new mesh is being created. An error arises if a mesh with the same file name and object ID already exists. This function is called from the VR3MeshManager::LoadAAM() function.

Parameters:
[in]meshA reference to the new mesh object
static void VR3MeshManager::DeleteReference ( VR3Mesh mesh ) [static]

Notifies the deletion of a reference to a mesh.

A mesh may only be deleted by this mesh loading and managing module, when an object linked to some meshes terminates its life time, it simply calls the pseudo-destructor VR3Mesh::Destroy(). The VR3Mesh::Destroy() method will simply notify the mesh manager that a reference to the specified mesh has been deleted.

Parameters:
[in]meshThe referenced mesh
static VR3Mesh* VR3MeshManager::FindMesh ( const char *  file_name,
const char *  mesh_name = 0,
int  objID = -1 
) [static]

Searches the current mesh pool for the provided mesh clues.

This function is used to avoid multiple instantiations of the same mesh. A mesh pool is mantained and continuously updated stating which VR3Mesh object is associated to which (mesh file,objID) couple. This function is used to avoid mesh instantiation if possible. The mesh_name and objID are used to specify the particular mesh object to search for, they may be used together, singularly or not at all (in such case any mesh object from the file may be returned).

Parameters:
[in]file_nameThe requested mesh file name
[in]mesh_nameThe requeste mesh name in the mesh file
[in]objIDThe requested mesh object ID inside the mesh file
Returns:
The found mesh object or 0 if no matching object was found
static int VR3MeshManager::ListMeshesAAM ( const char *  file_name,
int  ids[],
std::string  mesh_names[],
int  count 
) [static]

Lists the names and the ids of the meshes available in a given file.

Given a mesh file, this function may be used to retrieve the list of all available meshes in the file. The name of the meshes is returned together with their ID. If the ids parameter or the mesh_names parameter is set to 0 (NULL), the only use of the function is the discovery of the number of meshes in the file: the names and the ids will not be returned. This function only works for AAM files.

Parameters:
[in]file_nameThe name of the file
[out]idsThe retrieved ids of the meshes (may be used to load them)
[out]mesh_namesThe retrieved names of the meshes (may be used to load them)
[in]countThe number of elements available in the ids and mesh_names arrays for writing
Returns:
The effective number of available meshes in the file
static void VR3MeshManager::LoadAAM ( const char *  file_name,
VR3Mesh mesh,
const char *  mesh_name = 0,
int  objID = -1 
) [static]

Loads a mesh from a specified AAM file.

This function fills the mesh variables with the values extracted from the specified AAM file. Notice that an AAM file may contain many different objects, representing globally a whole scene. When a mesh is loaded from an AAM file, the specified object ID and mesh name inside the file may determine which object to load. If no mesh_name (object name in the AAM file) or objID is specified, the first mesh object encountered will be loaded.

Parameters:
[in]file_nameName of the AAM file
[out]meshThe mesh object to fill
[in]mesh_nameThe object name inside the AAM file (0 if any)
[in]objIDThe object ID inside the AAM file (-1 if any)

Member Data Documentation

std::map<std::string, std::map<int,MapElement>, VR3Map::Less> VR3MeshManager::ms_meshes [static, private]

Mapping of mesh file names and object IDs to mesh object references.

File names are stored with their absolute normalized path

Definition at line 59 of file VR3MeshManager.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines