![]() |
Polygon Crucher SDK - Documentation
Documentation
|
C3DSceneNode are entities linked together hierarchically by the scene.
A node makes a reference to a C3DBaseObject giving it, in particular, a name and a matrix transformation.
So one of the important thing to know is how to create nodes and how to retrieve them using scene traversal.
Whereas a node can have no object attached to it, this is not recommended unless because such nodes are ignored during traversal unless using NODEPOS_ALLOW_EMPTY_NODES flag.
This simple code creates an object group and add it to the scene.
Several nodes can reference the same C3DBaseObject. This means that the scene contains the same object several times at different position. Instantiation is a simple way to save memory usage.
C3DSceneNode::IsObjectIntanciated allows to know if the node object is referenced several times, whereas C3DSceneNode::DeleteObjectInstanciation attach a copy of the instantiated object to the node (the object instantiation count decrease by one).
Transformations are associated to node using KEYFRAME_MATRIX (C3DMatrixKey) or a combination of KEYFRAME_ROT (C3DRotateKey), KEYFRAME_TRANS (C3DTranslateKey), KEYFRAME_SCALE (C3DScaleKey), KEYFRAME_PIVOT (C3DVectorKey).
The transformation associated to the node are the local transformation. It can be retrieved using C3DSceneNode::GetObjectLocalTM or C3DSceneNode::GetNodeLocalTM.
You can retrieve a world transformation matrix using C3DSceneNode::GetNodeTM which accumulates matrices along the hierarchy. Finally you can modify the node transformation using C3DSceneNode::SetObjectLocalTM.
Transformation are defined at a given time, which means that you'll have to define the time in most of the method. C3DScene::GetCurrentTime returns the current time.
It is possible to remove any transformation using C3DSceneNode::ConvertToGlobalCoordinates.