CSCI441 OpenGL Library 5.25.0.0
CS@Mines CSCI441 Computer Graphics Course Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
CSCI441::MD5Model Class Reference

stores a Doom3 MD5 Mesh + Animation More...

#include <MD5Model.hpp>

Public Member Functions

 MD5Model ()
 initializes an empty MD5 Model
 
 ~MD5Model ()
 deallocates any used memory on the CPU and GPU
 
 MD5Model (const MD5Model &)=delete
 do not allow MD5 models to be copied
 
MD5Modeloperator= (const MD5Model &)=delete
 do not allow MD5 models to be copied
 
 MD5Model (MD5Model &&src) noexcept
 do not allow MD5 models to be moved
 
MD5Modeloperator= (MD5Model &&src) noexcept
 do not allow MD5 models to be moved
 
bool loadMD5Model (const char *MD5_MESH_FILE, const char *MD5_ANIM_FILE="")
 loads a corresponding md5mesh and md5anim file to the object
 
bool isAnimated () const
 returns if the MD5 Model has an accompanying animation
 
bool readMD5Model (const char *FILENAME)
 parses md5mesh file and allocates corresponding mesh data
 
void allocVertexArrays (GLuint vPosAttribLoc, GLuint vColorAttribLoc, GLuint vTexCoordAttribLoc, GLuint vNormalAttribLoc=0, GLuint vTangentAttribLoc=0)
 binds model VBOs to attribute pointer locations
 
void setActiveTextures (GLint diffuseMapActiveTexture, GLint specularMapActiveTexture, GLint normalMapActiveTexture, GLint heightMapActiveTexture)
 specify which texture targets each texture map should be bound to when rendering
 
void draw () const
 draws all the meshes that make up the model
 
void drawSkeleton () const
 draws the skeleton joints (as points) and bones (as lines)
 
bool readMD5Anim (const char *filename, GLushort targetAnimationIndex=0)
 reads in an animation sequence from an external file
 
bool addMD5Anim (const char *filename)
 adds another MD5 Animation sequence to the model's set of animation
 
GLushort getNumberOfAnimations () const
 returns the number of animations that were successfully loaded against the model
 
void useTargetAnimationIndex (GLushort targetAnimationIndex)
 update current animation to be running through
 
void animate (GLfloat dt)
 advances the model forward in its animation sequence the corresponding amount of time based on frame rate
 

Static Public Member Functions

static void readMD5Material (const char *FILENAME)
 loads textures corresponding to MD5 Shaders
 
static void releaseMD5Materials ()
 deletes textures from GPU that were registered during parsing of *.mtr file
 

Detailed Description

stores a Doom3 MD5 Mesh + Animation

Constructor & Destructor Documentation

◆ MD5Model()

CSCI441::MD5Model::MD5Model ( )
inline

initializes an empty MD5 Model

Note
need to call loadMD5Model() or readMD5Model() after construction to actually load in a mesh file

Member Function Documentation

◆ addMD5Anim()

bool CSCI441::MD5Model::addMD5Anim ( const char *  filename)
inline

adds another MD5 Animation sequence to the model's set of animation

Parameters
filename*.md5anim file to open add to animation list
Returns
true iff mesh and animation are compatible

◆ allocVertexArrays()

void CSCI441::MD5Model::allocVertexArrays ( GLuint  vPosAttribLoc,
GLuint  vColorAttribLoc,
GLuint  vTexCoordAttribLoc,
GLuint  vNormalAttribLoc = 0,
GLuint  vTangentAttribLoc = 0 
)
inline

binds model VBOs to attribute pointer locations

Parameters
vPosAttribLoclocation of vertex position attribute
vColorAttribLoclocation of vertex color attribute
vTexCoordAttribLoclocation of vertex texture coordinate attribute
vNormalAttribLoclocation of vertex normal attribute (defaults to 0 to disable usage)
vTangentAttribLoclocation of vertex tangent attribute (defaults to 0 to disable usage)
Note
color attribute used when drawing the skeleton
texCoord attribute used when drawing the mesh
vertex position attribute must not be zero, if any other attribute is zero it disables it

◆ animate()

void CSCI441::MD5Model::animate ( GLfloat  dt)
inline

advances the model forward in its animation sequence the corresponding amount of time based on frame rate

Parameters
dtdelta time since last frame

◆ getNumberOfAnimations()

GLushort CSCI441::MD5Model::getNumberOfAnimations ( ) const
inline

returns the number of animations that were successfully loaded against the model

Returns
number of animations loaded against the mesh
Note
if model is not animated, will return 0
calling addMD5Anim() increments this number when successfully loaded

◆ isAnimated()

bool CSCI441::MD5Model::isAnimated ( ) const
inline

returns if the MD5 Model has an accompanying animation

Returns
true if animation exists for model

◆ loadMD5Model()

bool CSCI441::MD5Model::loadMD5Model ( const char *  MD5_MESH_FILE,
const char *  MD5_ANIM_FILE = "" 
)
inline

loads a corresponding md5mesh and md5anim file to the object

Parameters
MD5_MESH_FILEname of file to load mesh from
MD5_ANIM_FILEname of file to load animation from
Returns
true if both mesh and animation loaded successfully and are compatible

◆ readMD5Anim()

bool CSCI441::MD5Model::readMD5Anim ( const char *  filename,
GLushort  targetAnimationIndex = 0 
)
inline

reads in an animation sequence from an external file

Parameters
filename*.md5anim file to open
targetAnimationIndexanimation index sequence to read into (defaults to first)
Returns
true iff mesh and animation are compatible

◆ readMD5Material()

void CSCI441::MD5Model::readMD5Material ( const char *  FILENAME)
inlinestatic

loads textures corresponding to MD5 Shaders

Parameters
FILENAME*.mtr file to open and load textures from
Note
registers textures on GPU

◆ readMD5Model()

bool CSCI441::MD5Model::readMD5Model ( const char *  FILENAME)
inline

parses md5mesh file and allocates corresponding mesh data

Parameters
FILENAME*.md5mesh file to load
Returns
true if file parsed successfully

◆ setActiveTextures()

void CSCI441::MD5Model::setActiveTextures ( GLint  diffuseMapActiveTexture = GL_TEXTURE0,
GLint  specularMapActiveTexture = GL_TEXTURE1,
GLint  normalMapActiveTexture = GL_TEXTURE2,
GLint  heightMapActiveTexture = GL_TEXTURE3 
)
inline

specify which texture targets each texture map should be bound to when rendering

Parameters
diffuseMapActiveTextureactive texture to bind the diffuse map to (default GL_TEXTURE0)
specularMapActiveTextureactive texture to bind the specular map to (default GL_TEXTURE1)
normalMapActiveTextureactive texture to bind the normal map to (default GL_TEXTURE2)
heightMapActiveTextureactive texture to bind the height map to (default GL_TEXTURE3)

◆ useTargetAnimationIndex()

void CSCI441::MD5Model::useTargetAnimationIndex ( GLushort  targetAnimationIndex)
inline

update current animation to be running through

Parameters
targetAnimationIndexanimation index to animate model through
Note
targetAnimationIndex must be within the range [0, getNumberOfAnimations()]

The documentation for this class was generated from the following file: