General Category > General Anim8or Forum

SMD skeleton to an8 skeleton

(1/4) > >>

Deepthought:
I am writing a program to convert SMD files to an8.
The bones of an smd file are defined by a position and 3 euler angles in radians. I am using the following code to convert to an8



--- Code: ---smdbone sb=bones.get(x);
Bone b = new Bone();

b.name=sb.name;
b.length=new Vector3f(sb.x,sb.y,sb.z).length();
b.diameter=.2f;
--- End code ---

                     Quat4f orientation= new Quat4f();
           Quat4f xrot=new Quat4f();
            Quat4f yrot=new Quat4f();
            Quat4f zrot=new Quat4f();

                      xrot.set(new AxisAngle4f(1,0,0,sb.rotx));
            yrot.set(new AxisAngle4f(0,1,0,sb.roty));
            zrot.set(new AxisAngle4f(0,0,1,sb.rotz));
           
            orientation.set(xrot);
            orientation.mul(yrot);// same as orientation=orientation*yrot
            orientation.mul(zrot);
           
            System.out.println("orientation "+orientation.x+" "+orientation.y+" "+orientation.z+" "+orientation.w);
         
         b.orientation=(Quat4f) orientation.clone();[/code]
the output skeleton looks like a torture victim.
any ideas where i'm going wrong?

NickE:
I ran into the same sorts of problems when I was writing a BVH to Anim8or converter.  You need to know the reference frame for the SMD skeleton and rotate the SMD skeleton to the Anim8or reference frame right-handed (0,1,0).  The SMD reference frame is unclear, but seems to be left-handed (0,0,1).

Attached is the VB6 source code for the BVHtoAnim8or program.  To follow execution, look at cmd_sel_input_Click() and cmd_convert_Click().

NickE

Deepthought:
for SMD x is left, y is forward, z is up.
could you walk me through the math?
I'm still trying to make sense of that VB code

NickE:
Deepthought,

Is it your intention to (1) gain the experience and satisfaction of having written a converter for SMD files for Anim8or or (2) do you just want something that works?

If (1), then you need to gain a thorough understanding of the both the SMD file format(s) and reference frames and Anim8or's conventions for handling figures, sequences, and scenes.  The code in the BVH converter is not going to make sense unless you understand those concepts.  In a nutshell, the code reads and parses a BVH file, constructs an Anim8or figure, constructs a sequence for the non-positional movements, and then constructs a scene containing the figure and sequence so that position can be added.  In Anim8or, the figure's root bone is relative to the world coordinate system, but each child bone is relative to it's parent.  A cursory reading of the SMD format suggests the same arrangement (although it is not completely clear), but the world coordinate system is different from Anim8or's.

The math part essentially steps through the bones, rotates the bones into the reference frame, performs the relative rotation of child to parent, then rotates them back.

If (2), I'd be happy to help you out if you can be patient.  I would need some sample SMD's and either some viewer program or screenshots to see what the SMD file is supposed to look like.  My first guess is that the BVH conversion program can be easily adapted by writing a new parsing routine and other small changes.

NickE

Deepthought:
https://www.dropbox.com/s/tcufr4o27p9pze0/smd_package.zip?dl=0 contains a viewer and some decompiled SMDs

Right now I'm just trying to get some source models into anim8or. I already have code for parsing SMD files and for parsing and saving an8 files. the math for converting in between is what's giving me problems.

Navigation

[0] Message Index

[#] Next page

Go to full version