Game Development Reference
In-Depth Information
Microsoft convention of adding a C to the class name is adopted
throughout this topic, for the principle of adding 'm_' member variable is
sometimes used.) For editing convenience we use a linked list for the
object class. Each object has a pointer to a CToon3DObject called
'm_next'. In the constructor for the object this is set to NULL, indicating
that the object is the last in the list. We also use a class called
CToon3DScene that has a member variable called m_ObjectList, which is
a CToon3DObject. We use a CToon3DObject rather than a pointer to an
object so that the list is always valid. The first member in the list is only
used as a place holder, it contains no geometry. A scene is effectively
empty if m_ObjectList.next is NULL. Referring back to the hierarchy, there
is no requirement that this appears in the order of the hierarchy, i.e. 'Torso'
does not have to be first, followed by 'Neck'. The list of objects in the
scene may well appear as shown in Table 7.1.
Table 7.1 Object list and parents
Object
Parent
Next pointer
m_ObjectList
NULL
Left Shoulder
Left Shoulder
Torso
Left Bicep
Left Bicep
Left Shoulder
Neck
Neck
Torso
Torso
Torso
NULL
Right Shoulder
Right Shoulder
Torso
Right Bicep
Right Bicep
Right Shoulder
Head
Head
Neck
Left Forearm
Left Forearm
Left Bicep
Left Hand
Left Hand
Left Forearm
Right Forearm
Right Forearm
Right Bicep
Right Hand
Right Hand
Right Forearm
NULL
Our transformation code starts with a function called 'UpdateAllOb-
jects'. A pointer to m_ObjectList.m_next is created if this is NULL, then the
list is empty and we have nothing to transform. In this example
m_ObjectList.next points to the object called 'Left Shoulder'; this object
has 'Torso' as a parent so we can skip this object for the time being, since
we are looking for objects with no parent. We skip past 'Left Bicep' and
'Neck' also until we get to 'Torso'. This object has no parent. So we
transform this object and then call a function called 'UpdateChildObjects'
passing the 'Torso' object as a parameter. 'UpdateChildObjects' has
 
Search Nedrilad ::




Custom Search