Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

VPMeshObject Class Reference

Graphical object made of polygon meshes. More...

#include <vpmeshobject.h>

Inheritance diagram for VPMeshObject:

VPGraphicObj VPSceneNode VPMemoryObj List of all members.

Public Member Functions

 VPMeshObject ()
 VPMeshObject (const VPMeshObject &obj)
VPMeshObjectoperator= (const VPMeshObject &obj)
void SetMaterial (const VPMaterial &mat)
 Assigns a material to all meshes of the mesh object.
void MakeBox (double minX, double maxX, double minY, double maxY, double minZ, double maxZ)
 Creates a box aligned with the 3 reference planes (XY, XZ and YZ).
void GetYProjection (std::list< VPPoint4D > *resultPtr, double height=0) const
 Computes the projection of all vertices along the Y axis.
void Optimize ()
void Clear ()
 Erases internal structures.
void SetVertices (const std::vector< VPPoint4D > &vertexVec)
 Sets the vector of vertices.
void SetVertices (const char *vertexStr)
 Sets the vector of vertices.
void AddFace (const char *indexStr)
 Adds a face (a mesh of a single polygon) based on previously set vertices.
virtual void ComputeBoundingBox ()
 Computes the bounding box.
virtual TypeID GetID () const
void MergeWith (const VPMeshObject &obj)
 All vertices, normals, meshes, etc. are copied inside the active object.
void Transform (const VPTransform &trans)
 Apply Transformation to all vertices.
bool IsEmpty ()
 Checks whether the object contains geometry data.

Static Public Member Functions

static void ComputeTriangleNormal (const VPPoint4D &v1, const VPPoint4D &v2, const VPPoint4D &v3, VPPoint4D *resultPtr)
 V1, V2 and V3 should be in counter clockwise order.
static void ReadFromOBJ (const std::string &filename, std::list< VPMeshObject * > *resultPtr)
 Read VPMeshObjects from a Wavefront OBJ file.

Protected Member Functions

virtual bool DrawInstanceOGL () const
 Non-recursive drawing - should be overriden by every derived clas.

Static Protected Member Functions

static void ReadMaterialTable (const std::string &filename, std::map< std::string, VPMaterial > *matMapPtr)

Protected Attributes

std::vector< VPPoint4DvertVec
 Vector of pointers to all vertices.
std::vector< double > vertCoordVec
 Vector of all vertices (their coordinates in sequence).
std::vector< VPPoint4DnormVec
 Vector of pointers to all normals.
std::vector< double > normCoordVec
 Vector of all normals (their coordinates in sequence).
std::vector< float > textCoordVec
 Vector of all texture coordinates.
std::list< VPMeshmeshList
 List of Meshes.

Detailed Description

Graphical object made of polygon meshes.

A mesh object, unlike other graphical objects, maintains information about every vertex, normals, texture coordinates and edges. This is the class of choice for creating objects from files or objects whose vertex are to be edited. A mesh object may be optimized for display, and in that case vertex editing will be no longer possible.

Definition at line 26 of file vpmeshobject.h.


Constructor & Destructor Documentation

VPMeshObject::VPMeshObject  ) 
 

Definition at line 32 of file vpmeshobject.cpp.

VPMeshObject::VPMeshObject const VPMeshObject obj  ) 
 

Definition at line 36 of file vpmeshobject.cpp.

References meshList, normCoordVec, normVec, textCoordVec, vertCoordVec, and vertVec.


Member Function Documentation

void VPMeshObject::AddFace const char *  indexStr  ) 
 

Adds a face (a mesh of a single polygon) based on previously set vertices.

Creates a new Mesh of a single polygon, based on the indices found in indexStr. Indices start at zero. The vertices referenced should be in counter-clockwise order. No checking is done.

Definition at line 112 of file vpmeshobject.cpp.

References VPPoint4D::CrossProduct(), VPMesh::indexVec, meshList, VPPoint4D::Normalize(), VPMesh::normIndVec, normVec, VPMesh::POLYGON, VPMesh::type, and vertVec.

void VPMeshObject::Clear  ) 
 

Erases internal structures.

Erases previous vertices, indices, normals, texture coordinates, etc. Use before a complete change in the object.

Definition at line 57 of file vpmeshobject.cpp.

References meshList, normCoordVec, normVec, textCoordVec, vertCoordVec, and vertVec.

void VPMeshObject::ComputeBoundingBox  )  [virtual]
 

