#124841 - relpats_eht - Mon Apr 09, 2007 3:03 am
I have been attempting to make the switch from software to hardware matrices on my model loader and have come across a bit of a problem: the resulting image seems to be ignoring all premultiplication translation.
Previously, I had been transforming each vertex through the matrix of its corresponding joint in software, which, simplified, was something like this:
The above worked just fine, but I am trying to move past that as it doesn't work well for normals and is slower than using hardware. Therefore, I now have code that looks like this:
But the result is incorrect. It seems that any translation, but not rotation, done before the call to glMultMatrix is lost in the final result. I do not know if and to what extent the final model is deformed, as I cannot see the whole thing without translation.
Thus, I ask, could anyone point out just what I am doing wrong? I think my matrices are stored in the same manner and those on the DS (translation on the bottom row) and I seem to be currently unable to figure this out.
** Yes, I know this code is horrible and inefficient. Step one is making things work, step two is aesthetics and optimization.
_________________
- relpats_eht
Last edited by relpats_eht on Wed Apr 11, 2007 2:43 am; edited 1 time in total
Previously, I had been transforming each vertex through the matrix of its corresponding joint in software, which, simplified, was something like this:
Code: |
Vector newVertex(curVert->location);
newVertex.Transform(matrix->GetMatrix()); F32* vert = newVertex.GetVector(); glTranslate3f32(vert[0].v, vert[1].v, vert[2].v); glVertex3v16(0, 0, 0); glTranslate3f32(-vert[0].v, -vert[1].v, -vert[2].v); |
The above worked just fine, but I am trying to move past that as it doesn't work well for normals and is slower than using hardware. Therefore, I now have code that looks like this:
Code: |
Matrix* matrix = &joint[curVert->boneId]->final;
F32* m = matrix->GetMatrix(); m4x4 glM; glM.m[0]=m[0].v; glM.m[1]=m[1].v; glM.m[2]=m[2].v; glM.m[3]=m[3].v; glM.m[4]=m[4].v; glM.m[5]=m[5].v; glM.m[6]=m[6].v; glM.m[7]=m[7].v; glM.m[8]=m[8].v; glM.m[9]=m[9].v; glM.m[10]=m[10].v; glM.m[11]=m[11].v; glM.m[12]=m[12].v; glM.m[13]=m[13].v; glM.m[14]=m[14].v; glM.m[15]=m[15].v; glPushMatrix(); glMultMatrix4x4(&glM); glTranslate3f32(curVert->location[0].v, curVert->location[1].v, curVert->location[2].v); glVertex3v16(0, 0, 0); glTranslate3f32(-curVert->location[0].v, -curVert->location[1].v, -curVert->location[2].v); glPopMatrix(1); |
But the result is incorrect. It seems that any translation, but not rotation, done before the call to glMultMatrix is lost in the final result. I do not know if and to what extent the final model is deformed, as I cannot see the whole thing without translation.
Thus, I ask, could anyone point out just what I am doing wrong? I think my matrices are stored in the same manner and those on the DS (translation on the bottom row) and I seem to be currently unable to figure this out.
** Yes, I know this code is horrible and inefficient. Step one is making things work, step two is aesthetics and optimization.
_________________
- relpats_eht
Last edited by relpats_eht on Wed Apr 11, 2007 2:43 am; edited 1 time in total