I have all of that built into my Matrix3d class, so I’m set there.
What I’m wondering though is how you get the ‘camera’ to move about the world axes? Right now my engine (written from scratch) doesn’t really have a concept of camera, it’s just at (0,0,0) looking down the z-axis.
For right now I do all my matrix transformations on my objects, then move them to about (0,0,-200) so that they are in view of the camera.
Now I want to start moving the camera though, and don’t really know how to begin doing that.
The other option is to simulate camera movement by transforming all objects using the ‘world’ as the root as a large assembly. I don’t quite know how to do that given that I’d need to figure out dynamically which angles to rotate by to simulate the ‘camera’ moving.
I definitely would, it’s just that I wrote this rendering engine from scratch (no opengl or anything). I’m not quite sure mathematically how to approach this. I mean I’m rotating my models about the world axes, but then how do you do a ‘camera’ transformation? I don’t know if these rendering engines just figure out a world transform to apply to all models to make it ‘appear’ as if you’re really moving ‘the camera’, or if there really is some special class/implemenation of a camera you’re supposed to come up with?
The trick is to figure out the transform that you would use to move your camera object into the world, but instead of transforming the camera, you transform the rest of the world using the inverse of this transform.
I was just about to put a similar post up, so I hope no one minds me asking a quick question here to prevent a similar thread.
I know you can do the camera movements/rotations with gluLookAt, OR you could simply apply all the opposite transformations to everything else. But I was wondering which is more efficient for moving the camera with mouse and keyboard input?
There really is no difference in efficiency, the gluLookAt function also sets up a modelview matrix that is used to transform all other objects you’re drawing. The only difference is in the way you think about the problem.