Computes the bounding box.

Implements VPGraphicObj.

Definition at line 228 of file vpmeshobject.cpp.

References VPGraphicObj::bBox, VPBoundingBox::ConditionalUpdate(), VPBoundingBox::SetBoundingBox(), vertCoordVec, and vertVec.

Referenced by MakeBox(), MergeWith(), SetVertices(), and Transform().

void VPMeshObject::ComputeTriangleNormal const VPPoint4D v1,
const VPPoint4D v2,
const VPPoint4D v3,
VPPoint4D resultPtr
[static]
 

V1, V2 and V3 should be in counter clockwise order.

Parameters:
v1 [in] 1st triangle vertex
v2 [in] 2nd triangle vertex
v3 [in] 4rd triangle vertex
resultPtr [out] Triangle normal (unit length).

Definition at line 301 of file vpmeshobject.cpp.

References VPPoint4D::CrossProduct(), and VPPoint4D::Normalize().

bool VPMeshObject::DrawInstanceOGL  )  const [protected, virtual]
 

Non-recursive drawing - should be overriden by every derived clas.

Reimplemented from VPSceneNode.

Definition at line 311 of file vpmeshobject.cpp.

References meshList, normCoordVec, normVec, VPGraphicObj::show, vertCoordVec, and vertVec.

virtual TypeID VPMeshObject::GetID  )  const [inline, virtual]
 

Reimplemented from VPSceneNode.

Definition at line 91 of file vpmeshobject.h.

References VPSceneNode::MESH_OBJECT.

void VPMeshObject::GetYProjection std::list< VPPoint4D > *  resultPtr,
double  height = 0
const
 

Computes the projection of all vertices along the Y axis.

Returns:
a list of projected points.
Parameters:
resultPtr [in,out] A pointer to a list that will be filled with resulting vertices.
height [in] Y coordinate to use in the projection (defaults to 0).

Definition at line 197 of file vpmeshobject.cpp.

References VPPoint4D::SetXYZW().

bool VPMeshObject::IsEmpty  )  [inline]
 

Checks whether the object contains geometry data.

Returns true if the object contains no geometry data. Actually it checks whether the mesh list is empty, which should be enough for consistent mesh objects.

Definition at line 117 of file vpmeshobject.h.

References meshList.

void VPMeshObject::MakeBox double  minX,
double  maxX,
double  minY,
double  maxY,
double  minZ,
double  maxZ
 

Creates a box aligned with the 3 reference planes (XY, XZ and YZ).

Definition at line 138 of file vpmeshobject.cpp.

References ComputeBoundingBox(), VPGraphicObj::ComputeRecursiveBoundingBox(), VPMaterial::DARK_PLASTIC_GRAY(), VPMesh::indexVec, VPMesh::material, meshList, normCoordVec, VPMesh::QUADS, textCoordVec, VPMesh::type, and vertCoordVec.

void VPMeshObject::MergeWith const VPMeshObject obj  ) 
 

All vertices, normals, meshes, etc. are copied inside the active object.

Definition at line 249 of file vpmeshobject.cpp.

References ComputeBoundingBox(), VPGraphicObj::ComputeRecursiveBoundingBox(), VPMesh::IncrementIndices(), meshList, normCoordVec, normVec, textCoordVec, vertCoordVec, and vertVec.

VPMeshObject & VPMeshObject::operator= const VPMeshObject obj  ) 
 

Definition at line 46 of file vpmeshobject.cpp.

References meshList, normCoordVec, normVec, textCoordVec, vertCoordVec, and vertVec.

void VPMeshObject::Optimize  ) 
 

This method creates an internal representation that is optimized for display (currently aimed at OpenGL - optimized representation may not be usefull for other renderers such as Direct3D). After being optimized, old data is discarded and the object can no longer be edited.

Definition at line 222 of file vpmeshobject.cpp.

static void VPMeshObject::ReadFromOBJ const std::string &  filename,
std::list< VPMeshObject * > *  resultPtr
[static]
 

Read VPMeshObjects from a Wavefront OBJ file.

This method creates mesh objects marked as auto-delete, ie, they will be automatically deleted if attached to scene. If not, the application programmer should delete them.

static void VPMeshObject::ReadMaterialTable const std::string &  filename,
std::map< std::string, VPMaterial > *  matMapPtr
[static, protected]
 

void VPMeshObject::SetMaterial const VPMaterial mat  ) 
 

