Sit or stand with your head pointing straight up. Tilt your head to your left. Note the view, the slant of the horizon, the movement (if any) of surrounding objects.
Tilt your head back to pointing straight up. Now imagine the view in front of you tilting to your right. Can you imagine the scene as having the same view as if you tilted your head left?
That was exactly what I was trying to achieve when I implemented a custom camera object to overcome a particular viewing problem in 3D. Well, you’ll have to wait for another article for the description of the problem. I’m going to just describe the function of that custom camera in this article.
So in 3D scenes, you have the scene objects and a virtual camera. Using the position and orientation of the camera, you can view the scene (by rendering the scene onto the viewing plane). This is analogous to the physical world.
Now, in the physical world, the scene, the set, and the props typically don’t move. Only the camera moves (we’ll leave out the human actors). I’m referring to the movement where an object goes from one place to another. Movement such as water flowing, or explosions aren’t included (as far as the discussion goes).
For a physical camera, there are limits. You can’t quite fly a camera through an explosion. You need special cameras to go through tiny openings. You’ve got to be careful when working with mirrors, because the camera (and cameraman) can be inadvertently captured (unless that was the effect). And you definitely can’t pass through walls.
A virtual camera in a 3D scene has none of those limitations. As far as the renderer is concerned, a camera is just a point, unless it’s modelled and treated as a 3D object. It can film the hottest of volcanic films, or be submerged in the depths of the seas, and remain undamaged. Now, the virtual camera might be limitless, but that’s not the point. Due to the transformations such as translations, rotations and scaling, the 3D scene itself can be modified at will.
I was inspired by a remark made by my university lecturer. He said that moving the camera towards a stationary object, is the same as moving the object towards the stationary camera. This also implied that rotating the camera clockwise around a stationary object, is the same as rotating the object anti-clockwise around the stationary camera.
This opened my eyes to another corollary. You don’t need to move the camera at all! You can move the entire scene instead.
So I set out to design a camera object where the entire 3D scene depended on it. What I mean is, instead of setting camera properties and have them work nicely with the 3D scene, the 3D scene itself conforms to the camera properties.
For example, if I set the camera position at (1,0,0), in actuality, the camera is still at (0,0,0). But the entire 3D scene is translated (-1,0,0).
What I did was set the camera at a default position, say (0,0,5) (I’m using the upright Y-axis), and set the camera’s “up” vector to (0,1,0) (meaning it’s head is pointing upwards, so it’s level with the ground). Then everything else is done with respect to this default camera orientation.
So why am I doing all this? I was bored, I had time then, and I wanted to solve a particular problem. I’ll tell you more about the mechanics of the camera, and the problem some other time…