3D Animation Workshop: Lesson 110: Getting Under the Hood | 2 | WebReference

3D Animation Workshop: Lesson 110: Getting Under the Hood | 2


Lesson 110 - Getting Under the Hood - Part 2

There are eight vertices in the cube-shaped mesh, connected up to create 6 polygons, all of which are quads (four-sided polygons). To describe this mesh to a renderer, the scene description must provide the locations of all of the vertices and instructions for connecting them into polygons. Thus the geometry might be described as follows for a 10x10x10 cube:

Vertices:
  -5 -5  5
   5 -5  5
  -5 -5 -5
   5 -5 -5
  -5  5  5
   5  5  5
  -5  5 -5 
   5  5 -5
Polygons:
  0 2 3 1
  4 5 7 6
  0 1 5 4
  1 3 7 5
  3 2 6 7
  2 0 4 6

The eight vertices are specified as locations in 3D space, with (x,y,z) coordinates. Assume that (0,0,0) is the very center of the cube. Take a moment to visualize how these eight values represent the corners of the box. Can you see how the first vertex in the list is at the left lower front (in the conventional - not MAX - system in which y is vertical and z is depth)?

The six quads are created by "connecting the dots." The first quad (0, 2, 3, 1) uses the first, third, fourth and second vertices in the vertex list. Anyone with a programming background will be familiar with the convention of counting from 0, rather than from 1, and this explains why the vertices are referenced 0-7, rather than 1-8. Using these references, instead of the coordinate values themselves, saves space. It's shorter to write 0 than (-5, -5, 5).

The order in which we connect the vertices also determines the direction of the normal – the renderable side of the polygon. For example, a quad specified as (0 2 3 1) will render on one side, but a quad specified as (1 3 2 0) will render on the opposite side.

The vertex coordinates are used to define the shape of the object by specifying distances from some common origin (in this case, in the center of the cube). But this doesn't tell us where the cube is located in the scene. To do this, we need to "transform" the vertices from their local coordinate system to the world coordinate system of the entire scene. The idea here is actually quite simple if you take a moment to think it through.

We want to specify where the center of the cube is in the space of the entire scene. This is achieved by a transformation matrix. A transformation matrix is set of 16 numbers that can be used to convert coordinates in one coordinate system into equivalent values in another coordinate system. Assume that we want the center of the cube to be at (2,0,0) in the world coordinate system. A transformation matrix is applied to the all of the vertices of the cube. If the (0,0,0) coordinate of local space (the center of the cube) is transformed to (2,0,0) in world space, the first vertex in the vertex list will necessarily transform to (–3,-5,5) in world space.

Take a moment to visualize (and I mean visualize) this. Once you have done so, you'll have made a big step forward.

To Continue to Part 3, or Return to Part 1, Use Arrow Buttons

Created: January 16, 2001
Revised: January 16, 2001

URL: https://webreference.com/3d/lesson110/2.html