


Of course, drawing empty shapes is hardly interesting, even in computer graphics. What we can do is fill them with color. Most colors can be represented by a combination of red, green and blue. So we use them in varying degrees to represent colors, where one color is used per 'channel'. Using 8 bits per color channel, we could represent 16.7 million colors on the screen (an 8 bit number can hold a value between 0 to 255, so we can represent this many color : 255 x 255 x 255). An additional 8 bits can be used to control the transparency of the shape - we usually call this the alpha channel. That's why we rarely see any difference between a 24 bit and 32 bit graphics. Of course, we can fill it with just one color, but we can do more since we can fill different colors for each pixels within the shape - for example a bitmap of a scanned photograph, a gradient fill or even a pattern.
Bringing it to 3D
If 2D graphics only uses two axis - the x and y axis, 3D adds another axis - the z axis - into the mix. This z axis represents depth and allows us to convey not just lines, curves and shapes but also volumes. Loot at a cube - it's basically nothing more than six squares, where one square shares a dot with two other squares. A pyramid is made up of four triangles and a square on the bottom. Even a ball is actually a circle rotated on an axis. You get the idea.
3D graphics allows us to present object that looks very closely to what we seen in real life. If you look at the same cube from the front, you could only see the side facing you. Turn it slightly, and you'll see the others. We know that a cube uses the same dimension for all its sides, but our visual perception of the cube depending on the angle and distance - this is called perspective. To our eyes, the back facing side of the cube is further away. A good 3D implementation must take this into account since we see everything around us in 3D and in perspective.
One of the obvious affects of perspective is the cube's sides appear less slanted when we move it left and right. It's actually easy to duplicate this effect in 3D - just shift the vectors for the back side of the cube. First, we need a vector describing the cube's position relative to the center of the screen (using the center of the cube). Then we 'correct' the vectors of all the dots in the cube to account for our perspective. It's the same thing for any object, even if our object is not a cube.
When we move an object along (or in parallel to) an axis, this is called translation. Since every dot in the box is drawn relative to its center, we only need to shift the center of the box relative to the center of the screen. Remember how rotation works in 2D? It's the same principle - rotate the center of the box relative to the center of the screen. Of course, since we're working in 3D, all this operation can be done on the x, y and z axis. For rotation, this means roll, yaw and pitch.
If we can move objects in 3D, shouldn't we be able to move ourselves as well? Well, yes! That's one of the greatest things with 3D, you can move your view just like you do in real life. You could move nearer to or further from an object, look up/down or left/right. Doing this in our virtual screen doesn't mean we're actually moving you or the camera. Instead, we move your perspective of everything in the 3D virtual world - we move everything you see in 3D in relation to you (or more accurately, the camera's position). This provides the illusion of movement to your eyes, although you hardly move at all! So every time you move in 3D, the computer must transform - translate and rotate all the objects in relation to you and take into account your perspective.
[Previous Page]
[Go to top]
[Next Page]