de_mon_uk

01-08-2004, 01:12 PM

Hi,

I am trying to make my 3D world rotate using the 'crystal sphere' method, using a mouse drag... and it works just fine except that when I'm done with the mouse drag the modelview matrix I transformed is not stored for the next draw and I can't work out why!

The final part of my transform is;

*rot = (float)((180/PI)*sqrt(dx*dx+dy*dy+dz*dz)/sqrt(R2));

glGetFloatv(GL_MODELVIEW_MATRIX,m);

*w1 = m[0]*a1 + m[1]*a2 + m[2]*a3;

*w2 = m[4]*a1 + m[5]*a2 + m[6]*a3;

*w3 = m[8]*a1 + m[9]*a2 + m[10]*a3;

After doing the glLoadIdentity(); in the draw loop I assumed glRotatef(rot, w1, w2, w3); would alter the matrix so that the next drag would alter it further yet it doesn't seem to work.

I know the maths is right but how do I make the new matrix my curent modelview matrix? Cheers.

I am trying to make my 3D world rotate using the 'crystal sphere' method, using a mouse drag... and it works just fine except that when I'm done with the mouse drag the modelview matrix I transformed is not stored for the next draw and I can't work out why!

The final part of my transform is;

*rot = (float)((180/PI)*sqrt(dx*dx+dy*dy+dz*dz)/sqrt(R2));

glGetFloatv(GL_MODELVIEW_MATRIX,m);

*w1 = m[0]*a1 + m[1]*a2 + m[2]*a3;

*w2 = m[4]*a1 + m[5]*a2 + m[6]*a3;

*w3 = m[8]*a1 + m[9]*a2 + m[10]*a3;

After doing the glLoadIdentity(); in the draw loop I assumed glRotatef(rot, w1, w2, w3); would alter the matrix so that the next drag would alter it further yet it doesn't seem to work.

I know the maths is right but how do I make the new matrix my curent modelview matrix? Cheers.