Mesh Class Reference

Representation of a triangular mesh stored in the obj format. It consists of a list of vertices's and a list of faces that contain indices in the vertex list. More...

#include <Mesh.h>

Inheritance diagram for Mesh:

Transformable PropertyMap Shape Intersectable SSEAligned

List of all members.

Public Member Functions

Constructors
 Mesh (const MeshData &data)
 Constructs a mesh out of the specified MeshData.
 Mesh (unsigned nVertices, unsigned nNormals, unsigned nUVs, unsigned nTriangles)
 Constructs a mesh with the specified vertex/triangle count.
 Mesh (const Mesh &mesh)
 Copy constructor.
virtual ~Mesh ()
 Cleans up vertex and triangle data.
Core functionality
virtual void init (bool forceUpdate)
 Initializes this Mesh and its underlying SpatialAccel.
virtual void init ()
 Initializes this Mesh and its underlying SpatialAccel.
virtual void preview ()
 Displays an OpenGL preview of this mesh; optimized for repeated calls via a compiled OpenGL display list.
virtual real_t getIntersection (const Ray &ray, SurfacePoint &pt)
 Tests the given ray with this object for intersection. If a valid intersection exists, its "t" value will be returned and the given SurfacePoint will be initialized with enough data for this object to later fill in all relevant information lazily (world space normal at intersection point, uv coordinates, etc.).
virtual bool intersects (const Ray &ray, real_t tMax=INFINITY)
 Used for occlusion/visibility testing where you don't necessarily care about anything other than whether or not an intersection exists. (generally faster than getIntersection).
void computeNormals ()
Sampling functionality
virtual void getPoint (SurfacePoint &pt, const UV &uv)
virtual Point3 getPosition (const UV &uv)
Accessors / Mutators
unsigned getNoVertices () const
unsigned getNoNormals () const
unsigned getNoUVs () const
unsigned getNoTriangles () const
VertexgetVertices (unsigned &nVertices) const
NormalgetNormals (unsigned &nNormals) const
UVgetUVs (unsigned &nUVs) const
MeshTrianglegetTriangles (unsigned &nTriangles) const
VertexgetVertices () const
NormalgetNormals () const
UVgetUVs () const
MeshTrianglegetTriangles () const
void setPreviewDirty ()

Protected Member Functions

virtual void _getUV (SurfacePoint &pt) const
virtual void _getGeometricNormal (SurfacePoint &pt) const
virtual real_t _getSurfaceArea ()

Protected Attributes

unsigned m_nVertices
unsigned m_nNormals
unsigned m_nUVs
unsigned m_nTriangles
Vertexm_vertices
Normalm_normals
UVm_uvs
MeshTrianglem_triangles
GLuint m_batch
SpatialAccelm_spatialAccel
bool m_enableAccelPreview


Detailed Description

Representation of a triangular mesh stored in the obj format. It consists of a list of vertices's and a list of faces that contain indices in the vertex list.

Author:
Travis Fischer (fisch0920@gmail.com)

Nong Li (nongli@gmail.com)

Date:
Spring 2008

Definition at line 34 of file Mesh.h.


Constructor & Destructor Documentation

Mesh::Mesh ( const MeshData data  ) 

Constructs a mesh out of the specified MeshData.

Definition at line 29 of file Mesh.cpp.

Mesh::Mesh ( unsigned  nVertices,
unsigned  nNormals,
unsigned  nUVs,
unsigned  nTriangles 
)

Constructs a mesh with the specified vertex/triangle count.

Definition at line 102 of file Mesh.cpp.

Mesh::Mesh ( const Mesh mesh  ) 

Copy constructor.

Definition at line 146 of file Mesh.cpp.

Mesh::~Mesh (  )  [virtual]

Cleans up vertex and triangle data.

Definition at line 188 of file Mesh.cpp.


Member Function Documentation

void Mesh::init ( bool  forceUpdate  )  [virtual]

Initializes this Mesh and its underlying SpatialAccel.

Parameters:
forceUpdate if true, reinitializes this mesh, including recreating the underlying SpatialAccel and dirtying this mesh's OpenGL preview display list

Definition at line 200 of file Mesh.cpp.

void Mesh::init (  )  [virtual]

Initializes this Mesh and its underlying SpatialAccel.

Reimplemented from Transformable.

Definition at line 209 of file Mesh.cpp.

void Mesh::preview (  )  [virtual]

Displays an OpenGL preview of this mesh; optimized for repeated calls via a compiled OpenGL display list.

Reimplemented from Transformable.

Definition at line 247 of file Mesh.cpp.

real_t Mesh::getIntersection ( const Ray ray,
SurfacePoint pt 
) [virtual]

Tests the given ray with this object for intersection. If a valid intersection exists, its "t" value will be returned and the given SurfacePoint will be initialized with enough data for this object to later fill in all relevant information lazily (world space normal at intersection point, uv coordinates, etc.).

