Game Development Reference
In-Depth Information
ï?® Camera : This is also a mathematical object that has a position and
orientation in 3D space. Additionally, it has parameters that govern how
much of the image we see, similar to a real camera. All these things together
define a view volume or view frustum (indicated by the pyramid with the
top cut off in Figure 7-1 ). Anything inside this pyramid can be seen by the
camera; anything outside will not make it into the final picture.
ï?® Viewport : This defines the size and resolution of the final image. Think of it
as the type of film you put into your analog camera or the image resolution
you get for pictures taken with your digital camera.
Given all this, OpenGL ES can construct a 2D bitmap of our scene from the camera's point of
view. Notice that we define everything in 3D space. So, how can OpenGL ES map that to two
dimensions?
Projections
This 2D mapping is done via something called projections . We already mentioned that OpenGL
ES is mainly concerned with triangles. A single triangle has three points defined in 3D space. To
render such a triangle to the framebuffer, OpenGL ES needs to know the coordinates of these
3D points within the pixel-based coordinate system of the framebuffer. Once it knows those
three corner-point coordinates, it can simply draw the pixels in the framebuffer that are inside the
triangle. We could even write our own little OpenGL ES implementation by projecting 3D points
to 2D, and simply draw lines between them via the Canvas .
There are two kinds of projections that are commonly used in 3D graphics.
ï?® Parallel (or orthographic) projection : If you've ever played with a CAD
application, you might already know about this. A parallel projection doesn't
care how far an object is away from the camera; the object will always have
the same size in the final image. This type of projection is typically used for
rendering 2D graphics in OpenGL ES.
ï?® Perspective projection : Your eyes use this type of projection every day.
Objects further away from you appear smaller on your retina. Perspective
projection is typically used when we do 3D graphics with OpenGL ES.
In both cases, you need something called a projection plane , which is nearly exactly the
same as your retina—it's where the light is actually registered to form the final image. While a
mathematical plane is infinite in terms of area, our retina is limited. Our OpenGL ES “retina� is
equal to the rectangle at the top of the view frustum seen in Figure 7-1 . This part of the view
frustum is where OpenGL ES will project the points. This area is called the near clipping plane ,
and it has its own little 2D coordinate system. Figure 7-2 shows that near clipping plane again,
from the camera's point of view, with the coordinate system superimposed.
 
Search WWH ::




Custom Search