Game Development Reference
In-Depth Information
space tree can change dynamically during the lifetime of a virtual world;
for example, the sheep's fleece can be sheared and taken away from the
sheep, and thus the fleece coordinate space goes from being a child of the
sheep body's coordinate space to being a child of the world space. The
hierarchy of nested coordinate spaces is dynamic and can be arranged in
a manner that is most convenient for the information that is important
to us.
3.5
In Defense of Upright Space
Finally, please allow us a few paragraphs to try to persuade you that the
concept of upright space is highly useful, even though the term may not
be standard. Lots 9 of people don't bother distinguishing between world
space and upright space. They would just talk about rotating a vector
from object space to “world space.” But consider the common situation in
code when the same data type, say float3 , is used to store both “points”
and “vectors.” (See Section 2.4 if you don't remember why those terms
were just put in quotes.) Let's say we have one float3 that represents the
position of a vertex in object space, and we wish to know the position of
that vertex in world space. The transformation from object to world space
must involve translation by the object's position. Now compare this to a
different float3 that describes a direction, such as a surface normal or the
direction a gun is aiming. The conversion of coordinates of the direction
vector from object space to “world space” (what we would call “upright
space”) should not contain this translation.
When you are communicating your intentions to a person, sometimes
the other person is able to understand what you mean and fill in the blanks
as to whether the translation happens or not when you say “world space.”
This is because they can visualize what you are talking about and implicitly
know whether the quantity being transformed is a “point” or a “vector.”
But a computer does not have this intuition, so we must find a way to be
explicit. One strategy for communicating this explicitly to a computer is
to use two different data types, for example, one class named Point3 and
another named Vector3 . The computer would know that vectors should
never be translated but points should be because you would write two dif-
ferent transformation routines. This is a strategy adopted in some sources
of academic origin, but in production code in the game industry, it is not
common. (It also doesn't really work well in HLSL/Cg, which greatly en-
courages the use of the generic float3 type.) Thus, we must find some
other way to communicate to the computer whether, when transforming
9 Here, the word “lots” means “almost everybody.”
 
Search WWH ::




Custom Search