KS.Reactor.ksCurve Class Reference

Describes a curve defined by keyframes. More...

Classes

struct  Keyframe
 Key frame data use to determine Bezier points. More...
 

Public Types

enum class  WrapModes : byte { First = 0 , Last = 1 , Loop = 2 , PingPong = 3 }
 Affects how the curve is evaluated when the time falls outside the curve duration. More...
 
enum class  EvalModes { Curve , Linear , Constant }
 Affects how the keyframes are used when evaluating a curve. More...
 

Public Member Functions

void Clear ()
 Removes all keyframes from the curve. More...
 
int AddKeyframe (Keyframe keyframe)
 Adds a keyframe to the curve. More...
 
void RemoveKeyframe (int index)
 Removes a keyframe from the curve. More...
 
float Evaluate (float time, EvalModes evalMode=EvalModes.Curve)
 Gets the curve value at a specific time. More...
 

Properties

WrapModes PreWrapMode [get, set]
 Gets/Sets the wrap mode to use when evaluating times before the start of the curve. More...
 
WrapModes PostWrapMode [get, set]
 Gets/Sets the wrap mode to use when evaluating times past the duration of the curve. More...
 
float Duration [get]
 Returns the duration of the curve. Sum of all keyframe times. More...
 
float StartTime [get]
 Gets the time this curve starts. More...
 
float EndTime [get]
 Gets the time this curve ends. More...
 
int KeyFrameCount [get]
 Returns the number of keyframes in the curve. More...
 

Detailed Description

Describes a curve defined by keyframes.

Each key frame contains information to create two points of a cubic Bezier curve. For a given segement between keyframe k0 and k1 the bezier points are defined to be 0, k0.Value), (k0.OutWeight, k0.OutTangent * t * k0.OutWeight + k0.Value), (1 - k1.InWeight, -k1.InTangent * t * k1.InWeight + k0.Value), (1, k1.Value) where t is k1.time - k0.time

Member Enumeration Documentation

◆ EvalModes

Affects how the keyframes are used when evaluating a curve.

Enumerator
Curve 

Evaulate by solving the y component of the bezier curve defined by the key frames.

Linear 

Evaulate using linear interpolation between keyframe values.

Constant 

Evaulate using the value of the keyframe that proceeds the evaluation time.

◆ WrapModes

enum KS.Reactor.ksCurve.WrapModes : byte
strong

Affects how the curve is evaluated when the time falls outside the curve duration.

Enumerator
First 

Return the first keyframe value.

Last 

Return the last keyframe value.

Loop 

Evaluate as if the curve loops.

PingPong 

Evaluate as if the curve loops and alternates direction.

Member Function Documentation

◆ AddKeyframe()

int KS.Reactor.ksCurve.AddKeyframe ( Keyframe  keyframe)

Adds a keyframe to the curve.

Places keyframe at correct position in the keyframe list based on time.

Parameters
keyframeKeyframe.
Returns
Index.

◆ Clear()

void KS.Reactor.ksCurve.Clear ( )

Removes all keyframes from the curve.

◆ Evaluate()

float KS.Reactor.ksCurve.Evaluate ( float  time,
EvalModes  evalMode = EvalModes.Curve 
)

Gets the curve value at a specific time.

Parameters
timeTime.
evalModeEvaluation mode (Default EvalModes.Curve).
Returns
Curve value.

◆ RemoveKeyframe()

void KS.Reactor.ksCurve.RemoveKeyframe ( int  index)

Removes a keyframe from the curve.

Parameters
indexKeyframe index.

Property Documentation

◆ Duration

float KS.Reactor.ksCurve.Duration
get

Returns the duration of the curve. Sum of all keyframe times.

◆ EndTime

float KS.Reactor.ksCurve.EndTime
get

Gets the time this curve ends.

◆ KeyFrameCount

int KS.Reactor.ksCurve.KeyFrameCount
get

Returns the number of keyframes in the curve.

◆ PostWrapMode

WrapModes KS.Reactor.ksCurve.PostWrapMode
getset

Gets/Sets the wrap mode to use when evaluating times past the duration of the curve.

◆ PreWrapMode

WrapModes KS.Reactor.ksCurve.PreWrapMode
getset

Gets/Sets the wrap mode to use when evaluating times before the start of the curve.

◆ StartTime

float KS.Reactor.ksCurve.StartTime
get

Gets the time this curve starts.