' transfers the objects matrix into opengl ready for render Function SetTransformMat(geom:Int) Local R:Float Ptr Local pos:Float Ptr Local matrix:Float[16]; pos =Float Ptr dGeomGetPosition (geom); R = Float Ptr dGeomGetRotation (geom); matrix[0]=R[0]; matrix[1]=R[4]; matrix[2]=R[8]; matrix[3]=0; matrix[4]=R[1]; matrix[5]=R[5]; matrix[6]=R[9]; matrix[7]=0; matrix[8]=R[2]; matrix[9]=R[6]; matrix[10]=R[10]; matrix[11]=0; matrix[12]=pos[0]; matrix[13]=pos[1]; matrix[14]=pos[2]; matrix[15]=1; glMultMatrixf (matrix); EndFunction Function EulerRotateGeom(geom:Int,x:Float,y:Float,z:Float) glPushMatrix() glLoadIdentity() glRotatef x,1,0,0 glRotatef y,0,1,0 glRotatef z,0,0,1 SetTransformMat(Geom) Local m:Float[16] Local m2:Float[16] glGetFloatv(GL_MODELVIEW_MATRIX,Varptr m[0]) m2[0]=m[0]; m2[1]=m[4]; m2[2]=m[8]; m2[3]=m[12] m2[4]=m[1]; m2[5]=m[5]; m2[6]=m[9]; m2[7]=m[13] m2[8]=m[2]; m2[9]=m[6]; m2[10]=m[10]; m2[11]=m[14] m2[12]=0; m2[13]=0; m2[14]=0; m2[15]=1 dGeomSetRotation(geom,Varptr m2[0]) glPopMatrix() End Function
Thanks Chris! This seems to be the blitzmax/opengl code you refer to that performs quat to euler. Is it a bit like the void AnglesFromMatrix C++ routine above?
Nice work btw, although I can't understand it :)