Hi,

If you looked at the pics, you would have noticed that the skinning is working, the animation is working, but both are not working together. When I try to put them together, the lamp/hat goes off somewhere else.

Please help me understand what is going on. I am at my wit's end at figuring out what I'm mis-using for assimp. My bone computation, drawing, and glsl code are posted below.

Thank you for your future help and insights,

Phi

void AnimatedAssimpModel::computeInverseBindPoseTransforms(float time, aiNode *node, const Matrix4x4 &parent_transform, std::vector<Matrix4x4> &bm) { //node to update const aiNodeAnim *na = findNodeAnimation(node->mName.data); //interpolate between animation key frames Matrix4x4 node_transform; if(nullptr != na) { calcInterpolatedKeyFrame(time, na, node->mTransformation); copyAssimp(node->mTransformation, node_transform); } //scene graph matrix of current node Matrix4x4 mesh_matrix = parent_transform * node_transform; //compute the bone matrices used for skinning auto it = mBones.find(node->mName.data); if(mBones.end() != it) { //converting objects in mesh space to bone space bm[it->second.index] = mesh_matrix * it->second.inverseBindPoseTransform; } for(uint32_t i = 0; i < node->mNumChildren; ++i) computeInverseBindPoseTransforms(time, node->mChildren[i], mesh_matrix, bm); } void AnimatedAssimpModel::draw(const aiNode *node, const Matrix4x4 &parent_transform) { Matrix4x4 node_transform; AnimatedAssimpModel::copyAssimp(node->mTransformation, node_transform); Matrix4x4 model_matrix = parent_transform * node_transform; if(node->mNumMeshes > 0) { UniformBlockVariable_t ubv; mDrawProgram->getUniformBlockVariable("gModelMatrix", ubv); mTransformations->bind(); mTransformations->update(ubv.offset, sizeof(Matrix4x4), &model_matrix); mTransformations->unbind(); } for(uint32_t idx = 0; idx < node->mNumMeshes; ++idx) { const MeshData_t &cur = mMeshes.at(node->mMeshes[idx]); mDrawProgram->setBuffer("Material", *cur.material); cur.vf->bind(); if(cur.texture) mDrawProgram->activateTextureUnits({{mSampler, cur.texture}}); glDrawElements(GL_TRIANGLES, cur.numberFaces * 3, GL_UNSIGNED_INT, 0); cur.vf->unbind(); } for(uint32_t idx = 0; idx < node->mNumChildren; ++idx) draw(node->mChildren[idx], model_matrix); } void main() { #if 0 vec4 vp_start = vec4(0,0,0,0); vec4 vp_end = vec4(0,0,0,0); vec4 ls_pos_start = vec4(viPosition, 1.0); vec4 ls_pos_end = vec4(viPosition + viNormal, 1.0); for(int i = 0; i < 4; ++i) { vp_start += viBoneWeights[i] * gIBPT[viBoneIDs[i]] * ls_pos_start; vp_end += viBoneWeights[i] * gIBPT[viBoneIDs[i]] * ls_pos_end; } #else mat4 bone_transform = mat4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); vec4 vp_start = bone_transform * vec4(viPosition, 1.0); vec4 vp_end = bone_transform * vec4(viPosition + viNormal, 1.0); #endif vec4 ws_start = gModelMatrix * vp_start; vec4 ws_end = gModelMatrix * vp_end; vec4 n_normal = normalize(ws_end - ws_start); vs_out.normal = n_normal.xyz; vs_out.texCoord = viTexCoord; vs_out.lightDir = normalize(vec4(gEyeWorldPos, 1.0) - ws_start).xyz; vec4 cs_pos = gViewMatrix * ws_start; gl_Position = gProjectionMatrix * cs_pos; }