# rotation problem

## Recommended Posts

hi. i need to rotate a door but i don't know how to rotate through hinge. how can i translate the rotation axis. i have to keep that code structure, what will change or add to it ? void DrawDoor (float x,float y,float z,float angle){ glPushMatrix(); glTranslatef(x,y,z); glRotatef(angle,0.0f,1.0f,0.0f); glScalef(5.0f,10.0f,0.3f); BaseDoor(0.0f,0.0f,0.0f); glPopMatrix(); }

##### Share on other sites
KumGame07    145
Why don't you try this ?

Align the door parallel to Y axis (you may have to rotate it !!)	Translate your door to align it on along the Y axis 		Rotate the door about Y axis (Here you perform the actual rotation)	Translate backPerform another rotation to get back to the original position.

You will have to replace your glRotate call with the above procedure .

##### Share on other sites
i solved it .. thank you :)