20 #if !defined(__MITSUBA_RENDER_TRIMESH_H_)
21 #define __MITSUBA_RENDER_TRIMESH_H_
47 : dpdu(dpdu), dpdv(dpdv) { }
49 dpdu(stream), dpdv(stream) {
53 dpdu.serialize(stream);
54 dpdv.serialize(stream);
58 std::ostringstream oss;
59 oss <<
"TangentSpace[dpdu=" << dpdu.toString() <<
", dpdv=" << dpdv.toString() <<
"]";
71 TriMesh(
const std::string &name,
72 size_t triangleCount,
size_t vertexCount,
73 bool hasNormals =
false,
74 bool hasTexcoords =
false,
75 bool hasVertexColors =
false,
76 bool flipNormals =
false,
77 bool faceNormals =
false);
185 const Point2 &sample)
const;
214 void computeUVTangents();
224 void computeNormals(
bool force =
false);
240 void rebuildTopology(
Float maxAngle);
301 static ref<TriMesh> fromBlender(
const std::string &name,
size_t faceCount,
void *facePtr,
302 size_t vertexCount,
void *vertexPtr,
void *uvPtr,
void *colPtr,
short matNr);
305 void writeOBJ(
const fs::path &path)
const;
308 void writePLY(
const fs::path &path)
const;
325 void loadCompressed(
Stream *stream,
int idx = 0);
334 static
short readHeader(
Stream *stream);
341 static
size_t readOffset(
Stream *stream,
short version,
int idx);
350 static
int readOffsetDictionary(
Stream *stream,
short version,
351 std::vector<
size_t>& outOffsets);
354 void prepareSamplingTable();
363 size_t m_triangleCount;
364 size_t m_vertexCount;
virtual ref< TriMesh > createTriMesh()
Create a triangle mesh approximation of this shape.
Color3 * getVertexColors()
Return the vertex colors.
Definition: trimesh.h:146
Three-dimensional normal data structure.
Definition: normal.h:39
Abstract triangle mesh base class.
Definition: trimesh.h:68
virtual void serialize(Stream *stream, InstanceManager *manager) const
Serialize this shape to a stream.
Simple triangle class including a collection of routines for analysis and transformation.
Definition: triangle.h:35
virtual size_t getPrimitiveCount() const =0
Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape...
Point2 * getVertexTexcoords()
Return the vertex texture coordinates.
Definition: trimesh.h:153
Vector dpdu
Position partial with respect to the U parameter of the local chart.
Definition: trimesh.h:40
virtual AABB getAABB() const =0
Return a bounding box containing the shape.
Generic sampling record for positions.
Definition: common.h:82
size_t getVertexCount() const
Return the number of vertices.
Definition: trimesh.h:124
TangentSpace * getUVTangents()
Return the per-triangle UV tangents.
Definition: trimesh.h:160
const Normal * getVertexNormals() const
Return the vertex normals (const version)
Definition: trimesh.h:137
Triangle * getTriangles()
Return the triangle list.
Definition: trimesh.h:129
const Point2 * getVertexTexcoords() const
Return the vertex texture coordinates (const version)
Definition: trimesh.h:151
TangentSpace(Stream *stream)
Definition: trimesh.h:48
TangentSpace()
Definition: trimesh.h:45
size_t getTriangleCount() const
Return the number of triangles.
Definition: trimesh.h:122
Abstract base class of all shapes.
Definition: shape.h:178
const Triangle * getTriangles() const
Return the triangle list (const version)
Definition: trimesh.h:127
RGB color data type.
Definition: spectrum.h:612
Point * getVertexPositions()
Return the vertex positions.
Definition: trimesh.h:134
const TangentSpace * getUVTangents() const
Return the per-triangle UV tangents (const version)
Definition: trimesh.h:158
void serialize(Stream *stream)
Definition: trimesh.h:52
Axis-aligned bounding box data structure in three dimensions.
Definition: aabb.h:437
virtual void getNormalDerivative(const Intersection &its, Vector &dndu, Vector &dndv, bool shadingFrame=true) const
Return the derivative of the normal vector with respect to the UV parameterization.
virtual void configure()
Called once after constructing the object.
bool hasVertexTexcoords() const
Does the mesh have vertex texture coordinates?
Definition: trimesh.h:155
virtual void samplePosition(PositionSamplingRecord &pRec, const Point2 &sample) const
Sample a point on the surface of this shape instance (with respect to the area measure) ...
Simple tangent space storage for surfaces.
Definition: trimesh.h:38
virtual Float getSurfaceArea() const
Return the shape's surface area.
Abstract seekable stream class.
Definition: stream.h:58
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
virtual Float pdfPosition(const PositionSamplingRecord &pRec) const
Query the probability density of samplePosition() for a particular point on the surface.
Reference counting helper.
Definition: ref.h:40
bool hasVertexColors() const
Does the mesh have vertex colors?
Definition: trimesh.h:148
const Color3 * getVertexColors() const
Return the vertex colors (const version)
Definition: trimesh.h:144
bool hasVertexNormals() const
Does the mesh have vertex normals?
Definition: trimesh.h:141
std::string toString() const
Definition: trimesh.h:57
virtual size_t getEffectivePrimitiveCount() const =0
Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape...
const Point * getVertexPositions() const
Return the vertex positions (const version)
Definition: trimesh.h:132
Normal * getVertexNormals()
Return the vertex normals.
Definition: trimesh.h:139
bool hasUVTangents() const
Does the mesh have UV tangent information?
Definition: trimesh.h:162
TangentSpace(const Vector &dpdu, const Vector &dpdv)
Definition: trimesh.h:46
Associative parameter map for constructing subclasses of ConfigurableObject.
Definition: properties.h:46
Container for all information related to a surface intersection.
Definition: shape.h:36
Vector dpdv
Position partial with respect to the V parameter of the local chart.
Definition: trimesh.h:43
Coordinates the serialization and unserialization of object graphs.
Definition: serialization.h:65
AABB & getAABB()
Return a bounding box containing the mesh.
Definition: trimesh.h:104
virtual std::string toString() const
Return a human-readable string representation of the object's contents.
Thin wrapper around the recursive boost thread lock.
Definition: lock.h:34
Discrete probability distribution.
Definition: pmf.h:35