Previous Thread  Next Thread

chat icon Is there anybody can help out with blender's skeleton transf

davyzhang

Posted: Sun Jan 01, 2012 5:16 am
Joined: 21 Dec 2011
Posts: 5
I am working on a y up system for flash stage3d. I am trying to parse the collada file into stage3d ready format. But the flash uses y = up system, this is not a very big problem with geometries till I worked on skeleton system. In geometry render I just apply a 90 degree rotation along X axis and all works fine.

Here's couple of matrix I am currently working with to make a skeleton deformation

correct me if I have any mistake, thanks a lot

bind shape matrix, this one is like this
<bind_shape_matrix>1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1</bind_shape_matrix>
tidy up:
Code:
1 0 0 0
0 1 0 0
0 0 1 1
0 0 0 1

it's a perfect identified y up matrix, only one thing is not true: I moved the plane wich being deformed along Z axis 1 unit, but in y up system this should by y = 1 not z = 1.
So here's the problem, If I wanna change the matrix to Y up coordinate system, I can not just rotate it 90 degree along X axis like usual, cause it will affect the roation. I have to switch Y / Z translation only and leave the rotation alone. it's a weird way to switch z up to y up.

And then the inverse bind matrix, looks like this:
<float_array id="Armature_Plane-skin-bind_poses-array" count="32">1 0 0 0 0 0 1 -1 0 -1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 1</float_array>
tidy up as two matrixes with two bones
bone_001,bone
bone_001 is the child of bone and connected 1 unit up along z axis in blender.
Code:
1 0 0 0
0 0 1 -1
0 -1 0 0
0 0 0 1

1 0 0 0
0 0 1 0
0 -1 0 0
0 0 0 1

this time the translation is y up but the rotation is z up, the bone_001's y = -1 is exactly the postion where it is after inverse. but the rotation is z up, I need to apply -90 degree along x aixs to make it y up


Now the local transform of two bones in collada
<node id="Bone" name="Bone" sid="Bone" type="JOINT">
<matrix sid="transform">1 0 0 0 0 -4.37114e-8 -1 -4.37114e-8 0 1 -4.37114e-8 -1.91069e-15 0 0 0 1</matrix>
<node id="Bone_001" name="Bone.001" sid="Bone_001" type="JOINT">
<matrix sid="transform">1 0 0 0 0 1 -1.10446e-7 1 0 1.10446e-7 1 0 0 0 0 1</matrix>
</node>
</node>
the root bone's matrix is (I changed small value to zero to make it clearer)
Code:
1 0 0 0
0 0 -1 0
0 1 0 0
0 0 0 1

the child bone's matrix is
Code:
1 0 0 0
0 1 0 1
0 0 1 0
0 0 0 1

So the root bone's local transformation matrix is a typical z up matrix, but the child bone is a typical y up matrix relative to parent

I am totally freaked out by these matrixes, and spend nearly two weeks on how to make this right.

And now I still don't know if I understand this correctly or not,
and plus I wanna know Why so many type of matrix in bone system? or I just misunderstand something?

thanks for any hints,

I am no matrix expert, I made this far by doing a LOT of experiments, and I am seeking for officially theories.

src file is in the attachment export to collada file will get the result file for this post
Reply with quote


davyzhang

Posted: Sun Jan 01, 2012 5:19 am
Joined: 21 Dec 2011
Posts: 5
I didn't find how to attach the attachment
here is the full exported collada
Code:

