BaseTime Manual
A BaseTime object is used to define a point in time in a BaseDocument . If only frame numbers were used, changing the frame rate would cause keys either to overlap or disappear. If only float values (seconds) were used instead, there would be problems because of the limited data precision. For instance when using 30 fps the frame 29 = 29/30 could easily be misinterpreted as frame 28.
BaseTime internally stores the time values as exact fractions independent of the frame rate. For example frame 29 is stored as fraction with nominator 29 and denominator 30. The class always tries to keep the nominator and denominator as small as possible. Hence 15/30 is stored as 1/2, so if using 30 fps BaseTime::GetFrame() would return 15, but if using 24 fps it would return frame 12.
The current time of a BaseDocument can be handled using:
For timeline dimensions, preview time and used time see BaseDocument Manual .
To retrieve and modify BaseTime objects stored in a BaseContainer respectively use:
另请参阅 BaseContainer Manual .
To retrieve and modify BaseTime objects stored in a GeData object ( GeData type is DA_TIME ) respectively use:
另请参阅 GeData Manual .
Please notice that Cinema 4D can only handle a limited number of frames:
Animation keys are placed at certain frames. These frames can be respectively retrieved and modified using:
// check if the given object is a standard particle emitter if (object-> GetType () == Oparticle ) { GeData data;
// read the "Start Emission" parameter if (!object-> GetParameter ( DescID ( PARTICLEOBJECT_START ), data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
The frame number equivalent of the stored time depends on the current framerate:
BaseTime objects can be constructed by setting a time in seconds of by giving a frame and a framerate.
// This example adds a keyframe to the given animation track at the position 1.0 seconds. CCurve * const curve = track-> GetCurve (); if (curve != nullptr ) { const BaseTime time { 1.0 }; const CKey * const key = curve-> AddKey (time); if (key == nullptr ) return maxon::UnknownError( MAXON_SOURCE_LOCATION ); }// This example adds a keyframe to the given animation track at the position of frame 25. CCurve * const curve = track-> GetCurve (); if (curve != nullptr ) { const Int32 fps = doc-> GetFps (); const BaseTime time(25, fps); const CKey * const key = curve-> AddKey (time); if (key == nullptr ) return maxon::UnknownError( MAXON_SOURCE_LOCATION ); }
The internal value of a BaseTime object is represented by a numerator and denominator. Both values can be retrieved and modified using:
Two BaseTime objects can be compared using a special function or the usual operators:
BaseTime objects can be stored in a HyperFile using:
另请参阅 HyperFile Manual on BaseTime .