Re: [PyOpenGL-Users] Newbe question on pyopengl
Brought to you by:
mcfletch
From: Greg E. <gre...@ca...> - 2007-11-28 01:32:31
|
duncan duncan wrote: > So what are the correct way ? Rotate the object or move the camera ? There isn't really any difference between these -- they're just two different ways of thinking about the same thing. If thinking in terms of rotating the object works for you, then there's nothing wrong with that. However, as you develop your application further, you may find it helpful to think of the object-to-camera transformation as consisting of two stages: 1) Transform from object to world coordinates 2) Transform from world to camera coordinates Then you can implement operations such as "move the object along the x axis" by changing the object-to-world part of the transformation, and not have to worry about what direction the x axis is pointing relative to the camera. Setting up such a 2-stage transformation would go something like glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(...) # or gluOrtho for an orthographic projection glMatrixMode(GL_MODELVIEW) glLoadIdentity() gluLookAt(...) # Establish world-to-camera transform glMultMatrixd(object_to_world_transform) # Render object Note that gluLookAt is used on the modelview matrix, not the projection matrix. -- Greg |