<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
  <asset>
    <contributor>
      <author>Blender User</author>
      <authoring_tool>Blender 2.61.0 r42614</authoring_tool>
    </contributor>
    <created>2011-12-31T01:36:33</created>
    <modified>2011-12-31T01:36:33</modified>
    <unit name="meter" meter="1"/>
    <up_axis>Z_UP</up_axis>
  </asset>
  <library_geometries>
    <geometry id="Plane-mesh">
      <mesh>
        <source id="Plane-mesh-positions">
          <float_array id="Plane-mesh-positions-array" count="18">1 1 0 1 -1 0 -1 -0.9999998 0 -0.9999997 1 0 1 0 0 -0.9999999 2.68221e-7 0</float_array>
          <technique_common>
            <accessor source="#Plane-mesh-positions-array" count="6" stride="3">
              <param name="X" type="float"/>
              <param name="Y" type="float"/>
              <param name="Z" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <source id="Plane-mesh-normals">
          <float_array id="Plane-mesh-normals-array" count="12">0 0 1 0 0 1 0 0 1 0 0 1</float_array>
          <technique_common>
            <accessor source="#Plane-mesh-normals-array" count="4" stride="3">
              <param name="X" type="float"/>
              <param name="Y" type="float"/>
              <param name="Z" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <vertices id="Plane-mesh-vertices">
          <input semantic="POSITION" source="#Plane-mesh-positions"/>
        </vertices>
        <polylist count="4">
          <input semantic="VERTEX" source="#Plane-mesh-vertices" offset="0"/>
          <input semantic="NORMAL" source="#Plane-mesh-normals" offset="1"/>
          <vcount>3 3 3 3 </vcount>
          <p>5 0 2 0 1 0 5 1 1 1 4 1 4 2 0 2 5 2 0 3 3 3 5 3</p>
        </polylist>
      </mesh>
      <extra><technique profile="MAYA"><double_sided>1</double_sided></technique></extra>
    </geometry>
  </library_geometries>
  <library_controllers>
    <controller id="Armature_Plane-skin" name="Armature">
      <skin source="#Plane-mesh">
        <bind_shape_matrix>1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1</bind_shape_matrix>
        <source id="Armature_Plane-skin-joints">
          <Name_array id="Armature_Plane-skin-joints-array" count="2">Bone_001 Bone</Name_array>
          <technique_common>
            <accessor source="#Armature_Plane-skin-joints-array" count="2" stride="1">
              <param name="JOINT" type="name"/>
            </accessor>
          </technique_common>
        </source>
        <source id="Armature_Plane-skin-bind_poses">
          <float_array id="Armature_Plane-skin-bind_poses-array" count="32">1 0 0 0 0 0 1 -1 0 -1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 1</float_array>
          <technique_common>
            <accessor source="#Armature_Plane-skin-bind_poses-array" count="2" stride="16">
              <param name="TRANSFORM" type="float4x4"/>
            </accessor>
          </technique_common>
        </source>
        <source id="Armature_Plane-skin-weights">
          <float_array id="Armature_Plane-skin-weights-array" count="4">1 1 1 1</float_array>
          <technique_common>
            <accessor source="#Armature_Plane-skin-weights-array" count="4" stride="1">
              <param name="WEIGHT" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <joints>
          <input semantic="JOINT" source="#Armature_Plane-skin-joints"/>
          <input semantic="INV_BIND_MATRIX" source="#Armature_Plane-skin-bind_poses"/>
        </joints>
        <vertex_weights count="6">
          <input semantic="JOINT" source="#Armature_Plane-skin-joints" offset="0"/>
          <input semantic="WEIGHT" source="#Armature_Plane-skin-weights" offset="1"/>
          <vcount>1 1 1 1 0 0 </vcount>
          <v>0 0 1 1 1 2 0 3</v>
        </vertex_weights>
      </skin>
    </controller>
  </library_controllers>
  <library_visual_scenes>
    <visual_scene id="Scene" name="Scene">
      <node id="Armature" type="NODE">
        <translate sid="location">0 0 0</translate>
        <rotate sid="rotationZ">0 0 1 0</rotate>
        <rotate sid="rotationY">0 1 0 0</rotate>
        <rotate sid="rotationX">1 0 0 0</rotate>
        <scale sid="scale">1 1 1</scale>
        <node id="Bone" name="Bone" sid="Bone" type="JOINT">
          <matrix sid="transform">1 0 0 0 0 -4.37114e-8 -1 -4.37114e-8 0 1 -4.37114e-8 -1.91069e-15 0 0 0 1</matrix>
          <node id="Bone_001" name="Bone.001" sid="Bone_001" type="JOINT">
            <matrix sid="transform">1 0 0 0 0 1 -1.10446e-7 1 0 1.10446e-7 1 0 0 0 0 1</matrix>
          </node>
        </node>
      </node>
      <node id="Plane" type="NODE">
        <translate sid="location">0 0 0</translate>
        <rotate sid="rotationZ">0 0 1 0</rotate>
        <rotate sid="rotationY">0 1 0 0</rotate>
        <rotate sid="rotationX">1 0 0 0</rotate>
        <scale sid="scale">1 1 1</scale>
        <instance_controller url="#Armature_Plane-skin">
          <skeleton>#Bone</skeleton>
        </instance_controller>
      </node>
    </visual_scene>
  </library_visual_scenes>
  <scene>
    <instance_visual_scene url="#Scene"/>
  </scene>
</COLLADA>
Reply with quote


davyzhang

Posted: Wed Jan 04, 2012 7:57 am
Joined: 21 Dec 2011
Posts: 5
All the problem is on z up to y up. I'll try to explain here:

at first I tried to simply rotate 90 along x axis to every matrix I get ,to make it y up.

But this is a lazy and dangerous move. It only change the matrix but not the vertex position. And more worse, the matrix can not be changed back, because it mixed with other rotation later.This make me very hard to track down the current vertex position and make sure it's right.

I realize I should change the vertex position and matrix at very first when I read from file, So I tried switch y and z translation, and make z = -y. Aslo the rotation switch rz and ry and make rz = -ry. this approach is more understandable and obvious than rotate.

Now the problem sovled, every matrix my previous post mentioned is correctly switched and skeleton is worked as it is
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group