Graphics Reference
In-Depth Information
bool UWB _ SceneNode::GetNodeBounds( const UWB _ SceneNode * pSearchNode ... ) const
// helper function implementing WC bbox computation
return GetNodeBoundsHeler(pSearchNode ... )
bool UWB _ SceneNode::GetNodeBoundsHelper( const UWB _ SceneNode * pSearchNode ... ) const
.
// when successfully find the target node
if ( this == pSearchNode )
// compute the WC bounding box and return
A:
box = this ->GetBounds( ... )
// otherwise set up OC-to-WC xform and continue searching
else
// concatenate transforamtion onto matrix stack
B:
helper.PushModelTransform();
// to allow computation of OC-to-WC xform
this ->GetXformInfo().SetUpModelStack(helper);
// search all children for the target node
for ( int i=0; i< this ->NumChildren(); i++)
B1: if ( this ->GetChildNode(i)->GetNodeBoundsHelper( pSearchNode, ...))
.
found = true ;
// restore trop of matrix stack
C:
helper.PopModelTransform();
return found;
Listing 11.14. The SceneNode::GetNodeBounds() function.
Source file.
uwbgl _ SceneNode2.cpp
file in the Common Files/
SceneNode subfolder
Restore the top of matrix stack (E). At label E, we restore the top of the
matrix stack before returning the results of the computed bounding box in
WC space.
of
the
UWBGL _ D3D _ Lib12 project.
Observe from the above discussion that in order to compute the WC bounding
box of a scene node, we need to know all of its ancestors' transformations. For
example, the left arm's WC bounding box, B wc
la , is computed by transforming the
bounding box in OC, B oc
la , based on its parent's transformation M b .Ifwewantto
determine if the mouse-click position is within the bounds of the left arm (inde-
pendent of that of the body node), we still have to begin the OC-to-WC transfor-
Search WWH ::




Custom Search