}
- 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];
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) {
}
}
- boneTrans = boneTrans * glm::inverse(boneOffset);
+ boneTrans = boneTrans * boneOffset;
std::string boneLocStr = "bones[" + std::to_string(boneId) + "]";
// TODO: handle default material inserted at the end by assimp
for (unsigned int i = 0; i < scene->mNumMaterials - 1; i++) {
const aiMaterial &material = *scene->mMaterials[i];
- materials.push_back(Material(material, p.progId));
+ materials.push_back(Material(material, *scene, p.progId));
}
AnimMap *animMap = new AnimMap();
root = new Node(*(scene->mRootNode), p.progId, animMap);
}
-void Model::calcBoneTransforms(aiNode &node, glm::mat4 parentTrans = glm::mat4(1), BoneTransforms boneTrans = BoneTransforms()) {
- glm::mat4 animTrans(1.f);
- if (animMap->count(std::string(ai.mName.C_Str()))) {
- for (const Animation anim: animMap->at(std::string(ai.mName.C_Str()))) {
- float t = fmod(tick, anim.duration);
- for (const aiNodeAnim *nodeAnim: anim.nodeAnims) {
- animTrans *= lerpPosition(nodeAnim, t);
- animTrans *= lerpRotation(nodeAnim, t);
- animTrans *= lerpScaling(nodeAnim, t);
- }
- }
- }
+/* void Model::calcBoneTransforms(aiNode &node, glm::mat4 parentTrans = glm::mat4(1), BoneTransforms boneTrans = BoneTransforms()) { */
+/* glm::mat4 animTrans(1.f); */
+/* if (animMap->count(std::string(ai.mName.C_Str()))) { */
+/* for (const Animation anim: animMap->at(std::string(ai.mName.C_Str()))) { */
+/* float t = fmod(tick, anim.duration); */
+/* for (const aiNodeAnim *nodeAnim: anim.nodeAnims) { */
+/* animTrans *= lerpPosition(nodeAnim, t); */
+/* animTrans *= lerpRotation(nodeAnim, t); */
+/* animTrans *= lerpScaling(nodeAnim, t); */
+/* } */
+/* } */
+/* } */
- glm::mat4 m = parentTrans * animTrans * aiMatrixToMat4(ai.mTransformation) * model;
-}
+/* glm::mat4 m = parentTrans * animTrans * aiMatrixToMat4(ai.mTransformation) * model; */
+/* } */
void Model::draw(Skybox skybox, const float tick) const {
glUseProgram(program.progId);