Jump to content
  • Advertisement
Sign in to follow this  
Ey-Lord

OpenGL [newbie question ] spin'

This topic is 4827 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 guys , i just started 3D opengl( i used 2D b4 ) . I'm just learning the basic . I 've built a pyramid ( 4 triangles / 1 quad ) . I'm able to rotate it around an axis ; but i cnt find how i can rotate it on itself . I mean : My camera is on (0,0,10) The top of my pyramid is facins the camera , the root is on the (x0z ) plane . I want that my pyramid's top STAY where it is ; and taht the 4 triangles rotate around an Y axis . i hope you understand what i mean ;o) any ideas ?

Share this post


Link to post
Share on other sites
Advertisement
Many times it's simply an order-of-operations thing. Try flipping the order of your translates and rotates an see if you get the desired results. It takes a while to get comfortable with it, but there is a rhyme and a reason to the way things happen.

Share this post


Link to post
Share on other sites
i understand what u say , but i cant find what i want :/

im using


glTranslatef(-2,0,0);
glRotatef(rtri,0,1,0);
// the drawing of my triangles


i tried to swap those ... doesnt worked .

Share this post


Link to post
Share on other sites
glRotate commands rotate around whatever the current origin is
perhaps do
glPushMatrix()
glLoadIdentity();
glTranslate( center of triangle )
glRotate(..)
glPopMatrix()

Share this post


Link to post
Share on other sites
i just tried something different ( if think your method will get the same result )

i just rewrote my pyremid coordinate so that the center is around the Y axe ( b4 she was elswhere on the screen ) ...
thx anyway ill try that too .

Share this post


Link to post
Share on other sites
so the pyramid would look like this, seen from the camera?

----
|\ /|
| \/ |
| /\ |
|/ \|
----

then you should rotate around the z-axis I think

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
glRotate commands rotate around whatever the current origin is
perhaps do
glPushMatrix()
glLoadIdentity();
glTranslate( center of triangle )
glRotate(..)
glPopMatrix()


You have to be pretty careful with this, though. Depending on how his camera is set up the glLoadIdentity() may undo any transformations from his view matrix, which again would give funky results. (Most likely putting him inside the pyramid.)

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.

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!