BaseTime Class Reference

#include <c4d_basetime.h>

详细描述

Cinema 4D uses a sophisticated system for specifying time values.
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 GetFrame() would return 15 , but if using 24 fps it would return frame 12 .

私有成员函数

void  Reduce (void)

Private Attributes

Float   numerator
Float   denominator

Friends

class  BaseFile
class  AESFile

Constructor/Destructor

  BaseTime ()
  BaseTime ( Float r)
  BaseTime ( Float z, Float n)

Numerator/Denominator

Float   Get (void) const
Float   GetNumerator (void) const
Float   GetDenominator (void) const
void  SetNumerator ( Float r)
void  SetDenominator ( Float r)

Frames

Int32   GetFrame ( Float fps) const
void  Quantize ( Float fps)

Math Operators

const friend BaseTime   operator* (const BaseTime &t1, const BaseTime &t2)
const friend BaseTime   operator/ (const BaseTime &t1, const BaseTime &t2)
const friend BaseTime   operator+ (const BaseTime &t1, const BaseTime &t2)
const friend BaseTime   operator- (const BaseTime &t1, const BaseTime &t2)

Comparison Operators

Bool   operator== (const BaseTime &t1, const BaseTime &t2)
Bool   operator< (const BaseTime &t1, const BaseTime &t2)
Bool   operator!= (const BaseTime &t1, const BaseTime &t2)
Bool   operator<= (const BaseTime &t1, const BaseTime &t2)
Bool   operator>= (const BaseTime &t1, const BaseTime &t2)
Bool   operator> (const BaseTime &t1, const BaseTime &t2)

杂项

Int32   TimeDif (const BaseTime &t2) const

构造函数 & 析构函数文档编制

◆  BaseTime() [1/3]

BaseTime ( )

Default constructor.

◆  BaseTime() [2/3]

BaseTime ( Float   r )
explicit

Initializes the internal time value from a float value in seconds.
Constructor will multiply the seconds by 1000.0 and store it as a fraction with 1000.0 as denominator; after this the fraction will be reduced to its lowest form.

参数
[in] r The time in seconds.

◆  BaseTime() [3/3]

BaseTime ( Float   z ,
Float   n  
)
explicit

Initializes the internal time value to the given fraction of z / n .

参数
[in] z The nominator.
[in] n The denominator.

成员函数文档编制

◆  Reduce()

void Reduce ( void  )
private

◆  Get()

Float Get ( void  ) const

Gets the time in seconds.

返回
The time in seconds.

◆  GetNumerator()

Float GetNumerator ( void  ) const

Gets the numerator part of the internally stored time.

返回
The numerator.

◆  GetDenominator()

Float GetDenominator ( void  ) const

Gets the denominator part of the internally stored time.

返回
The denominator.

◆  SetNumerator()

void SetNumerator ( Float   r )

Sets the numerator part of the internally stored time.

参数
[in] r The numerator.

◆  SetDenominator()

void SetDenominator ( Float   r )

Sets the denominator part of the internally stored time.

参数
[in] r The denominator.

◆  GetFrame()

Int32 GetFrame ( Float   fps ) const

Gets the number of frames equivalent to the time for the given number of Frames per Second.

参数
[in] fps The Frames per Second to use to calculate the frame number for the time.
返回
The frame number for the time.

◆  Quantize()

void Quantize ( Float   fps )

Quantizes the internally stored value so that it is a multiple of the given number of Frames per Second.

参数
[in] fps The number of Frames per Second to make the time a multiple of.

◆  TimeDif()

Int32 TimeDif ( const BaseTime t2 ) const

Check which is the largest between the time and t2 .

参数
[in] t2 The time to compare with.
返回
-1 if the time is < t2 , 0 if they are equal and 1 if the time is > t2 .

Friends And Related Function Documentation

◆  BaseFile

friend class BaseFile
friend

◆  AESFile

friend class AESFile
friend

◆  operator*

const friend BaseTime operator* ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Multiplies t1 and t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the multiplication.

◆  operator/

const friend BaseTime operator/ ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Divides t1 and t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the division.

◆  operator+

const friend BaseTime operator+ ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Adds t1 and t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the addition.

◆  operator-

const friend BaseTime operator- ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Subtracts t1 and t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the subtraction.

◆  operator==

Bool operator== ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Equality operator. Checks if t1 and t2 are equal.

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the comparison.

◆  operator<

Bool operator< ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Less than operator. Checks if t1 is less than t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the comparison.

◆  operator!=

Bool operator!= ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Inequality operator. Checks if t1 and t2 are not equal.

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the comparison.

◆  operator<=

Bool operator<= ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Less than or equal operator. Checks if t1 is less than or equal to t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the comparison.

◆  operator>=

Bool operator>= ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Greater than or equal operator. Checks if t1 is greater than or equal to t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the comparison.

◆  operator>

Bool operator> ( const BaseTime t1 ,
const BaseTime t2  
)
friend

Greater than operator. Checks if t1 大于 t2 .

参数
[in] t1 Left-operand time.
[in] t2 Right-operand time.
返回
Result of the comparison.

Member Data Documentation

◆  numerator

Float numerator
private

◆  denominator

Float denominator
private