Skinning Using OgreXML

Get answers to all your basic programming questions. No Ogre questions, please!
md83
Gnoblar
Posts: 1
Joined: Sun Dec 02, 2012 1:45 am

Skinning Using OgreXML

Post by md83 »

I am working on a model loader for OgreXML as a way to learn (CPU) vertex skinning. I am able to render the static model fine, but when I try to render an animated model (even in the default pose), what I get is completely wrong. I was hoping someone could explain to me what I am doing incorrectly. I am working under the assumption that exported data is relative to parent space - meaning joint and animation data is relative to its parent joint in WorldSpace coordinates. Here's some pseudocode:

Code: Select all

//Build the joint heirarchy 
for (Joint j : joints)
{
	if (!j.hasParentJoint())
		j.ModelSpaceTransform = j.ParentSpaceTransform;
	else
		j.ModelSpaceTransform = j.getParent().WorldSpaceTransform * j.ParentSpaceTransform;
}

//Animate the model using keyframe data
for (Joint j : joints)
{
	j.AnimationParentSpaceTransform = j.ParentSpaceTransform * keyframe;
	
	if (!j.hasParentJoint())
		j.AnimationWorldSpaceTransform = j.AnimationParentSpaceTransform;
	else
		j.AnimationWorldSpaceTransform = j.getParent().AnimationWorldSpaceTransform * j.AnimationParentSpaceTransform;
}

// Transform a vertex V
Joint  joint = V.getJoint();
Vertex animatedVertex = joint.AnimationWorldSpaceTransform * joint.WorldSpaceTransform.inverse() * V;
Thank you