Contains vertices and triangles of a triangle mesh. More...
#include <triangle_mesh.h>
Public Member Functions | |
TriangleMesh (Progress *progress) | |
Constructor. | |
virtual | ~TriangleMesh () |
Destructor. | |
void | set_emissive (float e) |
Accessor. | |
float | emissive () const |
Accessor. | |
void | add_vertex (const Vertex &v) |
Append a vertex. | |
void | add_triangle (const Triangle &t) |
Append a triangle. | |
const Vertex & | vertex (uint i) const |
Accessor. | |
const Triangle & | triangle (uint i) const |
Accessor. | |
virtual const Geometry & | geometry () const =0 |
Access the geometry of this class (needed to abstract concepts like "mid-point" and "height"). | |
float | vertex_height (uint i) const |
Return height of a vertex. | |
void | set_vertex_height (uint i, float h) |
Set height of a vertex. | |
float | triangle_height_min (uint i) const |
Return minimum height of a triangle's vertices. | |
float | triangle_height_max (uint i) const |
Return maximum height of a triangle's vertices. | |
float | triangle_height_average (uint i) const |
Return mean height of a triangle's vertices. | |
const XYZ | triangle_normal (uint i) const |
Compute and return the normal to a triangle. | |
uint | which_colour_for_triangle (uint t) const |
Return which vertex colour to use for a triangle. | |
uint | vertices () const |
Returns number of vertices in mesh. | |
uint | triangles () const |
Returns number of triangles in mesh. | |
uint | triangles_of_colour0 () const |
Returns number of triangles in mesh indexing colour[0] of vertices. | |
uint | triangles_of_colour1 () const |
Returns number of triangles in mesh indexing colour[1] of vertices. | |
void | compute_vertex_normals () |
(Re-)computes vertex normals. | |
void | subdivide (const XYZ &variation, uint level, uint levels) |
Perform a single subdivision pass with perturbations up to the specified size. More... | |
void | subdivide (uint subdivisions, uint flat_subdivisions, const XYZ &variation) |
Perform a number of subdivisions, possibly some unperturbed ("flat"), and halving the perturbation variation each iteration. | |
void | write_povray (std::ofstream &out, bool exclude_alternate_colour, bool double_illuminate, bool no_shadow) const |
Dump the mesh to the file in a form suitable for use by POVRay. | |
void | write_blender (std::ofstream &out, const std::string &mesh_name, const FloatRGBA *fake_alpha) const |
Dump the mesh to the file in a form suitable for use by Blender. More... | |
Protected Member Functions | |
Vertex & | vertex (uint i) |
Accessor. | |
Triangle & | triangle (uint i) |
Accessor. | |
void | progress_start (uint steps, const std::string &info) const |
Convenience wrapper with null test. | |
void | progress_stall (const std::string &reason) const |
Convenience wrapper with null test. | |
void | progress_step (uint step) const |
Convenience wrapper with null test. | |
void | progress_complete (const std::string &info) const |
Convenience wrapper with null test. | |
Protected Attributes | |
std::vector< Vertex > | _vertex |
The vertices of this mesh. | |
std::vector< Triangle > | _triangle |
The triangles of this mesh. | |
uint | _triangle_switch_colour |
The index of the triangle at which we switch to the alternate colour. | |
float | _emissive |
The emission level for vertices with the _emissive flag set. | |
Progress *const | _progress |
Pointer to the progress object to which progress reports should be made. | |
Contains vertices and triangles of a triangle mesh.
Abstract base class because specific classes must specify a geometry. Not as general-purpose as it might be due to constraints imposed by OpenGL. In particular, Triangle can have no attributes (e.g normal, colour) if a single OpenGL call is to be made to draw all triangles, so this information is entirely associated with Vertex. Two colours can be associated with each vertex (required for fracplanet application to obtain sharp coastlines), and it it a requirement for subclasses to sort triangles so that all those before _triangle_switch_colour use vertex colour index 0, and those afterwards vertex colour index 1.
void TriangleMesh::subdivide | ( | const XYZ & | variation, |
uint | level, | ||
uint | levels | ||
) |
Perform a single subdivision pass with perturbations up to the specified size.
level parameter is just for progress information
void TriangleMesh::write_blender | ( | std::ofstream & | out, |
const std::string & | mesh_name, | ||
const FloatRGBA * | faux_alpha | ||
) | const |
Dump the mesh to the file in a form suitable for use by Blender.
If faux_alpha is null, output per-vertex alpha. If a colour is specified, use the vertex alpha to blend with it.