Loads object models from file and renders using VBOs/VAOs.
More...
#include <ModelLoader.hpp>
|
|
| ModelLoader () |
| | Creates an empty model.
|
| |
| | ModelLoader (const char *filename) |
| | Loads a model from the given file.
|
| |
|
| ~ModelLoader () |
| | Frees memory associated with model on both CPU and GPU.
|
| |
|
| ModelLoader (const ModelLoader &)=delete |
| | do not allow models to be copied
|
| |
|
ModelLoader & | operator= (const ModelLoader &)=delete |
| | do not allow models to be copied
|
| |
|
| ModelLoader (ModelLoader &&) noexcept |
| | move construct from an existing Model
|
| |
| ModelLoader & | operator= (ModelLoader &&) noexcept |
| |
| bool | loadModelFile (std::string filename, bool INFO=true, bool ERRORS=true) |
| | Loads a model from the given file.
|
| |
| void | setAttributeLocations (GLint positionLocation, GLint normalLocation=-1, GLint texCoordLocation=-1) const |
| | Enables VBO attribute array locations.
|
| |
| bool | draw (GLuint shaderProgramHandle, GLint matDiffLocation=-1, GLint matSpecLocation=-1, GLint matShinLocation=-1, GLint matAmbLocation=-1, GLenum diffuseTexture=GL_TEXTURE0) const |
| | Renders a model.
|
| |
| GLuint | getNumberOfVertices () const |
| | Return the number of vertices the model is made up of. This value corresponds to the size of the Vertices, TexCoords, and Normals arrays.
|
| |
| GLfloat * | getVertices () const |
| | Return the vertex array that makes up the model mesh.
|
| |
| GLfloat * | getNormals () const |
| | Return the normal array that corresponds to the model mesh.
|
| |
| GLfloat * | getTexCoords () const |
| | Return the texture coordinates array that corresponds to the model mesh.
|
| |
| GLuint | getNumberOfIndices () const |
| | Return the number of indices to draw the model. This value corresponds to the size of the Indices array.
|
| |
| GLuint * | getIndices () const |
| | Return the index array that dictates the order to draw the model mesh.
|
| |
Loads object models from file and renders using VBOs/VAOs.
◆ ModelLoader()
| CSCI441::ModelLoader::ModelLoader |
( |
const char * |
filename | ) |
|
|
inlineexplicit |
Loads a model from the given file.
- Parameters
-
| filename | file to load model from |
◆ disableAutoGenerateNormals()
| void CSCI441::ModelLoader::disableAutoGenerateNormals |
( |
| ) |
|
|
inlinestatic |
Disable auto-generation of vertex normals.
- Warning
- Must be called prior to loading in a model from file
- Note
- No normals are generated by default
-
To enable, call enableAutoGenerateNormals
◆ draw()
| bool CSCI441::ModelLoader::draw |
( |
GLuint |
shaderProgramHandle, |
|
|
GLint |
matDiffLocation = -1, |
|
|
GLint |
matSpecLocation = -1, |
|
|
GLint |
matShinLocation = -1, |
|
|
GLint |
matAmbLocation = -1, |
|
|
GLenum |
diffuseTexture = GL_TEXTURE0 |
|
) |
| const |
|
inline |
Renders a model.
- Parameters
-
| shaderProgramHandle | shader program handle that |
| matDiffLocation | uniform location of material diffuse component |
| matSpecLocation | uniform location of material specular component |
| matShinLocation | uniform location of material shininess component |
| matAmbLocation | uniform location of material ambient component |
| diffuseTexture | texture number to bind diffuse texture map to |
- Returns
- true if draw succeeded, false otherwise
◆ enableAutoGenerateNormals()
| void CSCI441::ModelLoader::enableAutoGenerateNormals |
( |
| ) |
|
|
inlinestatic |
Enable auto-generation of vertex normals.
- Warning
- Must be called prior to loading in a model from file
- Note
- If an object model does not contain vertex normal data, then normals will be computed based on the cross product of vertex winding order.
-
No normals are generated by default
-
To disable, call disableAutoGenerateNormals
◆ getIndices()
| GLuint * CSCI441::ModelLoader::getIndices |
( |
| ) |
const |
|
inline |
Return the index array that dictates the order to draw the model mesh.
- Returns
- pointer to the index array
- Note
- For use with IBOs
◆ getNormals()
| GLfloat * CSCI441::ModelLoader::getNormals |
( |
| ) |
const |
|
inline |
Return the normal array that corresponds to the model mesh.
- Returns
- pointer to the normal array
- Note
- For use with VBOs
◆ getNumberOfIndices()
| GLuint CSCI441::ModelLoader::getNumberOfIndices |
( |
| ) |
const |
|
inline |
Return the number of indices to draw the model. This value corresponds to the size of the Indices array.
- Returns
- the number of indices when drawing the model
◆ getNumberOfVertices()
| GLuint CSCI441::ModelLoader::getNumberOfVertices |
( |
| ) |
const |
|
inline |
Return the number of vertices the model is made up of. This value corresponds to the size of the Vertices, TexCoords, and Normals arrays.
- Returns
- the number of vertices within the model
◆ getTexCoords()
| GLfloat * CSCI441::ModelLoader::getTexCoords |
( |
| ) |
const |
|
inline |
Return the texture coordinates array that corresponds to the model mesh.
- Returns
- pointer to texture coordinate array
- Note
- For use with VBOs
◆ getVertices()
| GLfloat * CSCI441::ModelLoader::getVertices |
( |
| ) |
const |
|
inline |
Return the vertex array that makes up the model mesh.
- Returns
- pointer to vertex array
- Note
- For use with VBOs
◆ loadModelFile()
| bool CSCI441::ModelLoader::loadModelFile |
( |
std::string |
filename, |
|
|
bool |
INFO = true, |
|
|
bool |
ERRORS = true |
|
) |
| |
|
inline |
Loads a model from the given file.
- Parameters
-
| filename | file to load model from |
| INFO | flag to control if informational messages should be displayed |
| ERRORS | flag to control if error messages should be displayed |
- Returns
- true if load succeeded, false otherwise
◆ operator=()
Move assign from an existing Model
- Returns
- newly configured object
◆ setAttributeLocations()
| void CSCI441::ModelLoader::setAttributeLocations |
( |
GLint |
positionLocation, |
|
|
GLint |
normalLocation = -1, |
|
|
GLint |
texCoordLocation = -1 |
|
) |
| const |
|
inline |
Enables VBO attribute array locations.
- Parameters
-
| positionLocation | attribute location of vertex position |
| normalLocation | attribute location of vertex normal |
| texCoordLocation | attribute location of vertex texture coordinate |
The documentation for this class was generated from the following file: