Nori  23
Mesh Class Reference

Triangle mesh. More...

#include <mesh.h>

Inheritance diagram for Mesh:
Collaboration diagram for Mesh:

Public Member Functions

virtual void activate () override
 Initialize internal data structures (called once by the XML parser)
 
virtual uint32_t getPrimitiveCount () const override
 Return the total number of triangles in this shape.
 
virtual BoundingBox3f getBoundingBox (uint32_t index) const override
 
virtual Point3f getCentroid (uint32_t index) const override
 
virtual bool rayIntersect (uint32_t index, const Ray3f &ray, float &u, float &v, float &t) const override
 Ray-triangle intersection test. More...
 
virtual void setHitInformation (uint32_t index, const Ray3f &ray, Intersection &its) const override
 Set intersection information: hit point, shading frame, UVs.
 
uint32_t getVertexCount () const
 Return the total number of vertices in this shape.
 
virtual void sampleSurface (ShapeQueryRecord &sRec, const Point2f &sample) const override
 Uniformly sample a position on the mesh with respect to surface area.
 
virtual float pdfSurface (const ShapeQueryRecord &sRec) const override
 Return the probability of sampling a point sRec.p by the sampleSurface() method (sRec.ref should be set before) sRec.n and sRec.pdf are ignored.
 
float surfaceArea (uint32_t index) const
 Return the surface area of the given triangle.
 
Point3f getInterpolatedVertex (uint32_t index, const Vector3f &bc) const
 
Normal3f getInterpolatedNormal (uint32_t index, const Vector3f &bc) const
 
const MatrixXf & getVertexPositions () const
 Return a pointer to the vertex positions.
 
const MatrixXf & getVertexNormals () const
 Return a pointer to the vertex normals (or nullptr if there are none)
 
const MatrixXf & getVertexTexCoords () const
 Return a pointer to the texture coordinates (or nullptr if there are none)
 
const MatrixXu & getIndices () const
 Return a pointer to the triangle vertex index list.
 
const std::string & getName () const
 Return the name of this mesh.
 
virtual std::string toString () const override
 Return a human-readable summary of this instance.
 
- Public Member Functions inherited from Shape
virtual ~Shape ()
 Release all memory.
 
virtual void addChild (NoriObject *child) override
 Add a child object to the current instance. More...
 
const BoundingBox3fgetBoundingBox () const
 
bool isEmitter () const
 Is this mesh an area emitter?
 
EmittergetEmitter ()
 Return a pointer to an attached area emitter instance.
 
const EmittergetEmitter () const
 Return a pointer to an attached area emitter instance (const version)
 
const BSDFgetBSDF () const
 Return a pointer to the BSDF associated with this mesh.
 
virtual EClassType getClassType () const override
 Return the type of object (i.e. Mesh/BSDF/etc.) provided by this instance.
 
- Public Member Functions inherited from NoriObject
virtual ~NoriObject ()
 Virtual destructor.
 
virtual void setParent (NoriObject *parent)
 Set the parent object. More...
 
void setIdName (const std::string &name)
 Allow to assign a name to the object.
 
const std::string & getIdName () const
 

Protected Member Functions

 Mesh ()
 Create an empty mesh.
 

Protected Attributes

std::string m_name
 Identifying name.
 
MatrixXf m_V
 Vertex positions.
 
MatrixXf m_N
 Vertex normals.
 
MatrixXf m_UV
 Vertex texture coordinates.
 
MatrixXu m_F
 Faces.
 
DiscretePDF m_pdf
 
- Protected Attributes inherited from Shape
BSDFm_bsdf = nullptr
 BSDF of the surface.
 
Emitterm_emitter = nullptr
 Associated emitter, if any.
 
BoundingBox3f m_bbox
 Bounding box of the mesh.
 
- Protected Attributes inherited from NoriObject
std::string m_idname
 

Additional Inherited Members

- Public Types inherited from NoriObject
enum  EClassType {
  EScene = 0 , EMesh , ETexture , EBSDF ,
  EPhaseFunction , EEmitter , EMedium , ECamera ,
  EIntegrator , ESampler , ETest , EReconstructionFilter ,
  EClassTypeCount
}
 
- Static Public Member Functions inherited from NoriObject
static std::string classTypeName (EClassType type)
 Turn a class type into a human-readable string.
 

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 35 of file mesh.h.

Member Function Documentation

◆ rayIntersect()

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

Ray-triangle intersection test.

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

Note that the test only applies to a single triangle in the mesh. An acceleration data structure like BVH is needed to search for intersections against many triangles.

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

Implements Shape.

Definition at line 83 of file mesh.cpp.


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