About
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.
Access
The current time of a BaseDocument can be handled using:
- BaseDocument::GetTime(): Returns a BaseTime storing the current time.
- BaseDocument::SetTime(): Sets the current time of the document using a BaseTime object.
- SetDocumentTime(): Sets the given document's time.
For timeline dimensions, preview time and used time see BaseDocument Manual.
To retrieve and modify BaseTime objects stored in a BaseContainer respectively use:
- BaseContainer::GetTime(): Returns the BaseTime stored at the given ID.
- BaseContainer::SetTime(): Sets the BaseTime stored at the given ID.
See also BaseContainer Manual.
To retrieve and modify BaseTime objects stored in a GeData object (GeData type is ::DA_TIME) respectively use:
- GeData::GetTime(): Return the BaseTime object.
- GeData::SetBaseTime(): Stores the BaseTime object.
See also GeData Manual.
Please notice that Cinema 4D can only handle a limited number of frames:
- MAXTIME: The maximum number of frames Cinema 4D can handle in a timeline.
Animation keys are placed at certain frames. These frames can be respectively retrieved and modified using:
- CKey::GetTime(): Returns the time of the key.
- CKey::SetTime(): Sets the time of the key.
BaseObject*
const object =
doc->GetActiveObject();
if (object == nullptr)
{
GeData data;
const BaseTime time = data.GetTime();
}
NONE
Definition: asset_browser.h:1
#define Oparticle
Particle emitter - ParticleObject.
Definition: ge_prepass.h:1052
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define ConstDescID(...)
Definition: lib_description.h:592
@ PARTICLEOBJECT_START
Definition: oparticle.h:28
const char * doc
Definition: pyerrors.h:226
Time and Frame
The frame number equivalent of the stored time depends on the current framerate:
- BaseTime::Get(): Returns the time in seconds.
- BaseTime::GetFrame(): Returns the frame equivalent to the stored time based on the given framerate.
- BaseTime::Quantize(): Quantizes the internally stored value so that it is a multiple of the given framerate.
const BaseTime now =
doc->GetTime();
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
maxon::Int32 Int32
Definition: ge_sys_math.h:51
PyFrameObject * frame
Definition: pycore_traceback.h:92
Properties
Set Time
BaseTime objects can be constructed by setting a time in seconds of by giving a frame and a framerate.
CCurve* const curve = track->GetCurve();
if (curve != nullptr)
{
const BaseTime time { 1.0 };
const CKey*
const key = curve->AddKey(time);
}
PyObject * key
Definition: abstract.h:289
CCurve* const curve = track->GetCurve();
if (curve != nullptr)
{
const BaseTime time(25, fps);
const CKey*
const key = curve->AddKey(time);
}
Numerator/Denominator
The internal value of a BaseTime object is represented by a numerator and denominator. Both values can be retrieved and modified using:
- BaseTime::GetNumerator(): Returns the numerator part of the internally stored time.
- BaseTime::SetNumerator(): Sets the numerator part of the internally stored time.
- BaseTime::GetDenominator(): Returns the denominator part of the internally stored time.
- BaseTime::SetDenominator(): Sets the denominator part of the internally stored time.
Compare
Two BaseTime objects can be compared using a special function or the usual operators:
const BaseTime oneSecond { 1.0 };
const BaseTime now =
doc->GetTime();
const Int32 compare = now.TimeDif(oneSecond);
if (compare == -1)
else if (compare == 1)
Disc I/O
BaseTime objects can be stored in a HyperFile using:
- HyperFile::ReadTime(): Reads a BaseTime object from the HyperFile.
- HyperFile::WriteTime(): Writes a BaseTime object into the HyperFile.
See also HyperFile Manual on BaseTime.
Further Reading