Nori

Mesh Class Reference

Triangle mesh. More...

#include <mesh.h>

Inheritance diagram for Mesh:
NoriObject

List of all members.

Public Member Functions

virtual ~Mesh ()
 Release all memory.
virtual void activate ()
 Initialize internal data structures (called once by the XML parser)
uint32_t getTriangleCount () const
 Return the total number of triangles in this hsape.
uint32_t getVertexCount () const
 Return the total number of vertices in this hsape.
void samplePosition (const Point2f &sample, Point3f &p, Normal3f &n) const
 Uniformly sample a position on the mesh with respect to surface area. Returns both position and normal.
float surfaceArea (uint32_t index) const
 Return the surface area of the given triangle.
BoundingBox3f getBoundingBox (uint32_t index) const
BoundingBox3f getClippedBoundingBox (uint32_t index, const BoundingBox3f &clip) const
 Returns the axis-aligned bounding box of a triangle after it has clipped to the extents of another given bounding box.
bool rayIntersect (uint32_t index, const Ray3f &ray, float &u, float &v, float &t) const
 Ray-triangle intersection test.
float surfaceArea () const
 Return the surface area of the entire mesh.
const Point3fgetVertexPositions () const
 Return a pointer to the vertex positions.
const Normal3fgetVertexNormals () const
 Return a pointer to the vertex normals (or NULL if there are none)
const Point2fgetVertexTexCoords () const
 Return a pointer to the texture coordinates (or NULL if there are none)
const uint32_t * getIndices () const
 Return a pointer to the triangle vertex index list.
const BSDF * getBSDF () const
 Return a pointer to the BSDF associated with this mesh.
virtual void addChild (NoriObject *child)
 Register a child object (e.g. a BSDF) with the mesh.
const QString & getName () const
 Return the name of this mesh.
QString toString () const
 Return a human-readable summary of this instance.
EClassType getClassType () const
 Return the type of object (i.e. Mesh/BSDF/etc.) provided by this instance.

Protected Member Functions

 Mesh ()
 Create an empty mesh.

Protected Attributes

Point3fm_vertexPositions
Normal3fm_vertexNormals
Point2fm_vertexTexCoords
uint32_t * m_indices
uint32_t m_vertexCount
uint32_t m_triangleCount
DiscretePDF m_distr
BSDF * m_bsdf
QString m_name

Detailed Description

Triangle mesh.

This class stores a triangle mesh object and provides numerous functions for querying the individual triangles. Subclasses of Mesh implement the specifics of how to create its contents (e.g. by loading from an external file)

Definition at line 75 of file mesh.h.


Constructor & Destructor Documentation

virtual Mesh::~Mesh ( ) [virtual]

Release all memory.

Mesh::Mesh ( ) [protected]

Create an empty mesh.


Member Function Documentation

virtual void Mesh::activate ( ) [virtual]

Initialize internal data structures (called once by the XML parser)

Reimplemented from NoriObject.

virtual void Mesh::addChild ( NoriObject child) [virtual]

Register a child object (e.g. a BSDF) with the mesh.

Reimplemented from NoriObject.

BoundingBox3f Mesh::getBoundingBox ( uint32_t  index) const
const BSDF* Mesh::getBSDF ( ) const [inline]

Return a pointer to the BSDF associated with this mesh.

Definition at line 154 of file mesh.h.

EClassType Mesh::getClassType ( ) const [inline, virtual]

Return the type of object (i.e. Mesh/BSDF/etc.) provided by this instance.

Implements NoriObject.

Definition at line 169 of file mesh.h.

BoundingBox3f Mesh::getClippedBoundingBox ( uint32_t  index,
const BoundingBox3f clip 
) const

Returns the axis-aligned bounding box of a triangle after it has clipped to the extents of another given bounding box.

This function uses the Sutherland-Hodgman algorithm to calculate the convex polygon that is created when applying all 6 BoundingBox3f splitting planes to the triangle. Afterwards, the BoundingBox3f of the newly created convex polygon is returned. This function is an important component for efficiently creating 'Perfect Split' KD-trees. For more detail, see "On building fast kd-Trees for Ray Tracing, and on doing that in O(N log N)" by Ingo Wald and Vlastimil Havran

const uint32_t* Mesh::getIndices ( ) const [inline]

Return a pointer to the triangle vertex index list.

Definition at line 151 of file mesh.h.

const QString& Mesh::getName ( ) const [inline]

Return the name of this mesh.

Definition at line 160 of file mesh.h.

uint32_t Mesh::getTriangleCount ( ) const [inline]

Return the total number of triangles in this hsape.

Definition at line 84 of file mesh.h.

uint32_t Mesh::getVertexCount ( ) const [inline]

Return the total number of vertices in this hsape.

Definition at line 87 of file mesh.h.

const Normal3f* Mesh::getVertexNormals ( ) const [inline]

Return a pointer to the vertex normals (or NULL if there are none)

Definition at line 145 of file mesh.h.

const Point3f* Mesh::getVertexPositions ( ) const [inline]

Return a pointer to the vertex positions.

Definition at line 142 of file mesh.h.

const Point2f* Mesh::getVertexTexCoords ( ) const [inline]

Return a pointer to the texture coordinates (or NULL if there are none)

Definition at line 148 of file mesh.h.

bool Mesh::rayIntersect ( uint32_t  index,
const Ray3f ray,
float &  u,
float &  v,
float &  t 
) const

Ray-triangle intersection test.

Uses the algorithm by Moeller and Trumbore discussed at http://www.acm.org/jgt/papers/MollerTrumbore97/code.html.

Parameters:
indexIndex of the triangle that should be intersected
rayThe ray segment to be used for the intersection query
tUpon success, t contains the distance from the ray origin to the intersection point,
uUpon success, u will contain the 'U' component of the intersection in barycentric coordinates
vUpon success, v will contain the 'V' component of the intersection in barycentric coordinates
Returns:
true if an intersection has been detected
void Mesh::samplePosition ( const Point2f sample,
Point3f p,
Normal3f n 
) const

Uniformly sample a position on the mesh with respect to surface area. Returns both position and normal.

float Mesh::surfaceArea ( uint32_t  index) const

Return the surface area of the given triangle.

float Mesh::surfaceArea ( ) const [inline]

Return the surface area of the entire mesh.

Definition at line 139 of file mesh.h.

QString Mesh::toString ( ) const [virtual]

Return a human-readable summary of this instance.

Implements NoriObject.


Member Data Documentation

BSDF* Mesh::m_bsdf [protected]

Definition at line 181 of file mesh.h.

Definition at line 180 of file mesh.h.

uint32_t* Mesh::m_indices [protected]

Definition at line 177 of file mesh.h.

QString Mesh::m_name [protected]

Definition at line 182 of file mesh.h.

uint32_t Mesh::m_triangleCount [protected]

Definition at line 179 of file mesh.h.

uint32_t Mesh::m_vertexCount [protected]

Definition at line 178 of file mesh.h.

Definition at line 175 of file mesh.h.

Definition at line 174 of file mesh.h.

Definition at line 176 of file mesh.h.


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