Yes, I am using several models with the same armature, and only one animation collection for all models.
In fact, t-pose is not used in any way when imported into the game engine. This function in the script only serves to initialize the matrices. The values did not need to be written to the file.
In the engine, I get matrices directly from positions and rotations:
Code:
procedure mat4.AssignEulerTranslation( e,t :vec3 );
var
cy,sy,cp,sp,cr,sr :float;
q :vec4;
begin
LoadIdentity;
cy := cos(e.z * 0.5);
sy := sin(e.z * 0.5);
cp := cos(e.y * 0.5);
sp := sin(e.y * 0.5);
cr := cos(e.x * 0.5);
sr := sin(e.x * 0.5);
q.w := cy * cp * cr + sy * sp * sr;
q.x := cy * cp * sr - sy * sp * cr;
q.y := sy * cp * sr + cy * sp * cr;
q.z := sy * cp * cr - cy * sp * sr;
with q do // m3 AssignQuaternion
begin
e00 := 1.0 - ( y * y + z * z ) * 2.0;
e01 := ( x * y + w * z ) * 2.0;
e02 := ( x * z - w * y ) * 2.0;
e10 := ( x * y - w * z ) * 2.0;
e11 := 1.0 - ( x * x + z * z ) * 2.0;
e12 := ( y * z + w * x ) * 2.0;
e20 := ( x * z + w * y ) * 2.0;
e21 := ( y * z - w * x ) * 2.0;
e22 := 1.0 - ( x * x + y * y ) * 2.0;
end;
e30 := t.x;
e31 := t.y;
e32 := t.z;
end;
For animation, I send these matrices to a simple shader like this:
Code:
uniform mat4 mm[32];
attribute vec3 vv;
attribute vec3 nn;
attribute vec2 tt;
attribute ivec2 bb;
attribute vec2 ww;
varying vec2 tex_coord;
varying vec3 normal;
void main( void )
{
ivec2 ibb = ivec2( bb );
vec4 v1 = vec4( vv , 1.0 );
vec4 v2 = ( mm[ibb[0]] * v1 ) * ww[0] + ( mm[ibb[1]] * v1 ) * ww[1];
vec4 n1 = vec4( nn , 0.0 );
vec4 n2 = ( mm[ibb[0]] * n1 ) * ww[0] + ( mm[ibb[1]] * n1 ) * ww[1];
normal = normalize( gl_NormalMatrix * n2.xyz );
tex_coord = tt;
gl_Position = gl_ModelViewProjectionMatrix * v2;
}
Bookmarks