Nori
|
Triangle mesh. More...
#include <mesh.h>
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 Point3f * | getVertexPositions () const |
Return a pointer to the vertex positions. | |
const Normal3f * | getVertexNormals () const |
Return a pointer to the vertex normals (or NULL if there are none) | |
const Point2f * | getVertexTexCoords () 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 | |
Point3f * | m_vertexPositions |
Normal3f * | m_vertexNormals |
Point2f * | m_vertexTexCoords |
uint32_t * | m_indices |
uint32_t | m_vertexCount |
uint32_t | m_triangleCount |
DiscretePDF | m_distr |
BSDF * | m_bsdf |
QString | m_name |
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)
virtual Mesh::~Mesh | ( | ) | [virtual] |
Release all memory.
Mesh::Mesh | ( | ) | [protected] |
Create an empty mesh.
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] |
EClassType Mesh::getClassType | ( | ) | const [inline, virtual] |
Return the type of object (i.e. Mesh/BSDF/etc.) provided by this instance.
Implements NoriObject.
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] |
const QString& Mesh::getName | ( | ) | const [inline] |
uint32_t Mesh::getTriangleCount | ( | ) | const [inline] |
uint32_t Mesh::getVertexCount | ( | ) | const [inline] |
const Normal3f* Mesh::getVertexNormals | ( | ) | const [inline] |
const Point3f* Mesh::getVertexPositions | ( | ) | const [inline] |
const Point2f* Mesh::getVertexTexCoords | ( | ) | const [inline] |
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
.
index | Index of the triangle that should be intersected |
ray | The ray segment to be used for the intersection query |
t | Upon success, t contains the distance from the ray origin to the intersection point, |
u | Upon success, u will contain the 'U' component of the intersection in barycentric coordinates |
v | Upon success, v will contain the 'V' component of the intersection in barycentric coordinates |
true
if an intersection has been detected 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] |
QString Mesh::toString | ( | ) | const [virtual] |
Return a human-readable summary of this instance.
Implements NoriObject.
BSDF* Mesh::m_bsdf [protected] |
DiscretePDF Mesh::m_distr [protected] |
uint32_t* Mesh::m_indices [protected] |
QString Mesh::m_name [protected] |
uint32_t Mesh::m_triangleCount [protected] |
uint32_t Mesh::m_vertexCount [protected] |
Normal3f* Mesh::m_vertexNormals [protected] |
Point3f* Mesh::m_vertexPositions [protected] |
Point2f* Mesh::m_vertexTexCoords [protected] |