2011-12-02 86 views
1

我想模拟胸部开口,胸部开口由2个主要部分组成,即盖子和底座。在固定点上旋转OpenGL

为了在x轴上旋转,是否需要将盖子移动到原点,以便:a)盖子的任何角落位于(0,0,0)或; b)盖子的中心必须在原点上?

所以我的代码如下所示:

- draw the chest base 
- translate to origin 
- rotate 
- translate to original position 
- draw the lid 

回答

4

您应位置的盖子,以便它的支点是在原点。 枢轴点是它旋转的点,在这种情况下,它将是你的盖子的铰链。

至于你的代码的顺序:

- draw the chest base 
- translate so pivot point of lid is on origin 
- rotate 
- draw the lid 
- translate and rotate to original position