Abstract triangle mesh base class. More...
#include <mitsuba/render/trimesh.h>
Public Member Functions | |
TriMesh (const std::string &name, size_t triangleCount, size_t vertexCount, bool hasNormals=false, bool hasTexcoords=false, bool hasVertexColors=false, bool flipNormals=false, bool faceNormals=false) | |
Create a new, empty triangle mesh with the specified state. More... | |
TriMesh (Stream *stream, InstanceManager *manager) | |
Unserialize a triangle mesh. More... | |
TriMesh (Stream *stream, int idx=0) | |
Unserialize a triangle mesh. More... | |
virtual const Class * | getClass () const |
Retrieve this object's class. More... | |
General query functions | |
Float | getSurfaceArea () const |
Return the total surface area. More... | |
AABB | getAABB () const |
Return a bounding box containing the mesh. More... | |
AABB & | getAABB () |
Return a bounding box containing the mesh. More... | |
ref< TriMesh > | createTriMesh () |
Create a triangle mesh approximation of this shape. More... | |
Access to the stored triangle mesh | |
size_t | getTriangleCount () const |
Return the number of triangles. More... | |
size_t | getVertexCount () const |
Return the number of vertices. More... | |
const Triangle * | getTriangles () const |
Return the triangle list (const version) More... | |
Triangle * | getTriangles () |
Return the triangle list. More... | |
const Point * | getVertexPositions () const |
Return the vertex positions (const version) More... | |
Point * | getVertexPositions () |
Return the vertex positions. More... | |
const Normal * | getVertexNormals () const |
Return the vertex normals (const version) More... | |
Normal * | getVertexNormals () |
Return the vertex normals. More... | |
bool | hasVertexNormals () const |
Does the mesh have vertex normals? More... | |
const Color3 * | getVertexColors () const |
Return the vertex colors (const version) More... | |
Color3 * | getVertexColors () |
Return the vertex colors. More... | |
bool | hasVertexColors () const |
Does the mesh have vertex colors? More... | |
const Point2 * | getVertexTexcoords () const |
Return the vertex texture coordinates (const version) More... | |
Point2 * | getVertexTexcoords () |
Return the vertex texture coordinates. More... | |
bool | hasVertexTexcoords () const |
Does the mesh have vertex texture coordinates? More... | |
const TangentSpace * | getUVTangents () const |
Return the per-triangle UV tangents (const version) More... | |
TangentSpace * | getUVTangents () |
Return the per-triangle UV tangents. More... | |
bool | hasUVTangents () const |
Does the mesh have UV tangent information? More... | |
Sampling routines | |
void | samplePosition (PositionSamplingRecord &pRec, const Point2 &sample) const |
Sample a point on the surface of this shape instance (with respect to the area measure) More... | |
Float | pdfPosition (const PositionSamplingRecord &pRec) const |
Query the probability density of samplePosition() for a particular point on the surface. More... | |
Public Member Functions inherited from mitsuba::Shape | |
virtual std::string | getName () const |
Return the name of this shape (e.g. the filename) More... | |
virtual bool | isCompound () const |
Is this a compound shape consisting of several sub-objects? More... | |
virtual Shape * | getElement (int i) |
Return a sub-element of a compound shape. More... | |
virtual AABB | getClippedAABB (const AABB &box) const |
Returns the minimal axis-aligned bounding box of this shape when clipped to another bounding box. More... | |
virtual bool | rayIntersect (const Ray &ray, Float mint, Float maxt, Float &t, void *temp) const |
Fast ray intersection test. More... | |
virtual bool | rayIntersect (const Ray &ray, Float mint, Float maxt) const |
Fast ray intersection test for visibility queries. More... | |
virtual void | fillIntersectionRecord (const Ray &ray, const void *temp, Intersection &its) const |
Given that an intersection has been found, create a detailed intersection record. More... | |
void | getCurvature (const Intersection &its, Float &H, Float &K, bool shadingFrame=true) const |
Compute the Gaussian and mean curvature at the given surface intersection. More... | |
virtual void | adjustTime (Intersection &its, Float time) const |
virtual const KDTreeBase< AABB > * | getKDTree () const |
Return the internal kd-tree of this shape (if any) More... | |
virtual void | sampleDirect (DirectSamplingRecord &dRec, const Point2 &sample) const |
Sample a point on the surface of this shape instance (with respect to the solid angle measure) More... | |
virtual Float | pdfDirect (const DirectSamplingRecord &dRec) const |
Query the probability density of sampleDirect() for a particular point on the surface. More... | |
bool | isMediumTransition () const |
Does the surface of this shape mark a medium transition? More... | |
Medium * | getInteriorMedium () |
Return the medium that lies on the interior of this shape (NULL == vacuum) More... | |
const Medium * | getInteriorMedium () const |
Return the medium that lies on the interior of this shape (NULL == vacuum, const version) More... | |
Medium * | getExteriorMedium () |
Return the medium that lies on the exterior of this shape (NULL == vacuum) More... | |
const Medium * | getExteriorMedium () const |
Return the medium that lies on the exterior of this shape (NULL == vacuum, const version) More... | |
bool | hasSubsurface () const |
Does this shape have a sub-surface integrator? More... | |
Subsurface * | getSubsurface () |
Return the associated sub-surface integrator. More... | |
const Subsurface * | getSubsurface () const |
Return the associated sub-surface integrator. More... | |
bool | isEmitter () const |
Is this shape also an area emitter? More... | |
Emitter * | getEmitter () |
Return the associated emitter (if any) More... | |
const Emitter * | getEmitter () const |
Return the associated emitter (if any) More... | |
void | setEmitter (Emitter *emitter) |
Set the emitter of this shape. More... | |
bool | isSensor () const |
Is this shape also an area sensor? More... | |
Sensor * | getSensor () |
Return the associated sensor (if any) More... | |
const Sensor * | getSensor () const |
Return the associated sensor (if any) More... | |
bool | hasBSDF () const |
Does the shape have a BSDF? More... | |
const BSDF * | getBSDF () const |
Return the shape's BSDF. More... | |
BSDF * | getBSDF () |
Return the shape's BSDF. More... | |
void | setBSDF (BSDF *bsdf) |
Set the BSDF of this shape. More... | |
void | copyAttachments (Shape *shape) |
Copy attachments (BSDF, Emitter, ..) from another shape. More... | |
void | addChild (const std::string &name, ConfigurableObject *child) |
Add a child (e.g. a emitter/sub surface integrator) to this shape. More... | |
void | addChild (ConfigurableObject *child) |
Add an unnamed child. More... | |
Public Member Functions inherited from mitsuba::ConfigurableObject | |
virtual void | setParent (ConfigurableObject *parent) |
Notify the ConfigurableObject instance about its parent object. More... | |
void | addChild (ConfigurableObject *child) |
Add an unnamed child. More... | |
const std::string & | getID () const |
Return the identifier associated with this instance (or "unnamed") More... | |
void | setID (const std::string &name) |
Set the identifier associated with this instance. More... | |
const Properties & | getProperties () const |
Return the properties object that was originally used to create this instance. More... | |
Public Member Functions inherited from mitsuba::SerializableObject | |
SerializableObject (Stream *stream, InstanceManager *manager) | |
Unserialize a serializable object. More... | |
Public Member Functions inherited from Object | |
Object () | |
Construct a new object. More... | |
int | getRefCount () const |
Return the current reference count. More... | |
void | incRef () const |
Increase the reference count of the object by one. More... | |
void | decRef (bool autoDeallocate=true) const |
Decrease the reference count of the object and possibly deallocate it. More... | |
Static Public Attributes | |
static Class * | m_theClass |
Static Public Attributes inherited from mitsuba::Shape | |
static Class * | m_theClass |
Static Public Attributes inherited from mitsuba::ConfigurableObject | |
static Class * | m_theClass |
Static Public Attributes inherited from mitsuba::SerializableObject | |
static Class * | m_theClass |
Static Public Attributes inherited from Object | |
static Class * | m_theClass |
Pointer to the object's class descriptor. More... | |
Protected Member Functions | |
TriMesh (const Properties &props) | |
Create a new triangle mesh. More... | |
virtual | ~TriMesh () |
Virtual destructor. More... | |
void | loadCompressed (Stream *stream, int idx=0) |
Load a Mitsuba compressed triangle mesh substream. More... | |
void | prepareSamplingTable () |
Prepare internal tables for sampling uniformly wrt. area. More... | |
Protected Member Functions inherited from mitsuba::Shape | |
Shape (const Properties &props) | |
Create a new shape. More... | |
Shape (Stream *stream, InstanceManager *manager) | |
Unserialize a shape. More... | |
virtual | ~Shape () |
Virtual destructor. More... | |
Protected Member Functions inherited from mitsuba::ConfigurableObject | |
virtual | ~ConfigurableObject () |
Virtual destructor. More... | |
ConfigurableObject (const Properties &props) | |
Construct a configurable object. More... | |
ConfigurableObject (Stream *stream, InstanceManager *manager) | |
Unserialize a configurable object. More... | |
Protected Member Functions inherited from mitsuba::SerializableObject | |
SerializableObject () | |
Construct a serializable object. More... | |
virtual | ~SerializableObject () |
Virtual deconstructor. More... | |
Protected Member Functions inherited from Object | |
virtual | ~Object () |
Virtual private deconstructor. (Will only be called by ref) More... | |
Static Protected Member Functions | |
static short | readHeader (Stream *stream) |
Reads the header information of a compressed file, returning the version ID. More... | |
static size_t | readOffset (Stream *stream, short version, int idx) |
Read the idx-th entry from the offset diccionary at the end of the stream, which has to be open already, given the file version tag. This function modifies the position of the stream. More... | |
static int | readOffsetDictionary (Stream *stream, short version, std::vector< size_t > &outOffsets) |
Read the entirety of the end-of-file offset dictionary from the already open stream, replacing the contents of the input vector. If the file is not large enough the function returns -1 and does not modify the vector. This function modifies the position of the stream. More... | |
Protected Attributes | |
AABB | m_aabb |
Triangle * | m_triangles |
Point * | m_positions |
Normal * | m_normals |
Point2 * | m_texcoords |
TangentSpace * | m_tangents |
Color3 * | m_colors |
size_t | m_triangleCount |
size_t | m_vertexCount |
bool | m_flipNormals |
bool | m_faceNormals |
DiscreteDistribution | m_areaDistr |
Float | m_surfaceArea |
Float | m_invSurfaceArea |
ref< Mutex > | m_mutex |
Protected Attributes inherited from mitsuba::Shape | |
std::string | m_name |
ref< BSDF > | m_bsdf |
ref< Subsurface > | m_subsurface |
ref< Emitter > | m_emitter |
ref< Sensor > | m_sensor |
ref< Medium > | m_interiorMedium |
ref< Medium > | m_exteriorMedium |
Protected Attributes inherited from mitsuba::ConfigurableObject | |
Properties | m_properties |
Miscellaneous | |
void | computeUVTangents () |
Generate per-triangle space basis vectors from a user-specified set of UV coordinates. More... | |
void | computeNormals (bool force=false) |
Generate smooth vertex normals? More... | |
void | rebuildTopology (Float maxAngle) |
Rebuild the mesh so that adjacent faces with a dihedral angle greater than maxAngle degrees are topologically disconnected. More... | |
void | serialize (Stream *stream, InstanceManager *manager) const |
Serialize to a file/network stream. More... | |
void | serialize (Stream *stream) const |
Serialize to a file/network stream. More... | |
virtual void | configure () |
Build a discrete probability distribution for sampling. More... | |
void | getNormalDerivative (const Intersection &its, Vector &dndu, Vector &dndv, bool shadingFrame) const |
Return the derivative of the normal vector with respect to the UV parameterization. More... | |
size_t | getPrimitiveCount () const |
Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape. More... | |
size_t | getEffectivePrimitiveCount () const |
Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape. More... | |
void | writeOBJ (const fs::path &path) const |
Export a Wavefront OBJ version of this file. More... | |
void | writePLY (const fs::path &path) const |
Export a Stanford PLY version of this file. More... | |
std::string | toString () const |
Return a string representation. More... | |
static ref< TriMesh > | fromBlender (const std::string &name, size_t faceCount, void *facePtr, size_t vertexCount, void *vertexPtr, void *uvPtr, void *colPtr, short matNr) |
Import a shape from the Blender in-memory representation. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Object | |
static void | staticInitialization () |
Initializes the built-in reference count debugger (if enabled) More... | |
static void | staticShutdown () |
Free the memory taken by staticInitialization() More... | |
Abstract triangle mesh base class.
mitsuba::TriMesh::TriMesh | ( | const std::string & | name, |
size_t | triangleCount, | ||
size_t | vertexCount, | ||
bool | hasNormals = false , |
||
bool | hasTexcoords = false , |
||
bool | hasVertexColors = false , |
||
bool | flipNormals = false , |
||
bool | faceNormals = false |
||
) |
Create a new, empty triangle mesh with the specified state.
mitsuba::TriMesh::TriMesh | ( | Stream * | stream, |
InstanceManager * | manager | ||
) |
Unserialize a triangle mesh.
mitsuba::TriMesh::TriMesh | ( | Stream * | stream, |
int | idx = 0 |
||
) |
Unserialize a triangle mesh.
This is an alternative routine, which only loads triangle data (no BSDF, Sub-surface integrator, etc.) in a format that will remain stable as Mitsuba evolves. The files can optionally contain multiple meshes – in that case, the specified index determines which one to load.
|
protected |
Create a new triangle mesh.
|
protectedvirtual |
Virtual destructor.
void mitsuba::TriMesh::computeNormals | ( | bool | force = false | ) |
Generate smooth vertex normals?
force | When this parameter is set to true, the function generates normals even when there are already existing ones. |
void mitsuba::TriMesh::computeUVTangents | ( | ) |
Generate per-triangle space basis vectors from a user-specified set of UV coordinates.
Will throw an exception when no UV coordinates are associated with the mesh.
|
virtual |
Build a discrete probability distribution for sampling.
Called once while loading the scene
Reimplemented from mitsuba::Shape.
Create a triangle mesh approximation of this shape.
Since instances are already triangle meshes, the implementation just returns a pointer to this.
Reimplemented from mitsuba::Shape.
|
static |
Import a shape from the Blender in-memory representation.
|
virtual |
Return a bounding box containing the mesh.
Implements mitsuba::Shape.
|
inline |
Return a bounding box containing the mesh.
|
virtual |
Retrieve this object's class.
Reimplemented from mitsuba::Shape.
|
virtual |
Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape.
Includes instanced geometry
Implements mitsuba::Shape.
|
virtual |
Return the derivative of the normal vector with respect to the UV parameterization.
This can be used to compute Gaussian and principal curvatures, amongst other things.
its | Intersection record associated with the query |
dndu | Parameter used to store the partial derivative of the normal vector with respect to u |
dndv | Parameter used to store the partial derivative of the normal vector with respect to v |
shadingFrame | Specifies whether to compute the derivative of the geometric or shading normal of the surface |
Reimplemented from mitsuba::Shape.
|
virtual |
Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape.
Does not include instanced geometry
Implements mitsuba::Shape.
|
virtual |
Return the total surface area.
Reimplemented from mitsuba::Shape.
|
inline |
Return the number of triangles.
|
inline |
Return the triangle list (const version)
|
inline |
Return the triangle list.
|
inline |
Return the per-triangle UV tangents (const version)
|
inline |
Return the per-triangle UV tangents.
|
inline |
Return the vertex colors (const version)
|
inline |
Return the vertex colors.
|
inline |
Return the number of vertices.
|
inline |
Return the vertex normals (const version)
|
inline |
Return the vertex normals.
|
inline |
Return the vertex positions (const version)
|
inline |
Return the vertex positions.
|
inline |
Return the vertex texture coordinates (const version)
|
inline |
Return the vertex texture coordinates.
|
inline |
Does the mesh have UV tangent information?
|
inline |
Does the mesh have vertex colors?
|
inline |
Does the mesh have vertex normals?
|
inline |
Does the mesh have vertex texture coordinates?
|
protected |
Load a Mitsuba compressed triangle mesh substream.
|
virtual |
Query the probability density of samplePosition() for a particular point on the surface.
This method will generally return the inverse of the surface area.
pRec | A position record, which will be used to return the sampled position, as well as auxilary information about the sample. |
Reimplemented from mitsuba::Shape.
|
protected |
Prepare internal tables for sampling uniformly wrt. area.
|
staticprotected |
Reads the header information of a compressed file, returning the version ID.
This function assumes the stream is at the beginning of the compressed file and leaves the stream located right after the header.
|
staticprotected |
Read the idx-th entry from the offset diccionary at the end of the stream, which has to be open already, given the file version tag. This function modifies the position of the stream.
|
staticprotected |
Read the entirety of the end-of-file offset dictionary from the already open stream, replacing the contents of the input vector. If the file is not large enough the function returns -1 and does not modify the vector. This function modifies the position of the stream.
void mitsuba::TriMesh::rebuildTopology | ( | Float | maxAngle | ) |
Rebuild the mesh so that adjacent faces with a dihedral angle greater than maxAngle
degrees are topologically disconnected.
On the other hand, if the angle is less than maxAngle, the code ensures that the faces reference the same vertices. This step is very useful as a pre-process when generating high-quality smooth shading normals on meshes with creases. Note: this function is fairly memory intensive and will require approximately three 3x the storate used by the input mesh. It will never try to merge vertices with equal positions but different UV coordinates or vertex colors.
|
virtual |
Sample a point on the surface of this shape instance (with respect to the area measure)
The returned sample density will be uniform over the surface.
pRec | A position record, which will be used to return the sampled position, as well as auxilary information about the sample. |
sample | A uniformly distributed 2D vector |
Reimplemented from mitsuba::Shape.
|
virtual |
Serialize to a file/network stream.
Reimplemented from mitsuba::Shape.
void mitsuba::TriMesh::serialize | ( | Stream * | stream | ) | const |
Serialize to a file/network stream.
This is an alternative routine, which only loads triangle data (no BSDF, Sub-surface integrator, etc.) in a format that will remain stable as Mitsuba evolves.
|
virtual |
Return a string representation.
Reimplemented from Object.
void mitsuba::TriMesh::writeOBJ | ( | const fs::path & | path | ) | const |
Export a Wavefront OBJ version of this file.
void mitsuba::TriMesh::writePLY | ( | const fs::path & | path | ) | const |
Export a Stanford PLY version of this file.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
protected |
|
protected |
|
protected |