Advertisement

Need help with this code ...

Started by January 23, 2001 06:20 AM
2 comments, last by penetrator 23 years, 10 months ago
I''ve set up a quad which is rotated through a quaternion ! The problem is that it rotates along it''s center, and I''ve not been able to set up the object rotation along another point (let''s say somewhere up on the Y axis, for example). This is the code of the draw function, somebody can help me ? Thanks ! glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0,-20,-100); glRotatef(-90,1,0,0); glPushMatrix(); dudes_quat.getMatrix( dudes_matrix ); glMultMatrixf(dudes_matrix); glColor3f(0.5f,0.5f,1.0f); glBegin(GL_QUADS); glVertex3f(-10.0f, 10.0f, 2.0f); glVertex3f( 10.0f, 10.0f, 2.0f); glVertex3f( 10.0f,-10.0f, 2.0f); glVertex3f(-10.0f,-10.0f, 2.0f); glEnd(); glPopMatrix();
im not 100% sure what u mean but with quaternions order is very important ie
q = q1 * q2 is totally different to
q = q2 * q1

http://members.xoom.com/myBollux
Advertisement
sorry zedzeek, I''ll try to explain better. I found very useful the code you indicated me (the fog sample using quaternions), so I modified it to fit my needs. Now I''m inside the cockpit of an aircraft flying over some terrain. As I pull the joystick to the left, I''ve to right-rotate the terrain along the Z axys (keeping the cockpit still), but the terrain rotates around it''s own center; instead, I need to rotate it around the cockpit !
mmhhh maybe is better if I study some english first ...

thanks anyway !

Um, what does dudes_quat.getMatrix( dudes_matrix ); do?

In your input routine, you need to modify the matrix first, then convert it to a quat, then you can mult it.

But can''t really help unless you post more code...


This topic is closed to new replies.

Advertisement