# 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.

## 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 on other sites
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 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 on other sites
glRotate commands rotate around whatever the current origin is
perhaps do
glPushMatrix()
glTranslate( center of triangle )
glRotate(..)
glPopMatrix()

##### 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 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 on other sites
Quote:
 Original post by zedzeekglRotate commands rotate around whatever the current origin isperhaps doglPushMatrix()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.)

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632162
• Total Posts
3004507

×