Classes | Private Member Functions | Static Private Attributes

VR3PhyMeshManager Class Reference

The physical mesh managing static class. More...

#include <VR3PhyMeshManager.h>

List of all members.

Classes

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

Static Public Member Functions

Physical Mesh Discovery Functions
static int ListPhyMeshesAAM (const char *file_name, int ids[], std::string mesh_names[], int count)
 Lists the names and the ids of the meshes having physical data in a given file.

Private Member Functions

 VR3PhyMeshManager ()
 Private constructor to avoid explicit instantiation.

Static Private Attributes

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

Physical Mesh Loading Functions

static void LoadStaticAAM (std::ifstream &is, VR3PhyMesh *phymesh)
 Loads the shape representing a static mesh in the physical simulation.
static void LoadNonStaticAAM (std::ifstream &is, VR3PhyMesh *phymesh)
 Loads the convex shapes representic a non-static mesh in the physical simulation.
static void LoadAAM (const char *file_name, VR3PhyMesh *phymesh, const char *mesh_name=0, int objID=-1)
 Loads a physical mesh from a specified AAM file.

Physical Mesh Management Functions

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

Detailed Description

The physical 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 physical mesh loading methods.

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

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

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

Definition at line 51 of file VR3PhyMeshManager.h.


Constructor & Destructor Documentation

VR3PhyMeshManager::VR3PhyMeshManager (  ) [private]

Private constructor to avoid explicit instantiation.


Member Function Documentation

static void VR3PhyMeshManager::AddReference ( VR3PhyMesh phymesh ) [static]

Notifies that a reference has been instantiated.

When the user provides a new VR3PhyMesh object reference while adding the object to the physics simulation, the VR3PhyMeshManager module is notified that a new reference to the object is now owned by the VR3PhysicsSimulator object. This ensures that the VR3PhyMesh object referenced by those entities won't be precociously deleted when the Destroy() function is called to get rid of a reference.

Parameters:
[in]phymeshThe referenced physical mesh
static void VR3PhyMeshManager::CreatePhyMesh ( VR3PhyMesh phymesh ) [static, private]

Notifies the creation of a new physical mesh.

When a new mesh is created, this function is called inside the mesh loading function to notify the VR3PhyMeshManager 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 VR3PhyMeshManager::LoadAAM() function.

Parameters:
[in]phymeshA reference to the new physical mesh object
static void VR3PhyMeshManager::DeleteReference ( VR3PhyMesh phymesh ) [static]

Notifies the deletion of a reference to a physical mesh.

A physical mesh may only be deleted by this physical mesh loading and managing module. When a physics simulator terminates its life, it simply calls the pseudo-destructor VR3PhyMesh::Destroy(). The VR3PhyMesh::Destroy() method will notify this physical mesh manager that a reference to the specified physical mesh has been deleted.

Parameters:
[in]phymeshThe referenced physical mesh
static VR3PhyMesh* VR3PhyMeshManager::FindPhyMesh ( const char *  file_name,
const char *  mesh_name = 0,
int  objID = -1 
) [static]

Searches the current physical mesh pool for the provided clues.

This function is used to avoid multiple instantiations of the same physical mesh. A mesh pool is mantained and continuously updated stating which VR3PhyMesh object is associated to which (mesh file,objID) couple. This function is used to avoid physical 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 VR3PhyMeshManager::ListPhyMeshesAAM ( const char *  file_name,
int  ids[],
std::string  mesh_names[],
int  count 
) [static]

Lists the names and the ids of the meshes having physical data in a given file.

Given a mesh file, this function may be used to retrieve the list of all meshes in the file corresponding having physical data (i.e. they can be simulated). 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 having physical data in the file: the ids and the names 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 meshes having physical data in the file
static void VR3PhyMeshManager::LoadAAM ( const char *  file_name,
VR3PhyMesh phymesh,
const char *  mesh_name = 0,
int  objID = -1 
) [static]

Loads a physical mesh from a specified AAM file.

This function fills the VR3PhyMesh 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 physical mesh is loaded from an AAM file, the specified object ID and mesh name inside the file may determine which physical object to load. If no mesh_name (object name in the AAM file) or objID is specified, the first physical mesh object encountered will be loaded.

Parameters:
[in]file_nameName of the AAM file
[out]phymeshThe 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)
static void VR3PhyMeshManager::LoadNonStaticAAM ( std::ifstream &  is,
VR3PhyMesh phymesh 
) [static, private]

Loads the convex shapes representic a non-static mesh in the physical simulation.

Dynamic and kinematic PhysX objects may only be correctly simulated if composed of convex meshes. This is why the dynamic object mesh used for rendering is decomposed in a set of convex meshes in the AAM file. The set of those convex meshes will form the full dynamic object body.

Parameters:
[in]isThe file input stream
[out]phymeshThe physical mesh object to fill
static void VR3PhyMeshManager::LoadStaticAAM ( std::ifstream &  is,
VR3PhyMesh phymesh 
) [static, private]

Loads the shape representing a static mesh in the physical simulation.

Loads the triangle mesh used to represent a static object in the PhysX simulation. Static objects may be simulated with arbitrary triangle meshes.

Parameters:
[in]isThe file input stream
[out]phymeshThe physical mesh object to fill

Member Data Documentation

std::map<std::string, std::map<int,MapElement>, VR3Map::Less> VR3PhyMeshManager::ms_phymeshes [static, private]

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

File names are stored with their absolute normalized path

Definition at line 62 of file VR3PhyMeshManager.h.


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