- CSCI441 OpenGL Library 5.3.0
+ CSCI441 OpenGL Library 5.4.0
CS@Mines CSCI441 Computer Graphics Course Library
|
@@ -121,1012 +121,1014 @@
56#include <glm/exponential.hpp>
57#include <glm/ext/quaternion_common.hpp>
58#include <glm/ext/quaternion_float.hpp>
- 59#include <glm/gtx/quaternion.hpp>
-
-
-
-
-
-
-
-
+
+ 60#define GLM_ENABLE_EXPERIMENTAL
+ 61#include <glm/gtx/quaternion.hpp>
+
+
+
+
+
+
-
-
-
-
- 83 static const GLint NULL_JOINT = -1;
-
- 91 GLint parent = NULL_JOINT;
- 95 glm::vec3 position = {0.0f, 0.0f, 0.0f};
- 99 glm::quat orientation = {0.0f, 0.0f, 0.0f, 0.0f};
-
-
-
- 109 glm::vec2 texCoord = {0.0f, 0.0f};
-
-
-
-
-
- 127 GLint index[3] = {0};
-
-
-
- 137 GLint joint = MD5Joint::NULL_JOINT;
-
- 145 glm::vec3 position = {0.0f, 0.0f, 0.0f};
-
-
-
- 155 GLuint texHandle = 0;
- 159 char filename[512] =
"";
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 207 GLint numVertices = 0;
- 211 GLint numTriangles = 0;
- 215 GLint numWeights = 0;
-
- 220 char shader[512] =
"";
-
-
-
-
-
- 235 GLint parent = MD5Joint::NULL_JOINT;
-
- 243 GLint startIndex = 0;
-
-
-
- 253 glm::vec3 position = {0.0f, 0.0f, 0.0f};
- 257 glm::quat orientation = {0.0f, 0.0f, 0.0f, 0.0f};
-
-
-
- 268 glm::vec3 min = {0.0f, 0.0f, 0.0f};
- 272 glm::vec3 max = {0.0f, 0.0f, 0.0f};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 320 GLfloat lastTime = 0.0f;
- 325 GLfloat maxTime = 0.0f;
-
-
-
-
-
-
-
-
-
- 354 [[maybe_unused]]
bool loadMD5Model(
const char* MD5_MESH_FILE,
const char* MD5_ANIM_FILE =
"");
-
- 360 [[nodiscard]]
bool isAnimated()
const {
return _isAnimated; }
-
-
- 368 [[nodiscard]]
bool readMD5Model(
const char* FILENAME);
- 377 [[maybe_unused]]
void allocVertexArrays(GLuint vPosAttribLoc, GLuint vColorAttribLoc, GLuint vTexCoordAttribLoc);
- 381 [[maybe_unused]]
void draw()
const;
- 385 [[maybe_unused]]
void drawSkeleton()
const;
-
-
- 393 [[nodiscard]]
bool readMD5Anim(
const char* filename);
- 398 void animate(GLfloat dt);
-
-
- 401 MD5Joint* _baseSkeleton;
-
-
-
-
-
-
-
-
-
- 411 glm::vec3* _vertexArray;
- 412 glm::vec2* _texelArray;
- 413 GLuint* _vertexIndicesArray;
-
-
-
-
-
-
-
-
- 428 MD5Animation _animation;
-
- 436 MD5AnimationState _animationInfo;
-
- 438 void _prepareMesh(
const MD5Mesh* pMESH)
const;
- 439 void _drawMesh(
const MD5Mesh* pMESH)
const;
- 440 [[nodiscard]]
bool _checkAnimValidity()
const;
- 441 static void _buildFrameSkeleton(
const MD5JointInfo* pJOINT_INFOS,
- 442 const MD5BaseFrameJoint* pBASE_FRAME,
- 443 const GLfloat* pANIM_FRAME_DATA,
- 444 MD5Joint* pSkeletonFrame,
-
- 446 void _interpolateSkeletons(GLfloat interp);
-
- 448 void _freeVertexArrays();
-
-
-
-
-
+
+
+
+
+
+
+ 85 static const GLint NULL_JOINT = -1;
+
+ 93 GLint parent = NULL_JOINT;
+ 97 glm::vec3 position = {0.0f, 0.0f, 0.0f};
+ 101 glm::quat orientation = {0.0f, 0.0f, 0.0f, 0.0f};
+
+
+
+ 111 glm::vec2 texCoord = {0.0f, 0.0f};
+
+
+
+
+
+ 129 GLint index[3] = {0};
+
+
+
+ 139 GLint joint = MD5Joint::NULL_JOINT;
+
+ 147 glm::vec3 position = {0.0f, 0.0f, 0.0f};
+
+
+
+ 157 GLuint texHandle = 0;
+ 161 char filename[512] =
"";
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 209 GLint numVertices = 0;
+ 213 GLint numTriangles = 0;
+ 217 GLint numWeights = 0;
+
+ 222 char shader[512] =
"";
+
+
+
+
+
+ 237 GLint parent = MD5Joint::NULL_JOINT;
+
+ 245 GLint startIndex = 0;
+
+
+
+ 255 glm::vec3 position = {0.0f, 0.0f, 0.0f};
+ 259 glm::quat orientation = {0.0f, 0.0f, 0.0f, 0.0f};
+
+
+
+ 270 glm::vec3 min = {0.0f, 0.0f, 0.0f};
+ 274 glm::vec3 max = {0.0f, 0.0f, 0.0f};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 322 GLfloat lastTime = 0.0f;
+ 327 GLfloat maxTime = 0.0f;
+
+
+
+
+
+
+
+
+
+ 356 [[maybe_unused]]
bool loadMD5Model(
const char* MD5_MESH_FILE,
const char* MD5_ANIM_FILE =
"");
+
+ 362 [[nodiscard]]
bool isAnimated()
const {
return _isAnimated; }
+
+
+ 370 [[nodiscard]]
bool readMD5Model(
const char* FILENAME);
+ 379 [[maybe_unused]]
void allocVertexArrays(GLuint vPosAttribLoc, GLuint vColorAttribLoc, GLuint vTexCoordAttribLoc);
+ 383 [[maybe_unused]]
void draw()
const;
+ 387 [[maybe_unused]]
void drawSkeleton()
const;
+
+
+ 395 [[nodiscard]]
bool readMD5Anim(
const char* filename);
+ 400 void animate(GLfloat dt);
+
+
+ 403 MD5Joint* _baseSkeleton;
+
+
+
+
+
+
+
+
+
+ 413 glm::vec3* _vertexArray;
+ 414 glm::vec2* _texelArray;
+ 415 GLuint* _vertexIndicesArray;
+
+
+
+
+
+
+
+
+ 430 MD5Animation _animation;
+
+ 438 MD5AnimationState _animationInfo;
+
+ 440 void _prepareMesh(
const MD5Mesh* pMESH)
const;
+ 441 void _drawMesh(
const MD5Mesh* pMESH)
const;
+ 442 [[nodiscard]]
bool _checkAnimValidity()
const;
+ 443 static void _buildFrameSkeleton(
const MD5JointInfo* pJOINT_INFOS,
+ 444 const MD5BaseFrameJoint* pBASE_FRAME,
+ 445 const GLfloat* pANIM_FRAME_DATA,
+ 446 MD5Joint* pSkeletonFrame,
+
+ 448 void _interpolateSkeletons(GLfloat interp);
+
+ 450 void _freeVertexArrays();
+
+
+
-
-
- 457 _baseSkeleton =
nullptr;
-
-
-
-
-
- 463 _vertexArray =
nullptr;
- 464 _texelArray =
nullptr;
- 465 _vertexIndicesArray =
nullptr;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 488 const char* MD5_MESH_FILE,
- 489 const char* MD5_ANIM_FILE
-
-
- 492 if( readMD5Model(MD5_MESH_FILE) ) {
-
- 494 if(strcmp(MD5_ANIM_FILE,
"") != 0 ) {
-
- 496 if( !readMD5Anim(MD5_ANIM_FILE) ) {
-
-
-
- 500 if( !isAnimated() ) {
- 501 printf (
"[.MD5_ANIM_FILE]: no animation loaded.\n");
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 517 GLint currentMesh = 0;
-
-
-
- 521 GLint totalVertices = 0;
- 522 GLint totalWeights = 0;
- 523 GLint totalTriangles = 0;
-
- 525 GLfloat minX = 999999, minY = 999999, minZ = 999999;
- 526 GLfloat maxX = -999999, maxY = -999999, maxZ = -999999;
-
- 528 printf(
"[.md5mesh]: about to read %s\n", FILENAME );
+
+
+
+
+ 459 _baseSkeleton =
nullptr;
+
+
+
+
+
+ 465 _vertexArray =
nullptr;
+ 466 _texelArray =
nullptr;
+ 467 _vertexIndicesArray =
nullptr;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 490 const char* MD5_MESH_FILE,
+ 491 const char* MD5_ANIM_FILE
+
+
+ 494 if( readMD5Model(MD5_MESH_FILE) ) {
+
+ 496 if(strcmp(MD5_ANIM_FILE,
"") != 0 ) {
+
+ 498 if( !readMD5Anim(MD5_ANIM_FILE) ) {
+
+
+
+ 502 if( !isAnimated() ) {
+ 503 printf (
"[.MD5_ANIM_FILE]: no animation loaded.\n");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 519 GLint currentMesh = 0;
+
+
+
+ 523 GLint totalVertices = 0;
+ 524 GLint totalWeights = 0;
+ 525 GLint totalTriangles = 0;
+
+ 527 GLfloat minX = 999999, minY = 999999, minZ = 999999;
+ 528 GLfloat maxX = -999999, maxY = -999999, maxZ = -999999;
- 530 fp = fopen(FILENAME,
"rb" );
-
- 532 fprintf (stderr,
"[.md5mesh]: Error: couldn't open \"%s\"!\n", FILENAME);
-
-
-
-
-
- 538 fgets( buff,
sizeof(buff), fp );
-
- 540 if( sscanf(buff,
" MD5Version %d", &version) == 1 ) {
- 541 if( version != 10 ) {
-
- 543 fprintf (stderr,
"[.md5mesh]: Error: bad model version\n");
-
-
-
- 547 }
else if( sscanf(buff,
" numJoints %d", &_numJoints) == 1 ) {
- 548 if( _numJoints > 0 ) {
-
- 550 _baseSkeleton =
new MD5Joint[_numJoints];
-
- 552 }
else if( sscanf(buff,
" numMeshes %d", &_numMeshes) == 1 ) {
- 553 if( _numMeshes > 0 ) {
-
- 555 _meshes =
new MD5Mesh[_numMeshes];
-
- 557 }
else if( strncmp(buff,
"joints {", 8) == 0 ) {
-
- 559 for(i = 0; i < _numJoints; ++i) {
- 560 MD5Joint *joint = &_baseSkeleton[i];
-
-
- 563 fgets( buff,
sizeof(buff), fp );
-
- 565 if( sscanf(buff,
"%s %d ( %f %f %f ) ( %f %f %f )",
-
-
-
-
-
-
-
-
- 574 }
else if( strncmp(buff,
"mesh {", 6) == 0 ) {
- 575 MD5Mesh *mesh = &_meshes[currentMesh];
- 576 GLint vert_index = 0;
-
- 578 GLint weight_index = 0;
-
-
-
- 582 while( buff[0] !=
'}' && !feof(fp) ) {
-
- 584 fgets( buff,
sizeof(buff), fp );
-
- 586 if( strstr( buff,
"shader ") ) {
- 587 GLint quote = 0, j = 0;
-
-
- 590 for(uli = 0; uli <
sizeof(buff) && (quote < 2); ++uli) {
- 591 if( buff[uli] ==
'\"' )
-
-
- 594 if( (quote == 1) && (buff[uli] !=
'\"') ) {
- 595 mesh->
shader[j] = buff[uli];
-
-
-
-
-
-
-
-
- 604 mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
- 608 mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
- 612 mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture(mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
-
-
-
- 619 mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
- 623 mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
-
-
- 629 mesh->
textures[MD5Mesh::TextureMap::NORMAL].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::NORMAL].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
- 633 mesh->
textures[MD5Mesh::TextureMap::NORMAL].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::NORMAL].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
-
-
- 639 mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
-
- 643 mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
-
-
- 646 }
else if( sscanf(buff,
" numverts %d", &mesh->
numVertices) == 1 ) {
-
-
-
-
-
-
-
-
-
- 656 }
else if( sscanf(buff,
" numtris %d", &mesh->
numTriangles) == 1 ) {
-
-
-
-
-
-
-
-
-
- 666 }
else if( sscanf(buff,
" numweights %d", &mesh->
numWeights) == 1 ) {
-
-
-
-
-
-
- 673 }
else if( sscanf(buff,
" vert %d ( %f %f ) %d %d",
-
- 675 &fdata[0], &fdata[1],
- 676 &idata[0], &idata[1]) == 5
-
-
-
-
-
-
- 683 }
else if( sscanf(buff,
" tri %d %d %d %d",
-
- 685 &idata[0], &idata[1], &idata[2]) == 4
-
-
-
-
-
- 691 }
else if( sscanf(buff,
" weight %d %d %f ( %f %f %f )",
- 692 &weight_index, &idata[0], &fdata[3],
- 693 &fdata[0], &fdata[1], &fdata[2]) == 6
-
-
-
-
-
-
-
-
- 702 if( fdata[0] < minX ) { minX = fdata[0]; }
- 703 if( fdata[0] > maxX ) { maxX = fdata[0]; }
- 704 if( fdata[1] < minY ) { minY = fdata[1]; }
- 705 if( fdata[1] > maxY ) { maxY = fdata[1]; }
- 706 if( fdata[2] < minZ ) { minZ = fdata[2]; }
- 707 if( fdata[2] > maxZ ) { maxZ = fdata[2]; }
-
-
-
-
-
-
-
-
+ 530 printf(
"[.md5mesh]: about to read %s\n", FILENAME );
+
+ 532 fp = fopen(FILENAME,
"rb" );
+
+ 534 fprintf (stderr,
"[.md5mesh]: Error: couldn't open \"%s\"!\n", FILENAME);
+
+
+
+
+
+ 540 fgets( buff,
sizeof(buff), fp );
+
+ 542 if( sscanf(buff,
" MD5Version %d", &version) == 1 ) {
+ 543 if( version != 10 ) {
+
+ 545 fprintf (stderr,
"[.md5mesh]: Error: bad model version\n");
+
+
+
+ 549 }
else if( sscanf(buff,
" numJoints %d", &_numJoints) == 1 ) {
+ 550 if( _numJoints > 0 ) {
+
+ 552 _baseSkeleton =
new MD5Joint[_numJoints];
+
+ 554 }
else if( sscanf(buff,
" numMeshes %d", &_numMeshes) == 1 ) {
+ 555 if( _numMeshes > 0 ) {
+
+ 557 _meshes =
new MD5Mesh[_numMeshes];
+
+ 559 }
else if( strncmp(buff,
"joints {", 8) == 0 ) {
+
+ 561 for(i = 0; i < _numJoints; ++i) {
+ 562 MD5Joint *joint = &_baseSkeleton[i];
+
+
+ 565 fgets( buff,
sizeof(buff), fp );
+
+ 567 if( sscanf(buff,
"%s %d ( %f %f %f ) ( %f %f %f )",
+
+
+
+
+
+
+
+
+ 576 }
else if( strncmp(buff,
"mesh {", 6) == 0 ) {
+ 577 MD5Mesh *mesh = &_meshes[currentMesh];
+ 578 GLint vert_index = 0;
+
+ 580 GLint weight_index = 0;
+
+
+
+ 584 while( buff[0] !=
'}' && !feof(fp) ) {
+
+ 586 fgets( buff,
sizeof(buff), fp );
+
+ 588 if( strstr( buff,
"shader ") ) {
+ 589 GLint quote = 0, j = 0;
+
+
+ 592 for(uli = 0; uli <
sizeof(buff) && (quote < 2); ++uli) {
+ 593 if( buff[uli] ==
'\"' )
+
+
+ 596 if( (quote == 1) && (buff[uli] !=
'\"') ) {
+ 597 mesh->
shader[j] = buff[uli];
+
+
+
+
+
+
+
+
+ 606 mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+ 610 mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+ 614 mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture(mesh->
textures[MD5Mesh::TextureMap::DIFFUSE].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+
+
+
+ 621 mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+ 625 mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::SPECULAR].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+
+
+ 631 mesh->
textures[MD5Mesh::TextureMap::NORMAL].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::NORMAL].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+ 635 mesh->
textures[MD5Mesh::TextureMap::NORMAL].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::NORMAL].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+
+
+ 641 mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+
+ 645 mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->
textures[MD5Mesh::TextureMap::HEIGHT].
filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT,
false );
+
+
+ 648 }
else if( sscanf(buff,
" numverts %d", &mesh->
numVertices) == 1 ) {
+
+
+
+
+
+
+
+
+
+ 658 }
else if( sscanf(buff,
" numtris %d", &mesh->
numTriangles) == 1 ) {
+
+
+
+
+
+
+
+
+
+ 668 }
else if( sscanf(buff,
" numweights %d", &mesh->
numWeights) == 1 ) {
+
+
+
+
+
+
+ 675 }
else if( sscanf(buff,
" vert %d ( %f %f ) %d %d",
+
+ 677 &fdata[0], &fdata[1],
+ 678 &idata[0], &idata[1]) == 5
+
+
+
+
+
+
+ 685 }
else if( sscanf(buff,
" tri %d %d %d %d",
+
+ 687 &idata[0], &idata[1], &idata[2]) == 4
+
+
+
+
+
+ 693 }
else if( sscanf(buff,
" weight %d %d %f ( %f %f %f )",
+ 694 &weight_index, &idata[0], &fdata[3],
+ 695 &fdata[0], &fdata[1], &fdata[2]) == 6
+
+
+
+
+
+
+
+
+ 704 if( fdata[0] < minX ) { minX = fdata[0]; }
+ 705 if( fdata[0] > maxX ) { maxX = fdata[0]; }
+ 706 if( fdata[1] < minY ) { minY = fdata[1]; }
+ 707 if( fdata[1] > maxY ) { maxY = fdata[1]; }
+ 708 if( fdata[2] < minZ ) { minZ = fdata[2]; }
+ 709 if( fdata[2] > maxZ ) { maxZ = fdata[2]; }
+
+
+
+
+
+
- 717 _skeleton = _baseSkeleton;
+
- 719 printf(
"[.md5mesh]: finished reading %s\n", FILENAME );
- 720 printf(
"[.md5mesh]: read in %d meshes, %d joints, %d vertices, %d weights, and %d triangles\n", _numMeshes, _numJoints, totalVertices, totalWeights, totalTriangles );
- 721 printf(
"[.md5mesh]: base pose %f units across in X, %f units across in Y, %f units across in Z\n", (maxX - minX), (maxY-minY), (maxZ - minZ) );
-
-
-
-
-
-
-
- 729CSCI441::MD5Model::_freeModel()
-
- 731 delete _baseSkeleton;
- 732 _baseSkeleton =
nullptr;
-
-
- 735 for(GLint i = 0; i < _numMeshes; ++i) {
- 736 delete _meshes[i].vertices;
- 737 _meshes[i].vertices =
nullptr;
-
- 739 delete _meshes[i].triangles;
- 740 _meshes[i].triangles =
nullptr;
-
- 742 delete _meshes[i].weights;
- 743 _meshes[i].weights =
nullptr;
-
-
-
-
-
-
-
-
-
-
-
- 755 for(GLint i = 0; i < _numMeshes; ++i) {
-
-
-
-
-
-
-
-
-
- 765CSCI441::MD5Model::_prepareMesh(
-
-
-
-
-
- 771 for(k = 0, i = 0; i < pMESH->numTriangles; ++i) {
- 772 for(j = 0; j < 3; ++j, ++k)
- 773 _vertexIndicesArray[k] = pMESH->triangles[i].index[j];
-
-
-
- 777 for(i = 0; i < pMESH->numVertices; ++i) {
- 778 glm::vec3 finalVertex = {0.0f, 0.0f, 0.0f };
-
-
- 781 for(j = 0; j < pMESH->vertices[i].count; ++j) {
- 782 const MD5Weight *weight = &pMESH->weights[pMESH->vertices[i].start + j];
- 783 const MD5Joint *joint = &_skeleton[weight->joint];
-
-
- 786 glm::vec3 weightedVertex;
- 787 weightedVertex = glm::rotate(joint->orientation, glm::vec4(weight->position, 0.0f));
-
-
- 790 finalVertex.x += (joint->position.x + weightedVertex.x) * weight->bias;
- 791 finalVertex.y += (joint->position.y + weightedVertex.y) * weight->bias;
- 792 finalVertex.z += (joint->position.z + weightedVertex.z) * weight->bias;
-
-
- 795 _vertexArray[i].x = finalVertex.x;
- 796 _vertexArray[i].y = finalVertex.y;
- 797 _vertexArray[i].z = finalVertex.z;
-
- 799 _texelArray[i].s = pMESH->vertices[i].texCoord.s;
- 800 _texelArray[i].t = pMESH->vertices[i].texCoord.t;
-
-
- 803 glBindVertexArray(_vao );
- 804 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
- 805 glBufferSubData(GL_ARRAY_BUFFER, 0,
sizeof(glm::vec3) * pMESH->numVertices, &_vertexArray[0] );
- 806 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _maxVertices,
sizeof(glm::vec2) * pMESH->numVertices, &_texelArray[0] );
- 807 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
- 808 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0,
sizeof(GLuint) * pMESH->numTriangles * 3, _vertexIndicesArray );
-
-
-
- 812CSCI441::MD5Model::_drawMesh(
-
-
-
- 816 glBindTexture(GL_TEXTURE_2D, pMESH->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle );
-
- 818 glBindVertexArray(_vao );
- 819 glDrawElements(GL_TRIANGLES, pMESH->numTriangles * 3, GL_UNSIGNED_INT, (
void*)
nullptr );
-
-
-
-
-
- 825 GLuint vPosAttribLoc,
- 826 GLuint vColorAttribLoc,
- 827 GLuint vTexCoordAttribLoc
-
- 829 _vertexArray =
new glm::vec3[_maxVertices];
- 830 _texelArray =
new glm::vec2[_maxVertices];
- 831 _vertexIndicesArray =
new GLuint[_maxTriangles * 3];
-
- 833 glGenVertexArrays( 1, &_vao );
- 834 glBindVertexArray(_vao );
-
- 836 glGenBuffers(2, _vbo );
- 837 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
- 838 glBufferData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _maxVertices +
sizeof(glm::vec2) * _maxVertices,
nullptr, GL_DYNAMIC_DRAW );
-
- 840 glEnableVertexAttribArray( vPosAttribLoc );
- 841 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (
void*)
nullptr );
-
- 843 glEnableVertexAttribArray( vTexCoordAttribLoc );
- 844 glVertexAttribPointer( vTexCoordAttribLoc, 2, GL_FLOAT, GL_FALSE, 0, (
void*)(
sizeof(glm::vec3) * _maxVertices) );
-
- 846 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
- 847 glBufferData(GL_ELEMENT_ARRAY_BUFFER,
sizeof(GLuint) * _maxTriangles * 3,
nullptr, GL_DYNAMIC_DRAW );
-
- 849 printf(
"[.md5mesh]: Model VAO/VBO/IBO registered at %u/%u/%u\n", _vao, _vbo[0], _vbo[1] );
+ 719 _skeleton = _baseSkeleton;
+
+ 721 printf(
"[.md5mesh]: finished reading %s\n", FILENAME );
+ 722 printf(
"[.md5mesh]: read in %d meshes, %d joints, %d vertices, %d weights, and %d triangles\n", _numMeshes, _numJoints, totalVertices, totalWeights, totalTriangles );
+ 723 printf(
"[.md5mesh]: base pose %f units across in X, %f units across in Y, %f units across in Z\n", (maxX - minX), (maxY-minY), (maxZ - minZ) );
+
+
+
+
+
+
+
+ 731CSCI441::MD5Model::_freeModel()
+
+ 733 delete _baseSkeleton;
+ 734 _baseSkeleton =
nullptr;
+
+
+ 737 for(GLint i = 0; i < _numMeshes; ++i) {
+ 738 delete _meshes[i].vertices;
+ 739 _meshes[i].vertices =
nullptr;
+
+ 741 delete _meshes[i].triangles;
+ 742 _meshes[i].triangles =
nullptr;
+
+ 744 delete _meshes[i].weights;
+ 745 _meshes[i].weights =
nullptr;
+
+
+
+
+
+
+
+
+
+
+
+ 757 for(GLint i = 0; i < _numMeshes; ++i) {
+
+
+
+
+
+
+
+
+
+ 767CSCI441::MD5Model::_prepareMesh(
+
+
+
+
+
+ 773 for(k = 0, i = 0; i < pMESH->numTriangles; ++i) {
+ 774 for(j = 0; j < 3; ++j, ++k)
+ 775 _vertexIndicesArray[k] = pMESH->triangles[i].index[j];
+
+
+
+ 779 for(i = 0; i < pMESH->numVertices; ++i) {
+ 780 glm::vec3 finalVertex = {0.0f, 0.0f, 0.0f };
+
+
+ 783 for(j = 0; j < pMESH->vertices[i].count; ++j) {
+ 784 const MD5Weight *weight = &pMESH->weights[pMESH->vertices[i].start + j];
+ 785 const MD5Joint *joint = &_skeleton[weight->joint];
+
+
+ 788 glm::vec3 weightedVertex;
+ 789 weightedVertex = glm::rotate(joint->orientation, glm::vec4(weight->position, 0.0f));
+
+
+ 792 finalVertex.x += (joint->position.x + weightedVertex.x) * weight->bias;
+ 793 finalVertex.y += (joint->position.y + weightedVertex.y) * weight->bias;
+ 794 finalVertex.z += (joint->position.z + weightedVertex.z) * weight->bias;
+
+
+ 797 _vertexArray[i].x = finalVertex.x;
+ 798 _vertexArray[i].y = finalVertex.y;
+ 799 _vertexArray[i].z = finalVertex.z;
+
+ 801 _texelArray[i].s = pMESH->vertices[i].texCoord.s;
+ 802 _texelArray[i].t = pMESH->vertices[i].texCoord.t;
+
+
+ 805 glBindVertexArray(_vao );
+ 806 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
+ 807 glBufferSubData(GL_ARRAY_BUFFER, 0,
sizeof(glm::vec3) * pMESH->numVertices, &_vertexArray[0] );
+ 808 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _maxVertices,
sizeof(glm::vec2) * pMESH->numVertices, &_texelArray[0] );
+ 809 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
+ 810 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0,
sizeof(GLuint) * pMESH->numTriangles * 3, _vertexIndicesArray );
+
+
+
+ 814CSCI441::MD5Model::_drawMesh(
+
+
+
+ 818 glBindTexture(GL_TEXTURE_2D, pMESH->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle );
+
+ 820 glBindVertexArray(_vao );
+ 821 glDrawElements(GL_TRIANGLES, pMESH->numTriangles * 3, GL_UNSIGNED_INT, (
void*)
nullptr );
+
+
+
+
+
+ 827 GLuint vPosAttribLoc,
+ 828 GLuint vColorAttribLoc,
+ 829 GLuint vTexCoordAttribLoc
+
+ 831 _vertexArray =
new glm::vec3[_maxVertices];
+ 832 _texelArray =
new glm::vec2[_maxVertices];
+ 833 _vertexIndicesArray =
new GLuint[_maxTriangles * 3];
+
+ 835 glGenVertexArrays( 1, &_vao );
+ 836 glBindVertexArray(_vao );
+
+ 838 glGenBuffers(2, _vbo );
+ 839 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
+ 840 glBufferData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _maxVertices +
sizeof(glm::vec2) * _maxVertices,
nullptr, GL_DYNAMIC_DRAW );
+
+ 842 glEnableVertexAttribArray( vPosAttribLoc );
+ 843 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (
void*)
nullptr );
+
+ 845 glEnableVertexAttribArray( vTexCoordAttribLoc );
+ 846 glVertexAttribPointer( vTexCoordAttribLoc, 2, GL_FLOAT, GL_FALSE, 0, (
void*)(
sizeof(glm::vec3) * _maxVertices) );
+
+ 848 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
+ 849 glBufferData(GL_ELEMENT_ARRAY_BUFFER,
sizeof(GLuint) * _maxTriangles * 3,
nullptr, GL_DYNAMIC_DRAW );
- 851 glGenVertexArrays( 1, &_skeletonVAO );
- 852 glBindVertexArray(_skeletonVAO );
-
- 854 glGenBuffers( 1, &_skeletonVBO );
- 855 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
- 856 glBufferData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints * 3 * 2,
nullptr, GL_DYNAMIC_DRAW );
-
- 858 glEnableVertexAttribArray( vPosAttribLoc );
- 859 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (
void*)
nullptr );
-
- 861 glEnableVertexAttribArray( vColorAttribLoc );
- 862 glVertexAttribPointer( vColorAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (
void*)(
sizeof(glm::vec3) * _numJoints * 3) );
-
- 864 printf(
"[.md5mesh]: Skeleton VAO/VBO registered at %u/%u\n", _skeletonVAO, _skeletonVBO );
-
-
-
- 868CSCI441::MD5Model::_freeVertexArrays()
-
- 870 delete[] _vertexArray;
- 871 _vertexArray =
nullptr;
-
- 873 delete[] _vertexIndicesArray;
- 874 _vertexIndicesArray =
nullptr;
-
- 876 delete[] _texelArray;
- 877 _texelArray =
nullptr;
-
- 879 glDeleteVertexArrays( 1, &_vao );
- 880 glDeleteBuffers(2, _vbo );
- 881 glDeleteVertexArrays( 1, &_skeletonVAO );
- 882 glDeleteBuffers( 1, &_skeletonVBO );
-
-
-
-
-
-
-
- 890 glBindVertexArray(_skeletonVAO );
- 891 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
-
- 893 glm::vec3 jointColor = {1.0f, 1.0f, 0.0f };
- 894 glm::vec3 boneColor = {1.0f, 0.0f, 1.0f };
-
-
- 897 for(GLint i = 0; i < _numJoints; ++i ) {
- 898 glBufferSubData(GL_ARRAY_BUFFER, i *
sizeof(glm::vec3),
sizeof(glm::vec3), &(_skeleton[i].position) );
- 899 glBufferSubData(GL_ARRAY_BUFFER, i *
sizeof(glm::vec3) +
sizeof(glm::vec3) * _numJoints * 3,
sizeof(glm::vec3), &jointColor[0]);
-
-
-
-
- 904 for(GLint i = 0; i < _numJoints; ++i ) {
- 905 if( _skeleton[i].parent != MD5Joint::NULL_JOINT ) {
- 906 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3),
sizeof(glm::vec3), &(_skeleton[_skeleton[i].parent].position) );
- 907 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3) +
sizeof(glm::vec3) * _numJoints * 3,
sizeof(glm::vec3), &boneColor[0]);
-
- 909 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3) +
sizeof(glm::vec3),
sizeof(glm::vec3), &(_skeleton[i].position) );
- 910 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3) +
sizeof(glm::vec3) +
sizeof(glm::vec3) * _numJoints * 3,
sizeof(glm::vec3), &boneColor[0]);
-
-
-
-
-
- 916 glDrawArrays(GL_POINTS, 0, _numJoints );
-
-
-
- 920 glDrawArrays(GL_LINES, _numJoints, numBones * 2 );
-
-
-
-
-
-
- 927CSCI441::MD5Model::_checkAnimValidity()
const
-
-
- 930 if( _numJoints != _animation.numJoints ) {
- 931 printf(
"\n[.md5anim]: skeleton and animation do not have same number of joints. cannot apply animation to skeleton\n\n");
-
-
-
-
- 936 for(GLint i = 0; i < _numJoints; ++i) {
-
- 938 if (_baseSkeleton[i].parent != _animation.skeletonFrames[0][i].parent) {
- 939 printf(
"\n[.md5anim]: skeleton and animation joints do not have same parent index. cannot apply animation to skeleton\n\n");
-
-
-
-
- 944 if (strcmp (_baseSkeleton[i].name, _animation.skeletonFrames[0][i].name) != 0) {
- 945 printf(
"\n[.md5anim]: skeleton and animation joints do not have same name. cannot apply animation to skeleton\n\n");
-
-
-
-
- 950 printf(
"\n[.md5anim]: skeleton and animation match. animation can be applied to skeleton\n\n");
-
-
-
-
-
- 956CSCI441::MD5Model::_buildFrameSkeleton(
- 957 const MD5JointInfo* pJOINT_INFOS,
- 958 const MD5BaseFrameJoint* pBASE_FRAME,
- 959 const GLfloat* pANIM_FRAME_DATA,
- 960 MD5Joint* pSkeletonFrame,
- 961 const GLint NUM_JOINTS
-
- 963 if(pJOINT_INFOS ==
nullptr
- 964 || pBASE_FRAME ==
nullptr
- 965 || pANIM_FRAME_DATA ==
nullptr
- 966 || pSkeletonFrame ==
nullptr)
return;
-
-
+ 851 printf(
"[.md5mesh]: Model VAO/VBO/IBO registered at %u/%u/%u\n", _vao, _vbo[0], _vbo[1] );
+
+ 853 glGenVertexArrays( 1, &_skeletonVAO );
+ 854 glBindVertexArray(_skeletonVAO );
+
+ 856 glGenBuffers( 1, &_skeletonVBO );
+ 857 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
+ 858 glBufferData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints * 3 * 2,
nullptr, GL_DYNAMIC_DRAW );
+
+ 860 glEnableVertexAttribArray( vPosAttribLoc );
+ 861 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (
void*)
nullptr );
+
+ 863 glEnableVertexAttribArray( vColorAttribLoc );
+ 864 glVertexAttribPointer( vColorAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (
void*)(
sizeof(glm::vec3) * _numJoints * 3) );
+
+ 866 printf(
"[.md5mesh]: Skeleton VAO/VBO registered at %u/%u\n", _skeletonVAO, _skeletonVBO );
+
+
+
+ 870CSCI441::MD5Model::_freeVertexArrays()
+
+ 872 delete[] _vertexArray;
+ 873 _vertexArray =
nullptr;
+
+ 875 delete[] _vertexIndicesArray;
+ 876 _vertexIndicesArray =
nullptr;
+
+ 878 delete[] _texelArray;
+ 879 _texelArray =
nullptr;
+
+ 881 glDeleteVertexArrays( 1, &_vao );
+ 882 glDeleteBuffers(2, _vbo );
+ 883 glDeleteVertexArrays( 1, &_skeletonVAO );
+ 884 glDeleteBuffers( 1, &_skeletonVBO );
+
+
+
+
+
+
+
+ 892 glBindVertexArray(_skeletonVAO );
+ 893 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
+
+ 895 glm::vec3 jointColor = {1.0f, 1.0f, 0.0f };
+ 896 glm::vec3 boneColor = {1.0f, 0.0f, 1.0f };
+
+
+ 899 for(GLint i = 0; i < _numJoints; ++i ) {
+ 900 glBufferSubData(GL_ARRAY_BUFFER, i *
sizeof(glm::vec3),
sizeof(glm::vec3), &(_skeleton[i].position) );
+ 901 glBufferSubData(GL_ARRAY_BUFFER, i *
sizeof(glm::vec3) +
sizeof(glm::vec3) * _numJoints * 3,
sizeof(glm::vec3), &jointColor[0]);
+
+
+
+
+ 906 for(GLint i = 0; i < _numJoints; ++i ) {
+ 907 if( _skeleton[i].parent != MD5Joint::NULL_JOINT ) {
+ 908 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3),
sizeof(glm::vec3), &(_skeleton[_skeleton[i].parent].position) );
+ 909 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3) +
sizeof(glm::vec3) * _numJoints * 3,
sizeof(glm::vec3), &boneColor[0]);
+
+ 911 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3) +
sizeof(glm::vec3),
sizeof(glm::vec3), &(_skeleton[i].position) );
+ 912 glBufferSubData(GL_ARRAY_BUFFER,
sizeof(glm::vec3) * _numJoints + (i * 2) *
sizeof(glm::vec3) +
sizeof(glm::vec3) +
sizeof(glm::vec3) * _numJoints * 3,
sizeof(glm::vec3), &boneColor[0]);
+
+
+
+
+
+ 918 glDrawArrays(GL_POINTS, 0, _numJoints );
+
+
+
+ 922 glDrawArrays(GL_LINES, _numJoints, numBones * 2 );
+
+
+
+
+
+
+ 929CSCI441::MD5Model::_checkAnimValidity()
const
+
+
+ 932 if( _numJoints != _animation.numJoints ) {
+ 933 printf(
"\n[.md5anim]: skeleton and animation do not have same number of joints. cannot apply animation to skeleton\n\n");
+
+
+
+
+ 938 for(GLint i = 0; i < _numJoints; ++i) {
+
+ 940 if (_baseSkeleton[i].parent != _animation.skeletonFrames[0][i].parent) {
+ 941 printf(
"\n[.md5anim]: skeleton and animation joints do not have same parent index. cannot apply animation to skeleton\n\n");
+
+
+
+
+ 946 if (strcmp (_baseSkeleton[i].name, _animation.skeletonFrames[0][i].name) != 0) {
+ 947 printf(
"\n[.md5anim]: skeleton and animation joints do not have same name. cannot apply animation to skeleton\n\n");
+
+
+
+
+ 952 printf(
"\n[.md5anim]: skeleton and animation match. animation can be applied to skeleton\n\n");
+
+
+
+
+
+ 958CSCI441::MD5Model::_buildFrameSkeleton(
+ 959 const MD5JointInfo* pJOINT_INFOS,
+ 960 const MD5BaseFrameJoint* pBASE_FRAME,
+ 961 const GLfloat* pANIM_FRAME_DATA,
+ 962 MD5Joint* pSkeletonFrame,
+ 963 const GLint NUM_JOINTS
+
+ 965 if(pJOINT_INFOS ==
nullptr
+ 966 || pBASE_FRAME ==
nullptr
+ 967 || pANIM_FRAME_DATA ==
nullptr
+ 968 || pSkeletonFrame ==
nullptr)
return;
- 970 for(i = 0; i < NUM_JOINTS; ++i) {
- 971 const MD5BaseFrameJoint *baseJoint = &pBASE_FRAME[i];
- 972 glm::vec3 animatedPosition = baseJoint->position;
- 973 glm::quat animatedOrientation = baseJoint->orientation;
-
-
-
- 977 if(pJOINT_INFOS[i].flags & 1 ) {
- 978 animatedPosition.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
-
-
-
- 983 if(pJOINT_INFOS[i].flags & 2 ) {
- 984 animatedPosition.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
-
-
-
- 989 if(pJOINT_INFOS[i].flags & 4 ) {
- 990 animatedPosition.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
-
-
-
- 995 if(pJOINT_INFOS[i].flags & 8 ) {
- 996 animatedOrientation.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
-
-
-
- 1001 if(pJOINT_INFOS[i].flags & 16 ) {
- 1002 animatedOrientation.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
-
-
-
- 1007 if(pJOINT_INFOS[i].flags & 32 ) {
- 1008 animatedOrientation.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
-
-
- 1012 animatedOrientation.w = glm::extractRealComponent(animatedOrientation);
-
-
-
-
- 1017 MD5Joint *thisJoint = &pSkeletonFrame[i];
-
- 1019 GLint parent = pJOINT_INFOS[i].parent;
- 1020 thisJoint->parent = parent;
- 1021 strcpy (thisJoint->name, pJOINT_INFOS[i].name);
-
-
- 1024 if( thisJoint->parent == MD5Joint::NULL_JOINT ) {
- 1025 thisJoint->position = animatedPosition;
- 1026 thisJoint->orientation = animatedOrientation;
-
- 1028 MD5Joint *parentJoint = &pSkeletonFrame[parent];
- 1029 glm::vec3 rotatedPosition = glm::rotate(parentJoint->orientation, glm::vec4(animatedPosition, 0.0f));
-
-
- 1032 thisJoint->position = parentJoint->position + rotatedPosition;
-
-
- 1035 thisJoint->orientation = glm::normalize( glm::cross(parentJoint->orientation, animatedOrientation) );
-
-
-
-
-
-
-
- 1043 const char *filename
-
-
-
-
- 1048 GLfloat *animFrameData =
nullptr;
-
- 1050 GLint numAnimatedComponents;
-
-
-
- 1054 printf(
"[.md5anim]: about to read %s\n", filename );
+
+
+ 972 for(i = 0; i < NUM_JOINTS; ++i) {
+ 973 const MD5BaseFrameJoint *baseJoint = &pBASE_FRAME[i];
+ 974 glm::vec3 animatedPosition = baseJoint->position;
+ 975 glm::quat animatedOrientation = baseJoint->orientation;
+
+
+
+ 979 if(pJOINT_INFOS[i].flags & 1 ) {
+ 980 animatedPosition.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
+
+
+
+ 985 if(pJOINT_INFOS[i].flags & 2 ) {
+ 986 animatedPosition.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
+
+
+
+ 991 if(pJOINT_INFOS[i].flags & 4 ) {
+ 992 animatedPosition.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
+
+
+
+ 997 if(pJOINT_INFOS[i].flags & 8 ) {
+ 998 animatedOrientation.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
+
+
+
+ 1003 if(pJOINT_INFOS[i].flags & 16 ) {
+ 1004 animatedOrientation.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
+
+
+
+ 1009 if(pJOINT_INFOS[i].flags & 32 ) {
+ 1010 animatedOrientation.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
+
+
+ 1014 animatedOrientation.w = glm::extractRealComponent(animatedOrientation);
+
+
+
+
+ 1019 MD5Joint *thisJoint = &pSkeletonFrame[i];
+
+ 1021 GLint parent = pJOINT_INFOS[i].parent;
+ 1022 thisJoint->parent = parent;
+ 1023 strcpy (thisJoint->name, pJOINT_INFOS[i].name);
+
+
+ 1026 if( thisJoint->parent == MD5Joint::NULL_JOINT ) {
+ 1027 thisJoint->position = animatedPosition;
+ 1028 thisJoint->orientation = animatedOrientation;
+
+ 1030 MD5Joint *parentJoint = &pSkeletonFrame[parent];
+ 1031 glm::vec3 rotatedPosition = glm::rotate(parentJoint->orientation, glm::vec4(animatedPosition, 0.0f));
+
+
+ 1034 thisJoint->position = parentJoint->position + rotatedPosition;
+
+
+ 1037 thisJoint->orientation = glm::normalize( glm::cross(parentJoint->orientation, animatedOrientation) );
+
+
+
+
+
+
+
+ 1045 const char *filename
+
+
+
+
+ 1050 GLfloat *animFrameData =
nullptr;
+
+ 1052 GLint numAnimatedComponents;
+
+
- 1056 FILE *fp = fopen( filename,
"rb" );
-
- 1058 fprintf (stderr,
"[.md5anim]: Error: couldn't open \"%s\"!\n", filename);
-
-
-
- 1062 while( !feof(fp) ) {
-
- 1064 fgets( buff,
sizeof(buff), fp );
-
- 1066 if( sscanf(buff,
" MD5Version %d", &version) == 1 ) {
- 1067 if( version != 10 ) {
-
- 1069 fprintf (stderr,
"[.md5anim]: Error: bad animation version\n");
-
-
-
- 1073 }
else if( sscanf(buff,
" numFrames %d", &_animation.numFrames) == 1 ) {
-
- 1075 if( _animation.numFrames > 0 ) {
- 1076 _animation.skeletonFrames =
new MD5Joint*[_animation.numFrames];
- 1077 _animation.boundingBoxes =
new MD5BoundingBox[_animation.numFrames];
-
- 1079 }
else if( sscanf(buff,
" numJoints %d", &_animation.numJoints) == 1 ) {
- 1080 if( _animation.numJoints > 0 ) {
- 1081 for(i = 0; i < _animation.numFrames; ++i) {
-
- 1083 _animation.skeletonFrames[i] =
new MD5Joint[_animation.numJoints];
-
-
-
-
-
-
-
- 1091 }
else if( sscanf(buff,
" frameRate %d", &_animation.frameRate) == 1 ) {
-
- 1093 }
else if( sscanf(buff,
" numAnimatedComponents %d", &numAnimatedComponents) == 1 ) {
- 1094 if( numAnimatedComponents > 0 ) {
-
- 1096 animFrameData =
new GLfloat[numAnimatedComponents];
-
- 1098 }
else if( strncmp(buff,
"hierarchy {", 11) == 0 ) {
- 1099 for(i = 0; i < _animation.numJoints; ++i) {
-
- 1101 fgets( buff,
sizeof(buff), fp );
-
-
- 1104 sscanf(buff,
" %s %d %d %d",
- 1105 jointInfos[i].name, &jointInfos[i].parent,
- 1106 &jointInfos[i].flags, &jointInfos[i].startIndex);
-
- 1108 }
else if( strncmp(buff,
"bounds {", 8) == 0 ) {
- 1109 for(i = 0; i < _animation.numFrames; ++i) {
-
- 1111 fgets( buff,
sizeof(buff), fp );
-
-
- 1114 sscanf(buff,
" ( %f %f %f ) ( %f %f %f )",
- 1115 &_animation.boundingBoxes[i].min[0], &_animation.boundingBoxes[i].min[1], &_animation.boundingBoxes[i].min[2],
- 1116 &_animation.boundingBoxes[i].max[0], &_animation.boundingBoxes[i].max[1], &_animation.boundingBoxes[i].max[2]);
-
- 1118 }
else if( strncmp(buff,
"baseframe {", 10) == 0 ) {
- 1119 for(i = 0; i < _animation.numJoints; ++i) {
-
- 1121 fgets( buff,
sizeof(buff), fp );
-
-
- 1124 if( sscanf(buff,
" ( %f %f %f ) ( %f %f %f )",
- 1125 &baseFrame[i].position[0], &baseFrame[i].position[1], &baseFrame[i].position[2],
- 1126 &baseFrame[i].orientation[0], &baseFrame[i].orientation[1], &baseFrame[i].orientation[2]) == 6 ) {
-
- 1128 baseFrame[i].
orientation.w = glm::extractRealComponent(baseFrame[i].orientation);
-
-
- 1131 }
else if(sscanf(buff,
" frame %d", &frameIndex) == 1 ) {
-
- 1133 for(i = 0; i < numAnimatedComponents; ++i)
- 1134 fscanf( fp,
"%f", &animFrameData[i] );
-
-
- 1137 _buildFrameSkeleton(jointInfos, baseFrame, animFrameData,
- 1138 _animation.skeletonFrames[frameIndex],
- 1139 _animation.numJoints);
-
-
-
-
+ 1056 printf(
"[.md5anim]: about to read %s\n", filename );
+
+ 1058 FILE *fp = fopen( filename,
"rb" );
+
+ 1060 fprintf (stderr,
"[.md5anim]: Error: couldn't open \"%s\"!\n", filename);
+
+
+
+ 1064 while( !feof(fp) ) {
+
+ 1066 fgets( buff,
sizeof(buff), fp );
+
+ 1068 if( sscanf(buff,
" MD5Version %d", &version) == 1 ) {
+ 1069 if( version != 10 ) {
+
+ 1071 fprintf (stderr,
"[.md5anim]: Error: bad animation version\n");
+
+
+
+ 1075 }
else if( sscanf(buff,
" numFrames %d", &_animation.numFrames) == 1 ) {
+
+ 1077 if( _animation.numFrames > 0 ) {
+ 1078 _animation.skeletonFrames =
new MD5Joint*[_animation.numFrames];
+ 1079 _animation.boundingBoxes =
new MD5BoundingBox[_animation.numFrames];
+
+ 1081 }
else if( sscanf(buff,
" numJoints %d", &_animation.numJoints) == 1 ) {
+ 1082 if( _animation.numJoints > 0 ) {
+ 1083 for(i = 0; i < _animation.numFrames; ++i) {
+
+ 1085 _animation.skeletonFrames[i] =
new MD5Joint[_animation.numJoints];
+
+
+
+
+
+
+
+ 1093 }
else if( sscanf(buff,
" frameRate %d", &_animation.frameRate) == 1 ) {
+
+ 1095 }
else if( sscanf(buff,
" numAnimatedComponents %d", &numAnimatedComponents) == 1 ) {
+ 1096 if( numAnimatedComponents > 0 ) {
+
+ 1098 animFrameData =
new GLfloat[numAnimatedComponents];
+
+ 1100 }
else if( strncmp(buff,
"hierarchy {", 11) == 0 ) {
+ 1101 for(i = 0; i < _animation.numJoints; ++i) {
+
+ 1103 fgets( buff,
sizeof(buff), fp );
+
+
+ 1106 sscanf(buff,
" %s %d %d %d",
+ 1107 jointInfos[i].name, &jointInfos[i].parent,
+ 1108 &jointInfos[i].flags, &jointInfos[i].startIndex);
+
+ 1110 }
else if( strncmp(buff,
"bounds {", 8) == 0 ) {
+ 1111 for(i = 0; i < _animation.numFrames; ++i) {
+
+ 1113 fgets( buff,
sizeof(buff), fp );
+
+
+ 1116 sscanf(buff,
" ( %f %f %f ) ( %f %f %f )",
+ 1117 &_animation.boundingBoxes[i].min[0], &_animation.boundingBoxes[i].min[1], &_animation.boundingBoxes[i].min[2],
+ 1118 &_animation.boundingBoxes[i].max[0], &_animation.boundingBoxes[i].max[1], &_animation.boundingBoxes[i].max[2]);
+
+ 1120 }
else if( strncmp(buff,
"baseframe {", 10) == 0 ) {
+ 1121 for(i = 0; i < _animation.numJoints; ++i) {
+
+ 1123 fgets( buff,
sizeof(buff), fp );
+
+
+ 1126 if( sscanf(buff,
" ( %f %f %f ) ( %f %f %f )",
+ 1127 &baseFrame[i].position[0], &baseFrame[i].position[1], &baseFrame[i].position[2],
+ 1128 &baseFrame[i].orientation[0], &baseFrame[i].orientation[1], &baseFrame[i].orientation[2]) == 6 ) {
+
+ 1130 baseFrame[i].
orientation.w = glm::extractRealComponent(baseFrame[i].orientation);
+
+
+ 1133 }
else if(sscanf(buff,
" frame %d", &frameIndex) == 1 ) {
+
+ 1135 for(i = 0; i < numAnimatedComponents; ++i)
+ 1136 fscanf( fp,
"%f", &animFrameData[i] );
+
+
+ 1139 _buildFrameSkeleton(jointInfos, baseFrame, animFrameData,
+ 1140 _animation.skeletonFrames[frameIndex],
+ 1141 _animation.numJoints);
+
+
- 1145 printf(
"[.md5anim]: finished reading %s\n", filename );
- 1146 printf(
"[.md5anim]: read in %d frames of %d joints with %d animated components\n", _animation.numFrames, _animation.numJoints, numAnimatedComponents );
- 1147 printf(
"[.md5anim]: animation's frame rate is %d\n", _animation.frameRate );
-
-
-
- 1151 free( animFrameData );
-
-
-
-
-
-
-
-
- 1160 _animationInfo.currFrame = 0;
- 1161 _animationInfo.nextFrame = 1;
-
- 1163 _animationInfo.lastTime = 0.0f;
- 1164 _animationInfo.maxTime = 1.0f / (GLfloat)_animation.frameRate;
-
-
- 1167 _skeleton =
new MD5Joint[_animation.numJoints];
-
- 1169 if( _checkAnimValidity() ) {
-
-
-
-
-
-
-
-
-
-
- 1180CSCI441::MD5Model::_freeAnim()
-
-
-
- 1184 for(i = 0; i < _animation.numFrames; ++i) {
- 1185 delete _animation.skeletonFrames[i];
- 1186 _animation.skeletonFrames[i] =
nullptr;
-
-
- 1189 delete[] _animation.skeletonFrames;
- 1190 _animation.skeletonFrames =
nullptr;
-
- 1192 delete _animation.boundingBoxes;
- 1193 _animation.boundingBoxes =
nullptr;
-
-
- 1196 _skeleton =
nullptr;
-
-
-
-
- 1201CSCI441::MD5Model::_interpolateSkeletons(GLfloat interp)
-
- 1203 const MD5Joint *skeletonA = _animation.skeletonFrames[_animationInfo.currFrame];
- 1204 const MD5Joint *skeletonB = _animation.skeletonFrames[_animationInfo.nextFrame];
-
-
+
+
+ 1147 printf(
"[.md5anim]: finished reading %s\n", filename );
+ 1148 printf(
"[.md5anim]: read in %d frames of %d joints with %d animated components\n", _animation.numFrames, _animation.numJoints, numAnimatedComponents );
+ 1149 printf(
"[.md5anim]: animation's frame rate is %d\n", _animation.frameRate );
+
+
+
+ 1153 free( animFrameData );
+
+
+
+
+
+
+
+
+ 1162 _animationInfo.currFrame = 0;
+ 1163 _animationInfo.nextFrame = 1;
+
+ 1165 _animationInfo.lastTime = 0.0f;
+ 1166 _animationInfo.maxTime = 1.0f / (GLfloat)_animation.frameRate;
+
+
+ 1169 _skeleton =
new MD5Joint[_animation.numJoints];
+
+ 1171 if( _checkAnimValidity() ) {
+
+
+
+
+
+
+
+
+
+
+ 1182CSCI441::MD5Model::_freeAnim()
+
+
+
+ 1186 for(i = 0; i < _animation.numFrames; ++i) {
+ 1187 delete _animation.skeletonFrames[i];
+ 1188 _animation.skeletonFrames[i] =
nullptr;
+
+
+ 1191 delete[] _animation.skeletonFrames;
+ 1192 _animation.skeletonFrames =
nullptr;
+
+ 1194 delete _animation.boundingBoxes;
+ 1195 _animation.boundingBoxes =
nullptr;
+
+
+ 1198 _skeleton =
nullptr;
+
+
+
+
+ 1203CSCI441::MD5Model::_interpolateSkeletons(GLfloat interp)
+
+ 1205 const MD5Joint *skeletonA = _animation.skeletonFrames[_animationInfo.currFrame];
+ 1206 const MD5Joint *skeletonB = _animation.skeletonFrames[_animationInfo.nextFrame];
- 1208 for(i = 0; i < _animation.numJoints; ++i) {
-
- 1210 _skeleton[i].parent = skeletonA[i].parent;
-
-
- 1213 _skeleton[i].position[0] = skeletonA[i].position[0] + interp * (skeletonB[i].position[0] - skeletonA[i].position[0]);
- 1214 _skeleton[i].position[1] = skeletonA[i].position[1] + interp * (skeletonB[i].position[1] - skeletonA[i].position[1]);
- 1215 _skeleton[i].position[2] = skeletonA[i].position[2] + interp * (skeletonB[i].position[2] - skeletonA[i].position[2]);
-
-
- 1218 _skeleton[i].orientation = glm::slerp(skeletonA[i].orientation, skeletonB[i].orientation, interp);
-
-
-
-
-
-
-
-
- 1227 GLint maxFrames = _animation.numFrames - 1;
-
- 1229 _animationInfo.lastTime += dt;
+
+
+ 1210 for(i = 0; i < _animation.numJoints; ++i) {
+
+ 1212 _skeleton[i].parent = skeletonA[i].parent;
+
+
+ 1215 _skeleton[i].position[0] = skeletonA[i].position[0] + interp * (skeletonB[i].position[0] - skeletonA[i].position[0]);
+ 1216 _skeleton[i].position[1] = skeletonA[i].position[1] + interp * (skeletonB[i].position[1] - skeletonA[i].position[1]);
+ 1217 _skeleton[i].position[2] = skeletonA[i].position[2] + interp * (skeletonB[i].position[2] - skeletonA[i].position[2]);
+
+
+ 1220 _skeleton[i].orientation = glm::slerp(skeletonA[i].orientation, skeletonB[i].orientation, interp);
+
+
+
+
+
+
+
+
+ 1229 GLint maxFrames = _animation.numFrames - 1;
-
- 1232 if( _animationInfo.lastTime >= _animationInfo.maxTime ) {
- 1233 _animationInfo.currFrame++;
- 1234 _animationInfo.nextFrame++;
- 1235 _animationInfo.lastTime = 0.0;
-
- 1237 if( _animationInfo.currFrame > maxFrames )
- 1238 _animationInfo.currFrame = 0;
-
- 1240 if( _animationInfo.nextFrame > maxFrames )
- 1241 _animationInfo.nextFrame = 0;
-
-
-
- 1245 _interpolateSkeletons( _animationInfo.lastTime * _animation.frameRate );
-
-
-
+ 1231 _animationInfo.lastTime += dt;
+
+
+ 1234 if( _animationInfo.lastTime >= _animationInfo.maxTime ) {
+ 1235 _animationInfo.currFrame++;
+ 1236 _animationInfo.nextFrame++;
+ 1237 _animationInfo.lastTime = 0.0;
+
+ 1239 if( _animationInfo.currFrame > maxFrames )
+ 1240 _animationInfo.currFrame = 0;
+
+ 1242 if( _animationInfo.nextFrame > maxFrames )
+ 1243 _animationInfo.nextFrame = 0;
+
+
+
+ 1247 _interpolateSkeletons( _animationInfo.lastTime * _animation.frameRate );
+
+
+
Helper functions to work with OpenGL Textures.
-stores a Doom3 MD5 Mesh + Animation
Definition: MD5Model.hpp:73
-void draw() const
draws all the meshes that make up the model
Definition: MD5Model.hpp:752
-bool readMD5Model(const char *FILENAME)
parses md5mesh file and allocates corresponding mesh data
Definition: MD5Model.hpp:511
-bool isAnimated() const
returns if the MD5 Model has an accompanying animation
Definition: MD5Model.hpp:360
-bool loadMD5Model(const char *MD5_MESH_FILE, const char *MD5_ANIM_FILE="")
loads a corresponding md5mesh and md5anim file to the object
Definition: MD5Model.hpp:487
-MD5Model()
initializes an empty MD5 Model
Definition: MD5Model.hpp:455
+stores a Doom3 MD5 Mesh + Animation
Definition: MD5Model.hpp:75
+void draw() const
draws all the meshes that make up the model
Definition: MD5Model.hpp:754
+bool readMD5Model(const char *FILENAME)
parses md5mesh file and allocates corresponding mesh data
Definition: MD5Model.hpp:513
+bool isAnimated() const
returns if the MD5 Model has an accompanying animation
Definition: MD5Model.hpp:362
+bool loadMD5Model(const char *MD5_MESH_FILE, const char *MD5_ANIM_FILE="")
loads a corresponding md5mesh and md5anim file to the object
Definition: MD5Model.hpp:489
+MD5Model()
initializes an empty MD5 Model
Definition: MD5Model.hpp:457
MD5Model & operator=(const MD5Model &)=delete
do not allow MD5 models to be copied
-bool readMD5Anim(const char *filename)
reads in an animation sequence from an external file
Definition: MD5Model.hpp:1042
-void allocVertexArrays(GLuint vPosAttribLoc, GLuint vColorAttribLoc, GLuint vTexCoordAttribLoc)
binds model VBOs to attribute pointer locations
Definition: MD5Model.hpp:824
-void animate(GLfloat dt)
advances the model forward in its animation sequence the corresponding amount of time based on frame ...
Definition: MD5Model.hpp:1225
+bool readMD5Anim(const char *filename)
reads in an animation sequence from an external file
Definition: MD5Model.hpp:1044
+void allocVertexArrays(GLuint vPosAttribLoc, GLuint vColorAttribLoc, GLuint vTexCoordAttribLoc)
binds model VBOs to attribute pointer locations
Definition: MD5Model.hpp:826
+void animate(GLfloat dt)
advances the model forward in its animation sequence the corresponding amount of time based on frame ...
Definition: MD5Model.hpp:1227
MD5Model(const MD5Model &)=delete
do not allow MD5 models to be copied
-~MD5Model()
deallocates any used memory on the CPU and GPU
Definition: MD5Model.hpp:477
-void drawSkeleton() const
draws the skeleton joints (as points) and bones (as lines)
Definition: MD5Model.hpp:888
+~MD5Model()
deallocates any used memory on the CPU and GPU
Definition: MD5Model.hpp:479
+void drawSkeleton() const
draws the skeleton joints (as points) and bones (as lines)
Definition: MD5Model.hpp:890
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
-stores an entire animation sequence for a given MD5 Model
Definition: MD5Model.hpp:278
-stores state of current animation frame
Definition: MD5Model.hpp:307
-base frame joint
Definition: MD5Model.hpp:249
-glm::quat orientation
joint orientation expressed as a quaternion in object space
Definition: MD5Model.hpp:257
-bounding box containing the model during animation
Definition: MD5Model.hpp:264
-a joint of the MD5 Skeleton
Definition: MD5Model.hpp:79
-glm::vec3 position
position of the joint in object space
Definition: MD5Model.hpp:95
-glm::quat orientation
joint orientation expressed as a quaternion in object space
Definition: MD5Model.hpp:99
-char name[256]
joint identifier
Definition: MD5Model.hpp:87
-GLint parent
index of the parent joint on skeletal tree
Definition: MD5Model.hpp:91
-information pertaining to each animation joint
Definition: MD5Model.hpp:227
-mesh that comprises the model's skin
Definition: MD5Model.hpp:165
-GLint numTriangles
number of triangles in the mesh triangle array
Definition: MD5Model.hpp:211
-TextureMap
named entities for different texture maps applied to the model
Definition: MD5Model.hpp:185
-@ DIFFUSE
diffuse map
Definition: MD5Model.hpp:189
-@ SPECULAR
specular map
Definition: MD5Model.hpp:193
-@ NORMAL
normal map
Definition: MD5Model.hpp:197
-MD5Texture textures[4]
texture map array
Definition: MD5Model.hpp:181
-GLint numVertices
number of vertices in the mesh vertex array
Definition: MD5Model.hpp:207
-MD5Triangle * triangles
array triangles comprising the mesh
Definition: MD5Model.hpp:173
-MD5Vertex * vertices
array of vertices comprising the mesh
Definition: MD5Model.hpp:169
-GLint numWeights
number of weights in the mesh weight array
Definition: MD5Model.hpp:215
-MD5Weight * weights
array of weights to determine vertex position based on joint positions
Definition: MD5Model.hpp:177
-char shader[512]
base filename for all textures applied to mesh
Definition: MD5Model.hpp:220
-texture handle for the model
Definition: MD5Model.hpp:151
-GLuint texHandle
handle of texture stored on the GPU
Definition: MD5Model.hpp:155
-char filename[512]
filename texture was loaded from
Definition: MD5Model.hpp:159
-a triangle on the mesh
Definition: MD5Model.hpp:123
-GLint index[3]
vertex indices that make up triangle
Definition: MD5Model.hpp:127
-a vertex on the mesh
Definition: MD5Model.hpp:105
-glm::vec2 texCoord
texture coordinate for vertex
Definition: MD5Model.hpp:109
-GLint start
index of starting weight
Definition: MD5Model.hpp:113
-GLint count
number of weights that determine vertex's position
Definition: MD5Model.hpp:117
-the weight for a mesh vertex
Definition: MD5Model.hpp:133
-GLfloat bias
contribution of the weight
Definition: MD5Model.hpp:141
-GLint joint
index of joint the weight depends on
Definition: MD5Model.hpp:137
-glm::vec3 position
weight's position in object space
Definition: MD5Model.hpp:145
+stores an entire animation sequence for a given MD5 Model
Definition: MD5Model.hpp:280
+stores state of current animation frame
Definition: MD5Model.hpp:309
+base frame joint
Definition: MD5Model.hpp:251
+glm::quat orientation
joint orientation expressed as a quaternion in object space
Definition: MD5Model.hpp:259
+bounding box containing the model during animation
Definition: MD5Model.hpp:266
+a joint of the MD5 Skeleton
Definition: MD5Model.hpp:81
+glm::vec3 position
position of the joint in object space
Definition: MD5Model.hpp:97
+glm::quat orientation
joint orientation expressed as a quaternion in object space
Definition: MD5Model.hpp:101
+char name[256]
joint identifier
Definition: MD5Model.hpp:89
+GLint parent
index of the parent joint on skeletal tree
Definition: MD5Model.hpp:93
+information pertaining to each animation joint
Definition: MD5Model.hpp:229
+mesh that comprises the model's skin
Definition: MD5Model.hpp:167
+GLint numTriangles
number of triangles in the mesh triangle array
Definition: MD5Model.hpp:213
+TextureMap
named entities for different texture maps applied to the model
Definition: MD5Model.hpp:187
+@ DIFFUSE
diffuse map
Definition: MD5Model.hpp:191
+@ SPECULAR
specular map
Definition: MD5Model.hpp:195
+@ NORMAL
normal map
Definition: MD5Model.hpp:199
+MD5Texture textures[4]
texture map array
Definition: MD5Model.hpp:183
+GLint numVertices
number of vertices in the mesh vertex array
Definition: MD5Model.hpp:209
+MD5Triangle * triangles
array triangles comprising the mesh
Definition: MD5Model.hpp:175
+MD5Vertex * vertices
array of vertices comprising the mesh
Definition: MD5Model.hpp:171
+GLint numWeights
number of weights in the mesh weight array
Definition: MD5Model.hpp:217
+MD5Weight * weights
array of weights to determine vertex position based on joint positions
Definition: MD5Model.hpp:179
+char shader[512]
base filename for all textures applied to mesh
Definition: MD5Model.hpp:222
+texture handle for the model
Definition: MD5Model.hpp:153
+GLuint texHandle
handle of texture stored on the GPU
Definition: MD5Model.hpp:157
+char filename[512]
filename texture was loaded from
Definition: MD5Model.hpp:161
+a triangle on the mesh
Definition: MD5Model.hpp:125
+GLint index[3]
vertex indices that make up triangle
Definition: MD5Model.hpp:129
+a vertex on the mesh
Definition: MD5Model.hpp:107
+glm::vec2 texCoord
texture coordinate for vertex
Definition: MD5Model.hpp:111
+GLint start
index of starting weight
Definition: MD5Model.hpp:115
+GLint count
number of weights that determine vertex's position
Definition: MD5Model.hpp:119
+the weight for a mesh vertex
Definition: MD5Model.hpp:135
+GLfloat bias
contribution of the weight
Definition: MD5Model.hpp:143
+GLint joint
index of joint the weight depends on
Definition: MD5Model.hpp:139
+glm::vec3 position
weight's position in object space
Definition: MD5Model.hpp:147