Xface Core Library: XEngine::Geometry Class Reference

XFace / XEngine / XMath

XEngine::Geometry Class Reference
[XEngine]

#include <Geometry.h>

Inheritance diagram for XEngine::Geometry:

XEngine::NamedObj XEngine::IndexedFaceSet XEngine::DeformableGeometry List of all members.

Detailed Description

Author:
Koray Balci
Version:
1.0
Date:
May 2003
Base class for the triangle mesh. Stores the vertices (not indices) and other related data. Every IMesh object is named and stored in MeshManager to be used through its name. The same name is assigned to Drawable instance and the make a couple for the mesh, MeshManager stores the IMesh instances, and RenderList stores the Drawables and Renderer renders IMesh instances by retrieving them using the registered names in Drawable instance.

IMesh objects are created and stored inside IModelLoader (or derived) instances, and stored in MeshManager class.

Here is a typical usage in IModelLoader;

        IndexedFaceSet* m_pMesh = new IndexedFaceSet("TestMesh"); // Create an instance (IndexedFaceSet IS-A IMesh)
        // Set a unique name in ctor
        m_pMesh->setVertices(m_Vertices);       // Set the vertices and others..
        m_pMesh->setIndices(m_Indices);         // Set the indices
        m_pMesh->createMesh();                  // You SHOULD call this one to get normals correctly!

        // MeshManager is a singleton class.
        MeshManager::getInstance()->registerMesh(m_pMesh); // Add the mesh to MeshManager

Then when you need to use that mesh in a different place (e.g. in Renderer);

        const IndexedGFaceSet* test = MeshManager::getInstance()->getMesh("TestMesh");

Note:
Texture coordinates, normals and vertices are stored in seperate arrays. Maybe we can consider using a single array (interleaved) later on. And also currently only one texture layer is supported. For multitexturing we might add more arrays for texture coordinates in the future versions.


Public Member Functions

virtual GeometrycopyFrom (const Geometry &rhs)
virtual void setVertices (const Vector3 *pVert, unsigned int size)
virtual void setVertices (const std::vector< Vector3 > &vertices)
virtual void setNormals (const std::vector< Vector3 > &normals)
virtual void setNormals (const Vector3 *pNorm, unsigned int size)
virtual void setTexCoords (const Vertex2D *pTex, unsigned int size)
virtual void setTexCoords (const std::vector< Vertex2D > &texCoords)
const std::vector< Vector3 > & getVertices () const
 Accessor for vertices (x, y, z).
const std::vector< Vector3 > & getNormals () const
 Accessor for normals.
const std::vector< Vertex2D > & getTexCoords () const
 Accessor for texture coordinates.
size_t getVertexCount () const
 Accessor for vertex count.

Static Public Member Functions

static Vector3 computeFaceNormal (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3)

Member Function Documentation

Vector3 XEngine::Geometry::computeFaceNormal const Vector3 p1,
const Vector3 p2,
const Vector3 p3
[static]
 

Computes the facenormal by crossing two vectors defined by (p2-p1) and (p3-p1). The parameters are assumed to be passed in counter-clockwise order.

Geometry & XEngine::Geometry::copyFrom const Geometry rhs  )  [virtual]
 

We do NOT override the = operator but implement a new method, because in some cases, we only want to copy the data, not the name of the Geometry.

void XEngine::Geometry::setNormals const Vector3 pNorm,
unsigned int  size
[virtual]
 

Todo:
check back here

void XEngine::Geometry::setNormals const std::vector< Vector3 > &  normals  )  [virtual]
 

Vertex normals are set through here.

void XEngine::Geometry::setTexCoords const std::vector< Vertex2D > &  texCoords  )  [virtual]
 

Texture coordinates are set through here.

void XEngine::Geometry::setTexCoords const Vertex2D pTex,
unsigned int  size
[virtual]
 

Texture coordinates are set through here.

void XEngine::Geometry::setVertices const std::vector< Vector3 > &  vertices  )  [virtual]
 

Vertices are set through here.

Reimplemented in XEngine::DeformableGeometry.

void XEngine::Geometry::setVertices const Vector3 pVert,
unsigned int  size
[virtual]
 

Todo:
check back here


The documentation for this class was generated from the following files:
Generated on Mon Aug 28 15:39:25 2006 for Xface Core Library by  doxygen 1.4.6-NO