Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Cutting Edge Direct 3D Programming
(Publisher: The Coriolis Group)
Author(s): Stan Trujillo
ISBN: 1576100502
Publication Date: 11/01/96

Bookmark It

Search this book:
 
Previous Table of Contents Next


Vertices

Vertices are points that are used to place objects such as faces and meshes in 3D space (we’ll talk about faces and meshes soon). Vertices, like points, are locations, so they are not visible. Still, Direct3D supports a mode in which vertices are drawn as dots. This mode is of little practical value because it’s hard to determine what’s being drawn based on vertices alone. In fact, scenes rendered in this mode look like 3D “connect the dots” puzzles. (Great—hand me a pencil!)

Faces

In Direct3D, a face is a flat graphical element that is defined in terms of vertices. Each vertex defines a corner of the face. All of the vertices in a face must exist in the same plane; they must define a face that is flat. Faces with vertices that do not exist in the same plane are invalid and cannot be drawn.

The simplest form of a face is defined with three vertices. The resulting triangular face is easy to work with for several reasons. First, it is impossible to define a set of three vertices that do not exist in the same plane, so the face cannot be invalid. Second, triangular faces are always convex, and convex faces can be rendered more efficiently than concave faces. Figure 2.7 shows some examples of faces.


Figure 2.7  Some sample faces.


Tip:  Direct3D uses triangles
Internally Direct3D Retained Mode divides non-triangular faces into triangles because the Immediate Mode interface (that does the actual rendering) accepts only triangles.

Faces are usually the only visible objects in a graphics system. Some graphics systems are capable of drawing curved surfaces but most, including Direct3D, use collections of small, flat faces to represent curved surfaces.

Meshes

A mesh is a collection of connected faces. Typically a mesh represents one object in a scene. A mesh can have one or more faces and can be very complicated. Figure 2.8 shows an example of a mesh. If you look closely at the figure, you can make out the individual faces.


Figure 2.8  A rendered mesh.

Normals

Normals are vectors used to calculate colors for faces and meshes. There are two types of normals: face normals and vertex normals.

A face normal is a vector that is perpendicular to the face. The normal determines the color of a face and which side of the face is visible. Figure 2.9 shows a cube with arrows representing the face normals.


Figure 2.9  Face normals for a cube.

Vertex normals are vectors that are assigned to each vertex in a mesh. The orientation of each vector depends on the orientation and size of the adjoining faces. Figure 2.10 shows the vertex normals for a cube.


Figure 2.10  Vertex normals for a cube.

The use of face normals versus vertex normals depends on the rendering method. Some rendering methods use face normals, others use vertex normals, and some rendering methods don’t use normals at all. We’ll talk about rendering methods later in this chapter.

In most cases, Direct3D calculates and uses normals automatically, so it’s not necessary that you know they exist. There are situations, however, when normals can be over-ridden to achieve specific rendering effects. We’ll talk about normals again in Chapter 8.

Translations

Now, we know how to place objects in three-dimensional space. We can specify vertices, define faces using vertices, and define meshes using faces. Now what we need is a way to move the objects around. There are three common operations (or translations) that can be used to move objects: translate, scale, and rotate. Using these three operations, it is possible to place an object in any location and give it any orientation.

Before we proceed, let’s construct a simple scenario that we can use as we discuss the translate, scale, and rotate operations. We’ll use a simple mesh: a cube. Our cube is centered on the origin and has dimensions of 1 by 1 by 1. Figure 2.11 shows this cube.


Figure 2.11  Our example cube.

Notice that because the cube is centered on the origin, each side of the cube extends ½ unit away from the origin. Notice also that each face (each side of the cube) is aligned perpendicularly with an axis.

Translate

The dictionary defines translate as: to express in another language. This definition has nothing to do with 3D graphics (that will teach you to look things up!). For our purposes here, translate means move.

Let’s say that we want to move (or translate) our sample cube up from the origin by two units. We can accomplish this by using a translation of <0, 2, 0>. Figure 2.12 shows the result.


Figure 2.12  A translated (moved) cube <0, 2, 0>.

Objects can be moved along several axes simultaneously with a single translation, so it isn’t necessary to perform a separate translation for each axis of movement. For example, a translation of <2, 2, 0> would move the cube two units to the right and two units up.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.