CCurve Manual

内容表

关于

A CCurve represents an animation curve that stores and interpolates animation keys. A CCurve is stored in a CTrack 对象。

CCurve objects are an instance of CSbase .

// This code loops through all tracks and all keys of the given object.
CTrack * track = activeObject-> GetFirstCTrack ();
while (track != nullptr ) { CCurve * const curve = track-> GetCurve (); if (curve == nullptr ) continue ; const Int32 keyCount = curve-> GetKeyCount (); for ( Int32 i = 0; i < keyCount; ++i) { CKey * const key = curve-> GetKey (i); if (key) { // do something with the key ApplicationOutput ( "Found a key!" ); } } track = track-> GetNext (); }

Access

CCurve objects cannot be created on their own. They are created with a CTrack that contains the CCurve 对象。

Access Keys

The CCurve objects stores the animation keys and provides access to these:

// This example searches for a key left from the given time. const BaseTime time = doc-> GetTime (); CKey * const leftKey = curve-> FindKey (time, nullptr , FINDANIM::LEFT ); if (leftKey) { // move this key to the current time leftKey-> SetTime (curve, time); }

Add Keys

A CCurve object can create and receive keys:

// This example creates keys along the timeline. const Int32 fps = doc-> GetFps (); const Int32 min = doc-> GetMinTime (). GetFrame (fps); const Int32 max = doc-> GetMaxTime (). GetFrame (fps); const Int32 range = max - min; const Int32 step = range / 10; const BaseTime stepTime = BaseTime (step, fps); BaseTime keyTime = doc-> GetMinTime (); for ( Int32 i = 0; i <= 10; ++i) { if (curve-> AddKey (keyTime, nullptr ) == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); keyTime = keyTime + stepTime; }

另请参阅 CKey Allocation/Deallocation .

Handle Keys

A CCurve object can be used to manipulate its keys:

// This example creates a new key and sets the default values. Int32 index; CKey * const newKey = curve-> AddKey (time, &index); if (newKey == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); track-> FillKey (doc, obj, newKey); curve-> SetKeyDefault (doc, index);

Unmuted Keys

A key can be muted so it is ignored.

// This example searches for the first unmuted key. const CKey * const key = curve-> FindNextUnmuted (0); if (key) { const Float time = key-> GetTime (). Get (); ApplicationOutput ( "Found unmuted key at " + String::FloatToString (time)); }

另请参阅 CKey Bits .

动画

The interpolation between the keys defines the dynamics of an animation. This interpolation is refined with the tangents.

// This example samples the curve. BaseTime time(0.0); const BaseTime step(0.1); for ( Int32 i = 0; i < 10; ++i) { const Float value = curve-> GetValue (time); ApplicationOutput ( "Value: " + String::FloatToString (value)); time = time + step; }

时间

A CCurve is confined by a first and a last key:

// This example sets the loop time dimensions based on the start // and end time of the given curve. const BaseTime start = curve-> GetStartTime (); const BaseTime end = curve-> GetEndTime (); doc-> SetLoopMinTime (start); doc-> SetLoopMaxTime ( end );

延伸阅读

String::FloatToString
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
定义: c4d_string.h:529
CCurve::GetStartTime
BaseTime GetStartTime(void) const
定义: c4d_canimation.h:550
CKey::SetTime
void SetTime(CCurve *seq, const BaseTime &t)
定义: c4d_canimation.h:96
BaseTime
定义: c4d_basetime.h:24
maxon::end
MAXON_ATTRIBUTE_FORCE_INLINE auto end(COLLECTION &&c) -> decltype(c.End())
定义: foreach.h:360
BaseDocument::GetFps
Int32 GetFps(void) const
CCurve::FindNextUnmuted
const CKey * FindNextUnmuted(Int32 idx, Int32 *ret_idx=nullptr) const
定义: c4d_canimation.h:569
CCurve::GetKey
const CKey * GetKey(Int32 index) const
定义: c4d_canimation.h:377
Float
maxon::Float Float
定义: ge_sys_math.h:64
CCurve
定义: c4d_canimation.h:354
BaseTime::GetFrame
Int32 GetFrame(Float fps) const
定义: c4d_basetime.h:107
CCurve::GetEndTime
BaseTime GetEndTime(void) const
定义: c4d_canimation.h:556
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
CCurve::AddKey
CKey * AddKey(const BaseTime &time, Int32 *nidx=nullptr, Bool bUndo=false, Bool SynchronizeKeys=false)
定义: c4d_canimation.h:412
CTrack
定义: c4d_canimation.h:640
BaseDocument::SetLoopMaxTime
void SetLoopMaxTime(const BaseTime &t)
FINDANIM::LEFT
@ LEFT
Search left.
CTrack::FillKey
Bool FillKey(BaseDocument *doc, BaseList2D *bl, CKey *key)
定义: c4d_canimation.h:791
BaseTime::Get
Float Get(void) const
定义: c4d_basetime.h:66
CTrack::GetNext
CTrack * GetNext() const
定义: c4d_canimation.h:686
BaseDocument::GetTime
BaseTime GetTime(void) const
BaseDocument::GetMinTime
BaseTime GetMinTime(void)
BaseDocument::SetLoopMinTime
void SetLoopMinTime(const BaseTime &t)
CCurve::GetValue
Float GetValue(const BaseTime &time) const
定义: c4d_canimation.h:508
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
CKey
定义: c4d_canimation.h:57
CKey::GetTime
BaseTime GetTime(void) const
定义: c4d_canimation.h:89
CCurve::SetKeyDefault
void SetKeyDefault(BaseDocument *doc, Int32 kidx)
CTrack::GetCurve
CCurve * GetCurve(CCURVE type=CCURVE::CURVE, Bool bCreate=true)
定义: c4d_canimation.h:805
CCurve::FindKey
const CKey * FindKey(const BaseTime &time, Int32 *idx=nullptr, FINDANIM match=FINDANIM::EXACT) const
定义: c4d_canimation.h:393
BaseList2D::GetFirstCTrack
CTrack * GetFirstCTrack()
BaseDocument::GetMaxTime
BaseTime GetMaxTime(void)
CCurve::GetKeyCount
Int32 GetKeyCount(void) const
定义: c4d_canimation.h:370

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1