Jump to content
  • Advertisement
Sign in to follow this  
3Dgonewild

[OpenGL]-GLROTATE

This topic is 3923 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

Hi! I'm trying to make my main menu look more professional ,and i have some ideas that i can't compete them without some help. What im trying to do is , to make an object follow the mouse. Thats easy..right? Well,the truth is that im having problem with the rotation. How can i make the object to point at a given coordinates(x,y) ? example: Button1 is at (x)300,(y)450 Button2 is at (x)300,(y)500 Button3 is at (x)300,(y)550 Mouse is at 10,10 Our object(lets name it cursor) is at (x)300,(y)450 The user moves the mouse at button1. Some pseudo-code:

if (collide(mouse,button1))//mouse is over button1
{
//thats easy....
cursor.y=button1.y-button1.h/2
cursor.x=button1.x-button1.w-cursor.w/2

//Here , some how , i have to rotate the cursor to point button1!
cursor.rotate(blah?)
}




So ,how can i rotate the object with GLROTATE, so that it will point the selected button?

Share this post


Link to post
Share on other sites
Advertisement
Standard library cmath has a function called "atan2"

float atan2(float x, float y);
You pass relative position as x and y and you get angle.

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!