OpenGL rotating a camera around a point

后端 未结 4 2124
别那么骄傲
别那么骄傲 2020-12-13 06:52

In OpenGL I\'m trying to rotate a camera around a point, with camera being distance r from the point and facing the point when it rotates. In other words, I want the camera

4条回答
  •  再見小時候
    2020-12-13 07:10

    it is a little confusing, but i think you should:

    // move camera a distance r away from the center
    glTranslatef(0, 0, -r);
    
    // rotate 
    glRotatef(angley, 0, 1, 0);
    glRotatef(anglex, 1, 0, 0);
    
    // move to center of circle    
    glTranslatef(-cx, -cy, -cz)
    

    note the order must NOT be changed.

提交回复
热议问题