hi thank you for the reply,i already did all of that and i’m able to display each frame transform (using directly the collada matrix),the problem i’m having is decomposing this matrix and blending 2 frames; i already checked all the maths i used and there are no errors i mean i used as reference the euclideanspace site

and i checked my functions results with their app

i show you some code of my implementation:

this is where i transpose the matrices(i mean i directly put them in column major)

```
for(UINT16 a = 0;a < model_ptr->bone_count; ++a)
{
mat_array_index = 0;
for(UINT16 b = 0;b < model_ptr->animation_count;++b)
{
model_ptr->bone[a].anim[b].bone_local_matrix = (MAT4*)malloc(sizeof(MAT4)*model_ptr->bone[a].anim[b].frame_count);
for(UINT16 c = 0;c < model_ptr->bone[a].anim[b].frame_count;++c)
{
for (UINT16 r1 = 0;r1<4;++r1)
{
for(UINT16 r2 = 0;r2<4;++r2)
{
model_ptr->bone[a].anim[b].bone_local_matrix[c][r2][r1] = parser_ptr->mat_array[a][mat_array_index];
printf("MATRIX BONE %d NUM %d = %f \n",a,c,model_ptr->bone[a].anim[b].bone_local_matrix[c][r2][r1]);
mat_array_index++;
}
}
}
}
}
```

and this is how i calculate the global transform matrix of each bone(i already did a bone map but now i’m trying to blending and calculate the local transform so i hardcoded a little to have the steps clear),also i’m using 4 bones to keep stuffs simple and each bone is child of the previous one so no tree for now

```
MAT4 global0;
MAT4 global1;
MAT4 global2;
MAT4 global3;
mat4_init(global0);
mat4_init(global1);
mat4_init(global2);
mat4_init(global3);
mat4_multiply(global0,model_ptr->identity,model_ptr->bone[0].anim[0].bone_local_matrix[frame]);
mat4_multiply(bot_bones->final_transform[0],global0,model_ptr->bone[0].inverse_model_space_bind_transform);
mat4_multiply(global1,global0,model_ptr->bone[1].anim[0].bone_local_matrix[frame]);
mat4_multiply(bot_bones->final_transform[1],global1,model_ptr->bone[1].inverse_model_space_bind_transform);
mat4_multiply(global2,global1,model_ptr->bone[2].anim[0].bone_local_matrix[frame]);
mat4_multiply(bot_bones->final_transform[2],global2,model_ptr->bone[2].inverse_model_space_bind_transform);
mat4_multiply(global3,global2,model_ptr->bone[3].anim[0].bone_local_matrix[frame]);
mat4_multiply(bot_bones->final_transform[3],global3,model_ptr->bone[3].inverse_model_space_bind_transform);
```

for the math i have only an header where i put functions that i do myself or that i find online,for the quaternion math i took a function from linmath library and for the interpolations i followed the previous site,but i repeat i checked thousand of times the math with different matrices and the result compared with the site are correct…so the problem now can be

- i’m extrapolating the wrong values from the bone_local_matrix -> i repeat my matrix is already transposed like you see in the function so if in the collada there is 1 2 3 4 5 6 7 8 etc

in my matrix they are 1 5 9 13 etc
- i’m missing some step during blending
- my math is wrong and i’m blind

so to be complete i post you also the other functions where maybe someone will see mistakes

quaternion math (copied by linmath library)

```
static inline void quat_from_mat4(QUAT q, MAT4 M)
{
float r = 0.f;
int i;
int perm[] = {0, 1, 2, 0, 1};
int *p = perm;
for (i = 0; i < 3; i++) {
float m = M[i][i];
if (m < r) continue;
m = r;
p = &perm[i];
}
r = sqrtf(1.f + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]]);
if (r < 1e-6) {
q[0] = 1.f;
q[1] = q[2] = q[3] = 0.f;
return;
}
q[0] = r / 2.f;
q[1] = (M[p[0]][p[1]] - M[p[1]][p[0]]) / (2.f * r);
q[2] = (M[p[2]][p[0]] - M[p[0]][p[2]]) / (2.f * r);
q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]]) / (2.f * r);
}
static inline void quat_interpolate(QUAT output,QUAT quat_1,QUAT quat_2, FLOAT progression)
{
output[0] = 0.0f;
output[1] = 0.0f;
output[2] = 0.0f;
output[3] = 1.0f;
FLOAT dot = (quat_1[0] * quat_2[0]) + (quat_1[1] * quat_2[1]) + (quat_1[2] * quat_2[2]) + (quat_1[3] * quat_2[3]);
FLOAT k = 1.0f - progression;
if (dot < 0)
{
output[0] = (k * quat_1[0]) + (progression * (-quat_2[0]));
output[1] = (k * quat_1[1]) + (progression * (-quat_2[1]));
output[2] = (k * quat_1[2]) + (progression * (-quat_2[2]));
output[3] = (k * quat_1[3]) + (progression * (-quat_2[3]));
}
else
{
output[0] = (k * quat_1[0]) + (progression * quat_2[0]);
output[1] = (k * quat_1[1]) + (progression * quat_2[1]);
output[2] = (k * quat_1[2]) + (progression * quat_2[2]);
output[3] = (k * quat_1[3]) + (progression * quat_2[3]);
}
vec4_normalize(output);
}
and the last vec3
static inline void vec3_interpolate(VEC3 output,VEC3 vec_1,VEC3 vec_2,FLOAT progression)
{
FLOAT x = vec_1[0] + (vec_2[0] - vec_1[0]) * progression;
FLOAT y = vec_1[1] + (vec_2[1] - vec_1[1]) * progression;
FLOAT z = vec_1[2] + (vec_2[2] - vec_1[2]) * progression;
output[0] = x;
output[1] = y;
output[2] = z;
}
```

well i know it’s a lot of stuff and i won’t expect nothing,it’s just desperation bye and thanks again