Jump to content
  • Advertisement
Sign in to follow this  
Der_Therion

OpenGL Vector back to glrotate question

This topic is 2606 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello @ All,

i got an working 3 Vector rotation system (X;Y;Z) for an space sim game,

but now i want to set the rotation in opengl for the objects(and later the camera)

orientate the object to the z orientation vector is very easy with this formula:


//vx,vy,vz holds the Z vector

float wi_r1=get_winkel(vx,vz); //get angle of vx,vz)
float wi_r2=get_winkel( get_entf_2d(vx,vz),vy ); //get angle of distance (vx,vz)/vy

gl.glRotatef(wi_r1, 0, 1, 0);
gl.glRotatef(wi_r2+90, 1, 0, 0);

this is working absolutly perfect


but my problem is the roll
gl.glRotatef(roll, 0, 0, 1);


how do i calculate an float value from the Vx/Vy/Vz vectors the setup for the opengl



[size="6"]**UPDATE**




the glulookat function set up my camera 100% correct (even with roll by giving the up vector)

now i only need the same thing to the painted objects

[size="4"]//camera

gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();

glu.gluPerspective( pvi, asp, near,far );
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();


gl.glTranslatef(0,0,camera_distance);

glu.gluLookAt(vector[0],vector[1],vector[2], // origin the Z Vector
0,0,0, //targeting the zero origin
vector[6],vector[7],vector[8]); //up vector (Y)

...




and here i need the same like the glulookat do...

gl.glPushMatrix();
texture[9].bind();

// rotate to vetctors
gl.glCallList(2005);
gl.glPopMatrix();


much greetings




problem.jpg

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!