|
virtual void | loadModel (const std::string &filename, bool insertDefaultMaterial=true, const MeshMaterialParams &defaultMaterial=MeshMaterialParams()) |
|
template<class Functor > |
void | forEachGroup (Functor functor) const |
|
template<class Functor > |
void | forEachGroup (Functor functor) |
|
int | getNumVertices () const |
|
int | getNumNormals () const |
|
int | getNumColors () const |
|
int | getNumTextureCoordinates () const |
|
int | getNumTriangles () const |
|
int | getNumGroups () const |
|
float * | getVertexData () |
|
const float * | getVertexData () const |
|
float * | getNormalData () |
|
const float * | getNormalData () const |
|
unsigned char * | getColorData () |
|
const unsigned char * | getColorData () const |
|
float * | getTextureCoordinateData () |
|
const float * | getTextureCoordinateData () const |
|
int | getVertexStride () const |
|
int | getNormalStride () const |
|
int | getColorStride () const |
|
int | getTextureCoordinateStride () const |
|
const float * | getBBoxMin () const |
|
const float * | getBBoxMax () const |
|
void | updateBBox () |
|
const std::string & | getMaterialLibraryName () const |
|
MeshGroup & | getMeshGroup (const std::string &group_name) |
|
const MeshGroup & | getMeshGroup (const std::string &group_name) const |
|
size_t | getMaterialCount () const |
|
void | setMeshMaterialParams (int i, const MeshMaterialParams ¶ms) |
|
MeshMaterialParams & | getMeshMaterialParams (int i) |
|
const MeshMaterialParams & | getMeshMaterialParams (int i) const |
|
void | setMeshGrouping (MeshGrouping grouping) |
|
MeshGrouping | getMeshGrouping () const |
|
void | loadFromObj (const std::string &filename, bool insertDefaultMaterial, const MeshMaterialParams &defaultMaterial) |
|
void | loadMaterials (const std::string &material_filename) |
|
void | loadFromPly (const std::string &filename, bool insertDefaultMaterial, const MeshMaterialParams &defaultMaterial) |
|
|
void | setVertexData (float *vertex_data) |
|
void | setNormalData (float *normal_data) |
|
void | setColorData (unsigned char *color_data) |
|
void | setTextureCoordinateData (float *texture_coordinate_data) |
|
void | setMaterialIndices (int *material_indices) |
|
void | setVertexStride (int vertex_stride) |
|
void | setNormalStride (int normal_stride) |
|
void | setColorStride (int color_stride) |
|
void | setTextureCoordinateStride (int texture_coordinate_stride) |
|
void | setVertexIndexStride (int index_stride) |
|
void | setNormalIndexStride (int index_stride) |
|
void | setColorIndexStride (int index_stride) |
|
void | setTextureIndexStride (int index_stride) |
|
const std::string & | getFilename () const |
|
const std::string & | getPathName () const |
|
virtual int | getVertexTriangleSize () const =0 |
|
virtual int | getNormalTriangleSize () const =0 |
|
virtual int | getTextureTriangleSize () const =0 |
|
virtual void | preProcess ()=0 |
|
virtual void | allocateData ()=0 |
|
virtual void | startWritingData ()=0 |
|
virtual void | postProcess ()=0 |
|
virtual void | finishWritingData ()=0 |
|
void | computeAabb () |
|
◆ allocateData()
virtual void MeshBase::allocateData |
( |
| ) |
|
|
protectedpure virtual |
Call this to allocate all data for the mesh after setting num_vertices, num_normals, num_colors, and num_texture_coordinates, as well as num_triangles for all the groups.
Implemented in MeshLoader.
◆ finishWritingData()
virtual void MeshBase::finishWritingData |
( |
| ) |
|
|
protectedpure virtual |
Call this when done writing to data or group data.
Implemented in MeshLoader.
◆ forEachGroup()
template<class Functor >
void MeshBase::forEachGroup |
( |
Functor |
functor | ) |
const |
Calls functor( group ) for each group in the mesh, where 'group' is of the type MeshGroup.
◆ getVertexTriangleSize()
virtual int MeshBase::getVertexTriangleSize |
( |
| ) |
const |
|
protectedpure virtual |
These pure virtual functions allow subclasses to control much about the loading behavior.
Implemented in MeshLoader.
◆ loadFromPly()
void MeshBase::loadFromPly |
( |
const std::string & |
filename, |
|
|
bool |
insertDefaultMaterial, |
|
|
const MeshMaterialParams & |
defaultMaterial |
|
) |
| |
Similar to loadFromObj() bur for .ply files
◆ loadMaterials()
void MeshBase::loadMaterials |
( |
const std::string & |
material_filename | ) |
|
◆ loadModel()
The load() method provides the overall model loading algorithm, which calls upon pure virtual functions which must override. The algorithm is as follows, where 'function()' indicates a call to one of the pure virtual functions:
- preProcess()
- Does a first pass on the model file to collect information about the number of vertices, normals, colors, and texture coordinates in the file, which it stores in the mesh's fields 'num_vertices', 'num_normals', etc. The first pass also creates the 'groups' structure with 'num_triangles' set for each group'.
- allocateData(), which allocates arrays, buffers, or whatever may be required for the subclass to own the data; the numbers collected during the "first pass" can be used for allocation sizes.
- startWritingData(), which is useful for cases where the subclass must first prepare for being written to, such as mapping Buffers, in the case of OptiX buffers.
- The second pass, in which it actually loads the data from the model file and stores it in the array pointers vertex_data, normal_data, color_data, and texture_coordinate_data, which should have been properly initalized to receive writes, either during allocateData() or startWritingData(). If any of these *_data pointers are '0', they will not be written to. Each group in the groups structure should also have had its field pointers vertex_indices, normal_indices, etc. initialized.
- Computes the bounding box on the model.
- postProcess(),
- finishWritingData(), for any cleanup that must be done, such as unmapping OptiX buffers.
Note that for uniformity with .ply loading, and for the accuracy of external algorithms that iterate over vertices (such as bounding box computation), or other alforithms that require an accurate count of the number of vertices actually used, 1-based indexing in .obj files is translated to 0-based indexing.
◆ postProcess()
virtual void MeshBase::postProcess |
( |
| ) |
|
|
protectedpure virtual |
An injection point for subclasses to do load postprocessing
Implemented in MeshLoader.
◆ preProcess()
virtual void MeshBase::preProcess |
( |
| ) |
|
|
protectedpure virtual |
An injection point for subclasses to do any prep before file info is loaded
Implemented in MeshLoader.
◆ setVertexData()
void MeshBase::setVertexData |
( |
float * |
vertex_data | ) |
|
|
inlineprotected |
Accessors for derived classes
◆ startWritingData()
virtual void MeshBase::startWritingData |
( |
| ) |
|
|
protectedpure virtual |
Call this before writing any data to the mesh, to set up correct pointer values to write to for vertex_data, normal_data, etc., as well as vertex_indices, normal_indices, etc. for each of the groups.
Call finishWritingData() when done.
Implemented in MeshLoader.
The documentation for this class was generated from the following files:
- C:/p4research/research/jpantaleoni/Fermat-Public/src/mesh/MeshBase.h
- C:/p4research/research/jpantaleoni/Fermat-Public/src/mesh/MeshBase.cpp