# [SOLVED] FK Bone Deformation Calculations

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone, I've been working on my FK deformation for my engine. I believe this is a very basic problem but my joint rotations seem to all rotate around the origin. I know with other affine tranformations that when doing rotations I have to move to the origin, rotate and move objects back to avoid this but I don't see how it is done for joints. I thank anyone for reading this post as I know it is long and contains alot of data sets. But I tried looking online for these calculations before in school and now and still have found very little literature describing the actual math behind it. Cube Data Source: here Basic data set for a cube: 8 vertices 1 -1 1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 When I export the cube with 2 joints via collada I get the two following bind pose matrices: M Bind Joint 1 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 M Bind Joint 2 1 0 0 0 0 1 0 -1 0 0 1 0 0 0 0 1 And in my collada .dae file I have the following nodes in my scene describing the transformation of the two joints. <node id="joint1" name="joint1" sid="bone0" type="JOINT"> <translate sid="translate">0 -1 0</translate> <rotate sid="jointOrientZ">0 0 1 0</rotate> <rotate sid="jointOrientY">0 1 0 0</rotate> <rotate sid="jointOrientX">1 0 0 0</rotate> - <node id="joint2" name="joint2" sid="bone1" type="JOINT"> <translate sid="translate">0 2 0</translate> <rotate sid="jointOrientZ">0 0 1 0</rotate> <rotate sid="jointOrientY">0 1 0 0</rotate> <rotate sid="jointOrientX">1 0 0 0</rotate> </node> From that I derived the counter matrices to the bind poses for the initial positions of the vertices: M Pose Matrix 1 1 0 0 0 0 1 0 -1 0 0 1 0 0 0 0 1 (Initial position of root joint 1) M Pose Matrix 2 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 (joint 2's translate added to joint 1 since it's its parent node) When I multiply these two with the given bind matrices it produces two identity matrices: for the base case M Bind * M Pose = M identity This is what I want since when I first bind the mesh to the joints, I don't want to displace any of the vertices. Now when I perform rotations, I leave the M Bind Matrices alone and instead modify the M Pose Matrices. Changes to parent matrices are propagated to children joints as one would expect. Now my weights for my vertices are as follows: Ordering : (joint 1 weight) (joint 2 weight) 1 (leading 1 that collada always gives for some reason) 0.9 0.1 0.9 0.1 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.9 0.1 0.9 0.1 I calculate the new vertex positions as follows: vf=vf.add(vi.mul(r).mul(scale)); vf- new vertex position accumluated from joint weights vi- initial vertex position as read from file r- calculated rotatation matrix using M bind * M pose for a given joint scale- weight value for that given joint for(int j=0;j<vertex.size();j++){     Vector4 vi=vertex.elementAt(j);     Vector4 vf=new Vector4(0,0,0,1);     for(int k=0;k<weight.elementAt(j).weight.size();k++){         int boneIndex;         float scale;         boneIndex=weight.elementAt(j).weight.elementAt(k).index;         scale=weight.elementAt(j).weight.elementAt(k).scale;         Matrix4x4 pose=new Matrix4x4(joint.elementAt(boneIndex).pose);         Matrix4x4 bind=new Matrix4x4(joint.elementAt(boneIndex).bind);         Matrix4x4 r=pose.mul(bind);         vf=vf.add(vi.mul(r).mul(scale));         vf.p[3]=1;     }     vertex.set(j,vf); } With this algorithm my cube rotates around the origin rather than the joints. My screen shots:
[Edited by - chibitotoro0_0 on January 4, 2009 10:31:34 PM]

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633704
• Total Posts
3013457
×