1-2 3D Shape Specification


Next, the process of actual drawing when expressing a three-dimensional object on a computer by using triangles or quadrangles will be described.


1-2-1 3D Shape Specification


Each three-dimensional shape is made up of a combination of the following three elements:

  1. Vertices (corners)
  2. Edges (lines) that connect vertices
  3. Planes (surfaces) surrounded by edges
You can render any three-dimensional object on the computer by creating a detailed database of these three elements.



1-2-2 Using Vertices, Edges and Planes


Using vertices, edges, and planes to render three-dimensional models is more complex than it is to use them to render two-dimensional models. To render a cube in three-dimensions, you need information about 8 vertices, 12 edges, and 6 planes as shown here:


Figure 1-2-1 Using Vertices, Edges and Planes


You have to be careful when connecting vertices. If you simply connect vertices to make edges, you may end up rendering an object different from the one you want, as shown here:


Figure 1-2-2 Example of connecting between vertices


Also, for an object (surface mode) having planes, many three-dimensional processes have rules for creating these. The following three rules are representative of these.


# No Open Sides



Figure 1-2-3 Rule One About Creating Planes


# No Dents


Figure 1-2-4 Rule Two About Creating Planes


# No Twisting
Vertices must be on the same plane, and edges must not intersect


Figure 1-2-5 Rule Three About Creating Planes


If you create and draw planes that do not follow these three rules, you will not get the correct result. Therefore, you need to be careful when creating planes.


Rendering a model that has many planes takes a long time. Therefore, if you try to render a complex model in real-time, you may encounter problems. For real-time rendering, you have to pay close attention to the drawing rate. You need to decide how many surfaces (planes) your game can support. A model with few surfaces, like the cube on the right in the following illustration, requires a relatively "light" drawing process as compared to a model that has many surfaces, like the sphere on the left:


Figure 1-2-6 Model with many surface and Model with few surface


To help solve this problem, there is a technique called "back face culling" which ensures that no unseen back surfaces are drawn. This reduces the number of planes to be drawn and thus lightens the amount of work required.


Figure 1-2-7 Back Face Culling


The next problem is how we should judge the front and back of planes. Something obvious to a human being can be a difficult process for a computer. In general, computers judge the front and back by the order of edges created to connect vertices. In the N64 system, planes that are rendered by connecting vertices in a counter-clockwise manner become the front.


Figure 1-2-8 The order of edges created by connecting vertices


You can distinguish front and back for the computer by using a normal vector. This technique will be explained later. It is important for the computer to recognize the front from the back so that it can improve the drawing rate by not doing the drawing calculations for the back side planes.


Pay attention to all the issues discussed here when creating your planes. Then combine the planes to complete a three-dimensional object as shown here:


Figure 1-2-9 Combine planes and complete three-dimensional object


Use the following N64 functions to draw three-dimensional objects:

vertices->sides->surfaces

Examples of N64 Functions to Draw 3D Shapes

gSPVertex (load the vertex data)
gSPModifyVertex (change the vertex data)
gSP1Triangle (draw one triangle)
gSP2Triangles (draw two triangles)
gSPSetGeometryMode G_CULL_BACK
(turn on back face culling)
gSPClearGeometryMode G_CULL_BACK
(turn off back face culling)