Game Development Reference
In-Depth Information
Vector Representing Force
Vectors can also represent a force. A force has a direction and magnitude, so it is a good fit for
representation by vectors. In Figure 3-5 , you see a force vector acting on a ball. The direction of the
force is in the negative x direction. I will discuss forces acting on 3D objects in more depth later in
the topic. More specifically, forces will be discussed in Chapter 5, “Motion and Collision.”
y
z
Force Vector
(-3, 0,0)
Ball
x
Figure 3-5. Vector representing force
Vectors Representing Local Axes
Vectors can also represent an object's local axes. Figure 3-6 shows the local x, y, and z axes of a
3D cube object. Local axes are important because they define an object's orientation. That is, they
define which side of the object is considered up, which part of the object is the right side, and which
part of the object is considered the front or forward part. For example, if a 3D object represents a
vehicle such as a tank or car, then it would be good to know which part of the object is the front.
If you want to move the tank or car forward, for example, you would need the front or forward vector
in world coordinates as part of the calculation of the next position. The Orientation class defines an
object's local axes as m_Right , m_Up , and m_Forward .
// Local Axes
private Vector3 m_Right;
private Vector3 m_Up;
private Vector3 m_Forward;
y
z
(0,1,0)
y
(1 ,0,0)
x
(0,0,1)
z
x
Figure 3-6. Vectors representing local axes
 
 
Search WWH ::




Custom Search