X-Git-Url: http://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=model.cpp;h=f68db4b6407f2096c4313794e1bb3d1c00e569f1;hp=107fda0b321317ab54a145d7e1249c08f340abde;hb=6fb9efea1fd0e4575973719a997602da4b4c4fa5;hpb=d381f617bef400fc157edf782008cafb018ed594 diff --git a/model.cpp b/model.cpp index 107fda0..f68db4b 100644 --- a/model.cpp +++ b/model.cpp @@ -232,11 +232,11 @@ void Model::Node::draw( const std::vector &meshes, } - glm::mat4 m = parentTrans * animTrans * aiMatrixToMat4(ai.mTransformation) * model; + glm::mat4 m = parentTrans * animTrans * aiMatrixToMat4(ai.mTransformation); - for (auto child: children) { - boneTransforms[std::string(ai.mName.C_Str())] = m; - } + /* for (auto child: children) { */ + /* boneTransforms[std::string(ai.mName.C_Str())] = m; */ + /* } */ for (unsigned int i: meshIndices) { const Mesh &mesh = meshes[i]; @@ -250,13 +250,17 @@ void Model::Node::draw( const std::vector &meshes, std::string nodeName = pair.first; unsigned int boneId = pair.second.first; + // This is actually an inverse-bind matrix + // i.e. position of the mesh in bone space + // so no need to inverse again! + // https://github.com/assimp/assimp/pull/1803/files glm::mat4 boneOffset = pair.second.second; glm::mat4 boneTrans(1.f); - if (boneTransforms.count(nodeName)) { - std::cerr << "got bone transform from map" << std::endl; - boneTrans = boneTransforms[nodeName]; - } + /* if (boneTransforms.count(nodeName)) { */ + /* std::cerr << "got bone transform from map" << std::endl; */ + /* boneTrans = boneTransforms[nodeName]; */ + /* } */ for (const Animation anim: animMap->at(nodeName)) { float t = fmod(tick, anim.duration); for (const aiNodeAnim *nodeAnim: anim.nodeAnims) { @@ -266,7 +270,7 @@ void Model::Node::draw( const std::vector &meshes, } } - boneTrans = boneTrans * glm::inverse(boneOffset); + boneTrans = boneTrans * boneOffset; std::string boneLocStr = "bones[" + std::to_string(boneId) + "]";