[SOLVED]Transformation problem

Started by elhoce, April 02, 2012, 03:21:48 PM

Previous topic - Next topic

elhoce

I try to make animations with the vertex shader using the transformation matrices calculated by bones.
Unfortunately I get enough strange animations.

I guess it comes from the fact that your calculation result is stored in the matrices JPCT.
But OpenGL expects to have an OpenGL matrix.
Are the two types of matrices compatible? Otherwise How can I convert the jpct matricx to openGl matrix without going through the method transforGL() of the JPCT class Matrix ?
To tell you the context, the treatment that you do in applySkeletonPose (animate3d class) I did it for my part in the VertexShader.

If I understand your algorithm, you apply the transformations on the mesh which is the previous animation, unlike me where the mesh is still bindPose. What should i do on the palette array to obtain the changes since the bind pose.

raft

yes, AFAIK jPCT and OpenGL matrices are not compatible, that's why the method Matrix.transformToGL() exists. why can't you use that method? if you really can't, Egon can give more detail about how to convert one to other

animation calculations do not depend on previous state or animation, however the thing you need to remember is each joint's (bone) transformation is in parent joint's space (relative to its parent)

elhoce

Thanks for your quick reply :)

The problem about the transformToGL call is the matrix identity (jpct) converted doesn't give me an identity matrix (OpenGL)

About your explanation, you said to care about the "relation to its parent", I suggest this link is already done by the updateTranforms call, cuz in the applySkeletonPose call I didn't saw particular code about this. I missed something ?

Thanks

raft

You're welcome :)

I'm not sure about Matrix thing. Egon may clarify it.

About parent relation, correct, that calculation is not done in applySkeletonPose, indeed it is done nowhere, it is exported that way by the exporter. But you have to take care of that if you programatically do animation like in ProceduralAnimationSample. Just a bit of information not sure if it will help in your case

EgonOlsen

transformToGL transforms your matrix in a way that vertex coordinates from jPCT will be transformed into GL's coordinate system when applying the matrix. That method's name might be a bit misleading. What this means it that an indentity matrix from jPCT wont result in the same matrix when using this method but in a matrix that will transform any jPCT coordinate into a gl coordinate as if you would have applied the identity matrix to some gl coordinate. For reference, this is what the method does:


public void transformToGL() {
mat0[1] *= -1f;
mat0[2] *= -1f;

mat1[1] *= -1f;
mat1[2] *= -1f;

mat2[1] *= -1f;
mat2[2] *= -1f;

mat3[1] *= -1f;
mat3[2] *= -1f;
}

elhoce

Thanks to you Egon for this precision.


Raft, my goal is to play an animation coming from an ogre xml, not to do animation by coding. So could you please tell if this bunch of code does the same thing that applySkeletonPose method :

     vec4 vPos = bones[j1] * vec4(position, 1.0) * w1 + bones[j2] * vec4(position, 1.0) * w2 + bones[j3] * vec4(position, 1.0) * w3 + bones[j4] * vec4(position, 1.0) * w4

with position is the position of the current vertex
j1,j2,j3,j4 the 4 indices of joints and w1,w2,w3,w4 the four weigths associated to the current vertex.

this code is executed for every vertex (vertex shader) of the mesh that I try to animate.

Thanks for your help :)

raft

assuming bones[jx]'s are palette matrices, yes, seems ok to me.

elhoce

Yes it's the palette array !

Now I'm trying to figure out how to interpret a matrix palette.
I have a simple animation :

<track bone="Head">
               <keyframes>
                        <keyframe time="0">
                            <translate x="0" y="0" z="0" />
                            <rotate angle="0.0">
                                <axis x="0" y="1" z="0" />
                            </rotate>
                            <scale x="1" y="1" z="1" />
                        </keyframe>
                        <keyframe time="10">
                            <translate x="0" y="0" z="0" />
                            <rotate angle="-30.0">
                                <axis x="1" y="0" z="0" />
                            </rotate>
                            <scale x="1" y="1" z="1" />
                        </keyframe>
                        <keyframe time="20">
                            <translate x="0" y="0" z="0" />
                            <rotate angle="30.0">
                                <axis x="1" y="0" z="0" />
                            </rotate>
                            <scale x="1" y="1" z="1" />
                        </keyframe>
               </keyframes>
            </track>

When I debuging my project, the palette matrix of the bone "Head" at "n" time is

translation : 7.8505083E-16, -0.77856064, -6.410426
rotation X axis : 1.0, -2.2415054E-17, 2.068825E-18
rotation Y axis : 2.2415054E-17, 0.9831068, -0.1830328
rotation Z axis : 2.068825E-18, 0.1830328, 0.9831068

I find the translation is wrong or this values are not about the translation ?
The result of the animation is that the head does translation animation over the z axis and  y axis; i think the rotation is interpreted as a translation  :(
I think my problem comes the interpretation of the matrix.
Could you please to help me to understand the values of the matrix in order to convert them for my vertex shader.

Thanks


raft

palette matrices contain the final value that can be directly applied to vertices. that takes into account that each joint's transform is in parent's space. have a look at SkeletonPose.updateTransforms() to see how pallette matrices are calculated.

therefore, dont expect to see with eye the real transform of a vertice in palette matrix, unless relevant joint has no parent.

at first try to avoid rotations, they are much harder to imagine. you can manually edit/create a skeleton file to see the result.

reading final part of this document may also help:
http://www.okino.com/conv/skinning.htm

elhoce

Thank you for your help, I solved my problems, my app works perfectly.  ;D

raft

cool, I'm glad to hear that  :)

so what you did is a software-hardware mixed skinning. how is the performance compared to sw only skinning? maybe you can publish what you did? ;)