1
\$\begingroup\$

I am currently trying to load 3D models and animations into a program. The file format has no public description, so I am decoding them piece by piece. (I'm studying computer science and it's for educational purposes)

My problem is to restore 3 dimensional rotation from the skeleton files as the rotation is stored in 8 bytes only and I can't figure out how that data represents rotation around 3 axis. This is a sample skeleton with 11 joints:

                                   float |    float |    float             Bytes (hexadecimal values)
Joint  0: Parent: -1 Position: ( 0.000000|  0.000000|  0.000000) Rotation: 00 40 00 40 00 C0 00 C0
Joint  1: Parent:  0 Position: ( 3.042923| -0.000000| -0.085759) Rotation: 00 00 82 5A 00 00 82 5A 
Joint  2: Parent:  0 Position: ( 3.803955| -0.000000| -0.085759) Rotation: 00 00 82 5A 00 00 82 5A 
Joint  3: Parent:  0 Position: ( 4.482897| -0.000000| -0.085759) Rotation: 00 00 82 5A 00 00 82 5A 
Joint  4: Parent:  1 Position: ( 0.824744| -0.000000|  0.000000) Rotation: 00 00 00 00 00 00 FF 7F 
Joint  5: Parent:  2 Position: ( 0.694988| -0.000000|  0.000000) Rotation: 00 00 00 00 00 00 FF 7F 
Joint  6: Parent:  3 Position: ( 0.509095| -0.000000| -0.000000) Rotation: 00 00 00 00 00 00 FF 7F 
Joint  7: Parent:  4 Position: ( 0.609431|  0.000000|  0.000000) Rotation: 00 00 00 00 00 00 FF 7F 
Joint  8: Parent:  5 Position: ( 0.609431|  0.000000|  0.000000) Rotation: 00 00 00 00 00 00 FF 7F 
Joint  9: Parent:  6 Position: ( 0.609431|  0.000000| -0.000000) Rotation: 00 00 00 00 00 00 FF 7F 
Joint 10: Parent:  7 Position: ( 0.842106|  0.000000|  0.000000) Rotation: 00 00 00 00 00 00 FF 7F 

which should form roughly this shape:

3-6-9
|
|2-5-8
||
||1-4-7-10
|||
 0

But as you can see, the joints only extend in the 1st dimension (excluding 1, 2 and 3 which do extend a little in the 3rd dimension) so the coordinates have to be relative to the parent (which makes perfectly sense in terms of a skeleton).

My problem is to figure out how the rotation is stored in the 8 bytes per joint.

Short example: joints 1, 2 and 3 have to store a 90° rotation for the skeleton to work .. I allready did some research for different representations, but none can store arbitrary rotations around 3 axis in only 8 bytes, usually it takes double the space (4 floats) ..

\$\endgroup\$
  • \$\begingroup\$ Could it be a quaternion (4-vector) quantized to 2 bytes per component? \$\endgroup\$ – DMGregory Nov 2 '16 at 18:20
  • \$\begingroup\$ Could be short ints or half precision floats in 4 components representing quaternion or possibly angle axis. Might be fixed point decimal value too. \$\endgroup\$ – Coburn Nov 2 '16 at 19:52
  • \$\begingroup\$ Finally solved it. The data is stored as denormalized quaternions with short values for x y z and w and the magnitude is alway 2^15. \$\endgroup\$ – rootmenu Nov 10 '16 at 14:55
  • \$\begingroup\$ I have a similar problem. I'm working on a game that used to provide the whole quaternion in fp32 format, but they currently changed that to some nonsense 6 byte representation, which is not clear if its euler angles or the whole quaternion in some truncated float format. Can you please share how exactly the format worked in your case? \$\endgroup\$ – Greg K. Aug 13 '18 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.