Note:
if you only care about whether or not an intersection exists and don't actually need to know the exact intersection point, see the intersects method instead.
Returns:
the smallest positive "t" value of any intersections found, or INFINITY if no valid intersection exists

Implements Intersectable.

Definition at line 366 of file Mesh.cpp.

bool Mesh::intersects ( const Ray ray,
real_t  tMax = INFINITY 
) [virtual]

Used for occlusion/visibility testing where you don't necessarily care about anything other than whether or not an intersection exists. (generally faster than getIntersection).

Note:
default implementation defers to getIntersection
Returns:
whether or not the given ray intersects this object with a positive "t" value greater than EPSILON and less than the given tMax

Reimplemented from Intersectable.

Definition at line 384 of file Mesh.cpp.

void Mesh::computeNormals (  ) 

Computes the normals. The vertex positions should be set. The normals will be averaged (Gourand Shading)

Definition at line 324 of file Mesh.cpp.

void Mesh::getPoint ( SurfacePoint pt,
const UV uv 
) [virtual]

Returns:
the point on the surface of this shape corresponding to the given UV coordinates in 'pt'

Reimplemented from Shape.

Definition at line 422 of file Mesh.cpp.

Point3 Mesh::getPosition ( const UV uv  )  [virtual]

Returns:
the point on the surface of this shape corresponding to the given UV coordinates

Reimplemented from Transformable.

Definition at line 429 of file Mesh.cpp.

unsigned Mesh::getNoVertices (  )  const [inline]

Returns:
the number of vertices

Definition at line 113 of file Mesh.h.

unsigned Mesh::getNoNormals (  )  const [inline]

Returns:
the number of normals

Definition at line 118 of file Mesh.h.

unsigned Mesh::getNoUVs (  )  const [inline]

Returns:
the number of uvs

Definition at line 123 of file Mesh.h.

unsigned Mesh::getNoTriangles (  )  const [inline]

Returns:
the number of triangles

Definition at line 128 of file Mesh.h.

Vertex* Mesh::getVertices ( unsigned &  nVertices  )  const [inline]

Returns:
a pointer to the vertex data and the number of vertices

Definition at line 133 of file Mesh.h.

Normal* Mesh::getNormals ( unsigned &  nNormals  )  const [inline]

Returns:
a pointer to the normal data and the number of normals

Definition at line 140 of file Mesh.h.

UV* Mesh::getUVs ( unsigned &  nUVs  )  const [inline]

Returns:
a pointer to the uv data and the number of uvs

Definition at line 147 of file Mesh.h.

MeshTriangle* Mesh::getTriangles ( unsigned &  nTriangles  )  const [inline]

Returns:
a pointer to the triangle data and the number of triangles

Definition at line 154 of file Mesh.h.

Vertex* Mesh::getVertices (  )  const [inline]

Returns:
a pointer to the vertex data

Definition at line 161 of file Mesh.h.

Normal* Mesh::getNormals (  )  const [inline]

Returns:
a pointer to the normal data

Definition at line 166 of file Mesh.h.

UV* Mesh::getUVs (  )  const [inline]

Returns:
a pointer to the uv data

Definition at line 171 of file Mesh.h.

MeshTriangle* Mesh::getTriangles (  )  const [inline]

Returns:
a pointer to the triangle data

Definition at line 176 of file Mesh.h.

void Mesh::setPreviewDirty (  ) 

Definition at line 454 of file Mesh.cpp.

void Mesh::_getUV ( SurfacePoint pt  )  const [protected, virtual]

Implements Shape.

Definition at line 395 of file Mesh.cpp.

void Mesh::_getGeometricNormal ( SurfacePoint pt  )  const [protected, virtual]

Implements Shape.

Definition at line 406 of file Mesh.cpp.

real_t Mesh::_getSurfaceArea (  )  [protected, virtual]

Returns:
the aggregate surface area of all triangles in this mesh

Reimplemented from Shape.

Definition at line 437 of file Mesh.cpp.


Member Data Documentation

unsigned Mesh::m_nVertices [protected]

Definition at line 195 of file Mesh.h.

unsigned Mesh::m_nNormals [protected]

Definition at line 196 of file Mesh.h.

unsigned Mesh::m_nUVs [protected]

Definition at line 197 of file Mesh.h.

unsigned Mesh::m_nTriangles [protected]

Definition at line 198 of file Mesh.h.

Vertex* Mesh::m_vertices [protected]

Definition at line 200 of file Mesh.h.

Normal* Mesh::m_normals [protected]

Definition at line 201 of file Mesh.h.

UV* Mesh::m_uvs [protected]

Definition at line 202 of file Mesh.h.

Definition at line 203 of file Mesh.h.

GLuint Mesh::m_batch [protected]

Definition at line 206 of file Mesh.h.

Definition at line 208 of file Mesh.h.

bool Mesh::m_enableAccelPreview [protected]

Definition at line 210 of file Mesh.h.


The documentation for this class was generated from the following files:

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6