On 09/30/2013 02:21 AM, cristupidmail wrote:
> Ok, the rest position of the vertex V, for example, is clear (pos_V[0]).
> Instead if I want to know the position of the vertex V in a certain time
> "1" (not binding time), which operation does OpenSG apply?
> Something like: pos_V[1] = mat_joint[1] * matBind ?

not exactly. The joint matrices are not indexed by time, but by joint 
index (a samll number uniquely identifying the joint within the 
skeleton). Every vertex has a number (usually <= 4) of joints that 
influence it and as many weights that determine how strong the effect of 
a joint on the vertex is [1]:

mat4x4 matJoints[N];
uint4  jointIdx;
float4 jointWeight;

float4 inPos; // vertex position in the mesh
float4 outPos = (0, 0, 0, 0);

for(i=0; i < 4; ++i)
{
     outPos += jointWeight[i] * (matJoints[jointIdx[i]] * inPos);
}

This assumes the jointWeights have been properly normalized so that they 
add up to 1 - otherwise you need to divide by the sum of the weights to 
compensate.
The matrices in matJoints are themselves computed by multiplying all 
joint matrices up to the root joint and then multiplying by the joint's 
bind matrix. So assuming joint i has parents joint a and joint b:

matJoints[i] = joint[a].matrix * joint[b].matrix *
                joint[i].matrix * joint[i].bindMatrix;

        Hope it helps,
                Carsten

[1] see the GLSL code in 
Source/System/Dynamics/Skeleton/OSGGPUSkinningAlgorithm.cpp
[2] see 
Source/System/Dynamics/Skeleton/OSGSkeletonJoint.cpp:jointUpdateEnter()


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to