Game Development Reference
In-Depth Information
Subtracting the centerPos from the child node's position returns a position that is relat-
ive to the origin (0x0). That's the exact opposite of what you did in Listing 10-1 when
adding the origin to each point on the circle. The length of this point from the origin re-
turns the circle's radius, which is increased by _enlargeTextureRadius . This
newRadius is then multiplied with the normalized centerToChild point. Normaliz-
ing means reducing the vector's length to one unit while retaining its relative orientation.
Take, for instance, vertex #3 from Figure 10-5 . Assume its length to the center (vertex #1)
is 25 points, which is equal to the circle's radius. Now if you multiply the normalized vec-
tor between vertices 1 and 3 by 33, you'll get a point 3b that extends further outward on
the line defined by vertices 1 to 3. Do this to all the points and the circle ends up being
larger.
Since the _initialBodyPositions are used to calculate the texture coordinates, let
me illustrate why exactly you may need to do so. Figure 10-3 already illustrates that some
of the nodes are positioned still within the image, resulting in the suboptimal texture co-
ordinates shown in Figure 10-6 . To avoid cutting off parts of the texture, the texture co-
ordinates need to assume a circle with a slightly larger radius. Otherwise, some of the hair,
belly, and mouth of the player may be missing. On the other hand, this added radius must
not be too large. If it is, parts of other images in the Global Sprite Sheet may be drawn as
well.
Search WWH ::




Custom Search