Hey Guys!
So i am building a custom c++ engine for my game but the skinned animation system is acting funny the animation is not acting correctly
I am thinking it has to do with the Joint Hierarchy maybe not been applied correctly during the skinned animation process and the joint poses are not set to the correct space, but at first glance what do you guys think the problem could be and what should i look at to fix it?
This would be the way its suppose to work (This are GIFs so click them so they can animate)
[attachment=33840:Animation_Walk.gif]
This is the way it actually shows up in game (This are GIFs so click them so they can animate)
[attachment=33841:Wrong_Walk_Animation.gif]
Here is some of the animation code
Animation* Current_Animation = _Model->GetAnimation(_AnimName);
Mesh* TempMesh = _Model->GetMesh();
//Final Vector with animation Updated Vertex Positions
vector<FLOAT4X4> CurrentPoses = ProcessChannels(Current_Animation,_DT);
vector<Vector_Struct> FinalVertexs;
for (unsigned int i = 0; i < _Model->GetOrgVertexs().size(); i++)
{
Vector_Struct vSum = {};
for (unsigned int x = 0; x < TempMesh->The_Influences[i].size(); x++)
{
int JointIndex = TempMesh->The_Influences[i][x].joint_index;
float Weight = TempMesh->The_Influences[i][x].weight;
FLOAT4 CurrentVertexOffset = {};
FLOAT4 Result = {};
FLOAT4X4 BindPoseInverse = {};
//Get the inverse bind pose to but the vertex into the correct space
FLOAT4X4 Bind_Pose = TempMesh->The_Joints[JointIndex].bind_pose_transform;
BindPoseInverse = Math::GetInstance()->FLOAT4X4Inverse(Bind_Pose);
//Put the Original Vertex into the correct space
CurrentVertexOffset = _Model->GetOrgVertexs()[i].Position * BindPoseInverse;
//Get the pose for the current animation frame
FLOAT4X4 pose = CurrentPoses[JointIndex];// Current_Animation->channels[JointIndex].keys[CurrentKey].node;
//apply the pose to the updated vertex
Result = CurrentVertexOffset * pose;
//affect the Vertex by the correct weight and apply the result affected by the weight into the complete vertex for the final version
Result *= Weight;
vSum.Position += Result;
}
//add it into the vector
FinalVertexs.push_back(vSum);
}
for (unsigned int i = 0; i < FinalVertexs.size(); i++)
{
_Model->GetVertexs()[i].Position = FinalVertexs[i].Position;
}
UpdateVertexBuffer = false;
_Model->SetAnimated(true);