I am attempting to convert the skeleton from a source engine SMD file to an anim8or an8 file.
The SMD file contains a position of the end of the bone relative to the parent and 3 euler angles for orientation, rotation order is X,Y,Z
the an8 format uses a bone length and quaternion for orientation.
this is the code i’m using.
for(int x=0;x<bones.size();x++)
{
smdbone sb=bones.get(x);
Quat4f orientation= new Quat4f();
float length;
Quat4f xrot=new Quat4f();
xrot.set(new AxisAngle4f(1,0,0,sb.rotx));
Quat4f yrot=new Quat4f();
yrot.set(new AxisAngle4f(0,1,0,sb.roty));
Quat4f zrot=new Quat4f();
zrot.set(new AxisAngle4f(0,0,1,sb.rotz));
orientation.set(xrot);
orientation.mul(yrot);
orientation.mul(zrot);
String pname;
if(sb.parent==null)
{
length=2;
pname="root";
}
else
{
length=new Vector3f(sb.x,sb.y,sb.z).length();
pname=sb.parent.name;
}
Bone b = new Bone();
b.name=sb.name;
b.length=length;
b.orientation=orientation;
fig.getbone(pname).subbones.add(b);
}
the Bone and smdbone classes represent an8 bones and smd bones respectively. I have verified that my SMD loading and an8 save code works properly.
so far the results I’ve been getting in no way resemble the input.
any ideas what’s going wrong?
thanks!