Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches

Animation in scene

Whereas animation is read only from few formats (ie. 3ds), you can add or retrieve keyframe from the SDK. Particularly C3DSceneNode derive from C3DAnimatable class, which means you can animate the matrix transformation for example.

Here is some code that allows to retrieve the different keyframe of a node.

int i, size;
size = node->GetKeyNbr();
for (i = 0; i < size; i++)
{
int time;
const C3DKeyframe* key = node->GetKeyByIndex(i, &time);
switch (key->GetClassID())
{
case C3DKeyframe::KEYFRAME_MATRIX:
{
C4x4Matrix matrix = ((C3DMatrixKey&)*key).ToMatrix();
break;
}
case C3DKeyframe::KEYFRAME_SCALE:
{
C3DVector vector = ((C3DScaleKey&)*key).GetVector();
break;
}
case C3DKeyframe::KEYFRAME_ROT:
{
float angle;
C3DVector vector = ((C3DRotateKey&)*key).GetRotation(angle);
break;
}
case C3DKeyframe::KEYFRAME_TRANS:
{
C3DVector vector = ((C3DTranslateKey&)*key).GetVector();
break;
}
case C3DKeyframe::KEYFRAME_PIVOT:
{
C3DVector vector = ((C3DPivotKey&)*key).GetVector();
break;
}
}
}
This is the base class for any keyframe that is part of C3DKeyframable class.
Definition 3DKeyframe.h:49
This is the keyframe base class for transformation keyfrrame which allows to modify the node matrix t...
Definition 3DKeyframe.h:125
Definition 3DKeyframe.h:152
Definition 3DKeyframe.h:211
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition 3DKeyframe.h:222

You can also retrieve the whole scene time range, using C3DScene::GetTimeRange method and set/retrieve scene time using C3DScene::SetCurrentTime and C3DScene::GetCurrentTime