Assigns a material to all meshes of the mesh object.

Definition at line 67 of file vpmeshobject.cpp.

References meshList.

void VPMeshObject::SetVertices const char *  vertexStr  ) 
 

Sets the vector of vertices.

Parses all values in vertexStr and stores them into the MeshObject's internal representation. Parameter vertexStr should be set of points separated by commas, point coordinates should be separated by spaces, point may have 3 or 4 coordinates - ex.: "1.2 0.2 3.1, 2 3 4 1, 1 2 3" The MeshObject becomes unoptimized. The meshList is cleared.

Definition at line 82 of file vpmeshobject.cpp.

References ComputeBoundingBox(), VPGraphicObj::ComputeRecursiveBoundingBox(), meshList, VPPoint4D::SetXYZW(), and vertVec.

void VPMeshObject::SetVertices const std::vector< VPPoint4D > &  vertexVec  ) 
 

Sets the vector of vertices.

All vertices in vertexVec are copied into the MeshObject's internal representation. The MeshObject becomes unoptimized. The meshList is cleared.

Definition at line 74 of file vpmeshobject.cpp.

References ComputeBoundingBox(), VPGraphicObj::ComputeRecursiveBoundingBox(), meshList, and vertVec.

void VPMeshObject::Transform const VPTransform trans  ) 
 

Apply Transformation to all vertices.

Definition at line 274 of file vpmeshobject.cpp.

References VPTransform::ApplyTo(), ComputeBoundingBox(), VPGraphicObj::ComputeRecursiveBoundingBox(), VPPoint4D::GetX(), VPPoint4D::GetY(), VPPoint4D::GetZ(), VPPoint4D::SetXYZW(), vertCoordVec, and vertVec.


Member Data Documentation

std::list<VPMesh> VPMeshObject::meshList [protected]
 

List of Meshes.

Definition at line 174 of file vpmeshobject.h.

Referenced by AddFace(), Clear(), DrawInstanceOGL(), IsEmpty(), MakeBox(), MergeWith(), operator=(), SetMaterial(), SetVertices(), and VPMeshObject().

std::vector<double> VPMeshObject::normCoordVec [protected]
 

Vector of all normals (their coordinates in sequence).

This is the optimized storage of normals. It must be a vector (not a list) because OpenGL will see it as a C array.

Definition at line 165 of file vpmeshobject.h.

Referenced by Clear(), DrawInstanceOGL(), MakeBox(), MergeWith(), operator=(), and VPMeshObject().

std::vector<VPPoint4D> VPMeshObject::normVec [protected]
 

Vector of pointers to all normals.

This is the unoptimized storage of normals. It must be a vector (not a list) because the internal meshes identifies vertices by integers.

Definition at line 159 of file vpmeshobject.h.

Referenced by AddFace(), Clear(), DrawInstanceOGL(), MergeWith(), operator=(), and VPMeshObject().

std::vector<float> VPMeshObject::textCoordVec [protected]
 

Vector of all texture coordinates.

This is both the optimized and the unoptimized storage of texture coordinates. It must be a vector (not a list) because OpenGL will see it as a C array.

Definition at line 171 of file vpmeshobject.h.

Referenced by Clear(), MakeBox(), MergeWith(), operator=(), and VPMeshObject().

std::vector<double> VPMeshObject::vertCoordVec [protected]
 

Vector of all vertices (their coordinates in sequence).

This is the optimized storage of vertices. It must be a vector (not a list) because OpenGL will see it as a C array. Every 3 sucessive coordinates in the array describe a vertex in the object.

Definition at line 153 of file vpmeshobject.h.

Referenced by Clear(), ComputeBoundingBox(), DrawInstanceOGL(), MakeBox(), MergeWith(), operator=(), Transform(), and VPMeshObject().

std::vector<VPPoint4D> VPMeshObject::vertVec [protected]
 

Vector of pointers to all vertices.

This is the unoptimized storage of vertices. It must be a vector (not a list) because the internal meshes identifies vertices by integers.

Definition at line 146 of file vpmeshobject.h.

Referenced by AddFace(), Clear(), ComputeBoundingBox(), DrawInstanceOGL(), MergeWith(), operator=(), SetVertices(), Transform(), and VPMeshObject().


The documentation for this class was generated from the following files:
Generated on Tue Sep 6 10:00:17 2005 for VPAT by  doxygen 1.4.4