All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzu_animation_key.h File Reference

Single key frame of animation data. More...

Namespaces

 kanzi
 

Enumerations

enum  KzuAnimationInterpolation { KZU_ANIMATION_INTERPOLATION_STEP, KZU_ANIMATION_INTERPOLATION_LINEAR, KZU_ANIMATION_INTERPOLATION_BEZIER, KZU_ANIMATION_INTERPOLATION_SMOOTHSTEP }
 Used interpolation method for animation key frame. More...
 
enum  KzuAnimationKeyValueSource { KZU_ANIMATION_KEY_VALUE_SOURCE_TIMELINE, KZU_ANIMATION_KEY_VALUE_SOURCE_ANIMATED_OBJECT_CURRENT_VALUE, KZU_ANIMATION_KEY_VALUE_SOURCE_TARGET_OBJECT_CURRENT_VALUE }
 Key frame value source, in additional to regular timeline keyframes the value can be fetch from source/target value. More...
 

Functions

KANZI_API kzsError kzuAnimationKeyFloatCreate (const struct KzcMemoryManager *memoryManager, kzFloat time, kzFloat value, enum KzuAnimationInterpolation interpolation, struct KzuAnimationKeyFloat **out_animationKey)
 Creates animation key. More...
 
KANZI_API kzsError kzuAnimationKeyFloatWithTangentsCreate (const struct KzcMemoryManager *memoryManager, kzFloat time, kzFloat value, enum KzuAnimationInterpolation interpolation, struct KzcVector2 inPoint, struct KzcVector2 outPoint, struct KzuAnimationKeyFloatWithTangents **out_animationKey)
 Creates an animation key, which represents a point on a Bezier curve and up to two Bezier control points. More...
 
KANZI_API KzuAnimationKeyTexturekzuAnimationKeyTextureCreate (const KzcMemoryManager *memoryManager, kzFloat time, kanzi::TextureSharedPtr outputTexture)
 Creates new animation key for texture animation. More...
 
KANZI_API kzsError kzuAnimationKeyMatrix4x4Create (const struct KzcMemoryManager *memoryManager, kzFloat time, const struct KzcMatrix4x4 *outputMatrix, struct KzuAnimationKeyMatrix4x4 **out_animationKeyMatrix)
 Creates animation key for matrix4x4 animation. More...
 
KANZI_API kzsError kzuAnimationKeyDelete (struct KzuAnimationKey *animationKey)
 Deallocates memory reserved for animation key. More...
 
KANZI_API kzFloat kzuAnimationKeyGetTime (const struct KzuAnimationKey *key)
 Gets time from a given KzuAnimationKey. More...
 
KANZI_API KzuAnimationInterpolation kzuAnimationKeyGetInterpolation (const struct KzuAnimationKey *key)
 Gets interpolation type from a given KzuAnimationKey. More...
 
KANZI_API kzFloat kzuAnimationKeyFloatGetValue (const struct KzuAnimationKeyFloat *key)
 Gets output value from a given KzuAnimationFloatKey. More...
 
KANZI_API void kzuAnimationKeyFloatWithTangentsGetTangents (KzuAnimationKeyFloatWithTangents *animationKey, KzcVector2 *out_inPoint, KzcVector2 *out_outPoint)
 Gets tangents from a given KzuAnimationKeyFloatWithTangents. More...
 
KANZI_API void kzuAnimationKeySetValueSource_private (KzuAnimationKey *key, KzuAnimationKeyValueSource source, kanzi::ResourceSharedPtr resource)
 Private function for setting value source for animation key frame. More...
 
KANZI_API enum
KzuAnimationKeyValueSource 
kzuAnimationKeyGetValueSource (const struct KzuAnimationKey *key)
 Gets value source from animation key. More...
 
KANZI_API void kzuAnimationKeyFloatSetValue (struct KzuAnimationKeyFloat *key, kzFloat value)
 Sets value for animation key float. More...
 
KANZI_API kanzi::ResourcekzuAnimationKeyGetValueSourceTargetObject (const struct KzuAnimationKey *key)
 Gets target object from key frame value source. More...
 
KANZI_API kzsError kzuAnimationKeySetTargetObjectPath (struct KzuAnimationKey *key, enum KzuAnimationKeyValueSource source, kzString path)
 Sets target object path. More...
 
KANZI_API kzString kzuAnimationKeyGetTargetObjectPath (const struct KzuAnimationKey *key)
 Sets target object path. More...
 
KANZI_API struct KzuAnimationKeykzuAnimationKeyFloatToAnimationKey (const struct KzuAnimationKeyFloat *key)
 Type casts KzuAnimationKeyFloat to KzuAnimationKey. More...
 
KANZI_API struct
KzuAnimationKeyFloat
kzuAnimationKeyFloatFromAnimationKey (const struct KzuAnimationKey *key)
 Type casts KzuAnimationKeyFloat from KzuAnimationKey. More...
 
KANZI_API struct KzuAnimationKeykzuAnimationKeyFloatWithTangentsToAnimationKey (const struct KzuAnimationKeyFloatWithTangents *key)
 Type casts KzuAnimationKeyFloatWithTangents to KzuAnimationKey. More...
 
KANZI_API struct
KzuAnimationKeyFloatWithTangents
kzuAnimationKeyFloatWithTangentsFromAnimationKey (const struct KzuAnimationKey *key)
 Type casts KzuAnimationKeyFloatWithTangents from KzuAnimationKey. More...
 
KANZI_API struct KzuAnimationKeykzuAnimationKeyTextureToAnimationKey (const struct KzuAnimationKeyTexture *key)
 Type casts KzuAnimationKeyTexture to KzuAnimationKey. More...
 
KANZI_API struct
KzuAnimationKeyTexture
kzuAnimationKeyToAnimationKeyTexture (const struct KzuAnimationKey *key)
 Type casts KzuAnimationKeyTexture from KzuAnimationKey. More...
 
KANZI_API struct KzuAnimationKeykzuAnimationKeyMatrix4x4ToAnimationKey (const struct KzuAnimationKeyMatrix4x4 *key)
 Type casts KzuAnimationKeyMatrix4x4 to KzuAnimationKey. More...
 
KANZI_API struct
KzuAnimationKeyMatrix4x4
kzuAnimationKeyToAnimationKeyMatrix4x4 (const struct KzuAnimationKey *key)
 Type casts KzuAnimationKeyMatrix4x4 from KzuAnimationKey. More...
 
KANZI_API kzFloat kzuAnimationKeyFloatInterpolate (kzFloat input, struct KzuAnimationKeyFloat *keyStart, struct KzuAnimationKeyFloat *keyEnd)
 Returns the output value from given point input, which is located between the two keys. More...
 
KANZI_API void kzuAnimationKeyMatrix4x4Interpolate (kzFloat input, const struct KzuAnimationKeyMatrix4x4 *keyStart, const struct KzuAnimationKeyMatrix4x4 *keyEnd, struct KzcMatrix4x4 *out_matrix)
 Returns the interpolated output value from input point, which is between the given two keys. More...
 
KANZI_API kanzi::TexturekzuAnimationKeyTextureInterpolate (const struct KzuAnimationKeyTexture *keyStart, const struct KzuAnimationKeyTexture *keyEnd)
 Returns the texture from given key frames. More...
 
KANZI_API kzFloat kzuAnimationInterpolateLinear (kzFloat time, kzFloat startValue, kzFloat endValue, kzFloat startTime, kzFloat endTime)
 Returns linearly interpolated value between given two values. More...
 
KANZI_API kzFloat kzuAnimationInterpolateSmoothstep (kzFloat time, kzFloat startValue, kzFloat endValue, kzFloat startTime, kzFloat endTime)
 Returns smoothstep interpolated value between given two values. More...
 
KANZI_API kzFloat kzuAnimationInterpolateBezier (kzFloat time, kzFloat startValue, kzFloat endValue, kzFloat startTime, kzFloat endTime, const struct KzcVector2 *outTangent, const struct KzcVector2 *inTangent)
 Returns cubic Bezier interpolated value from given values. More...
 
KANZI_API kzFloat kzuAnimationInterpolateHermite (kzFloat time, kzFloat startValue, kzFloat endValue, kzFloat startTime, kzFloat endTime, const struct KzcVector2 *outTangent, const struct KzcVector2 *inTangent)
 Returns hermite interpolated value from given values. More...
 
KANZI_API kzFloat kzuAnimationKeyBezierGetValue (kzFloat phase, kzFloat startValue, kzFloat controlValue1, kzFloat controlValue2, kzFloat endValue)
 Returns value of bezier for given phase value (in [0, 1]) and given control points. More...
 
KANZI_API kzFloat kzuAnimationApproximateCubicBezierParameter (kzFloat time, kzFloat p0, kzFloat c0, kzFloat c1, kzFloat p1)
 Returns Bezier parameter 's' for which time of 'Bezier(s)' is 'time'. More...
 

Detailed Description

Single key frame of animation data.

Copyright 2008-2020 by Rightware. All rights reserved.

Enumeration Type Documentation

Used interpolation method for animation key frame.

Enumerator
KZU_ANIMATION_INTERPOLATION_STEP 

Interpolation step.

KZU_ANIMATION_INTERPOLATION_LINEAR 

Interpolation linear.

KZU_ANIMATION_INTERPOLATION_BEZIER 

Interpolation Bezier.

KZU_ANIMATION_INTERPOLATION_SMOOTHSTEP 

Interpolation smoothstep.

Key frame value source, in additional to regular timeline keyframes the value can be fetch from source/target value.

Enumerator
KZU_ANIMATION_KEY_VALUE_SOURCE_TIMELINE 

Key frame value fetch from timeline.

KZU_ANIMATION_KEY_VALUE_SOURCE_ANIMATED_OBJECT_CURRENT_VALUE 

Key frame value fetch from animated object current value.

KZU_ANIMATION_KEY_VALUE_SOURCE_TARGET_OBJECT_CURRENT_VALUE 

Key frame value fetch from target object current value.

Function Documentation

KANZI_API kzsError kzuAnimationKeyFloatCreate ( const struct KzcMemoryManager memoryManager,
kzFloat  time,
kzFloat  value,
enum KzuAnimationInterpolation  interpolation,
struct KzuAnimationKeyFloat **  out_animationKey 
)

Creates animation key.

Parameters
memoryManagerThe memory manager to use.
timeThe time when the animation has value 'value'.
valueThe value the animation has at time 'time'.
interpolationThis must be KZU_ANIMATION_INTERPOLATION_STEP, KZU_ANIMATION_INTERPOLATION_LINEAR or KZU_ANIMATION_INTERPOLATION_SMOOTHSTEP.
out_animationKeyA pointer that is set to point to the new animation key.
Returns
KZS_SUCCESS on success.
KANZI_API kzsError kzuAnimationKeyFloatWithTangentsCreate ( const struct KzcMemoryManager memoryManager,
kzFloat  time,
kzFloat  value,
enum KzuAnimationInterpolation  interpolation,
struct KzcVector2  inPoint,
struct KzcVector2  outPoint,
struct KzuAnimationKeyFloatWithTangents **  out_animationKey 
)

Creates an animation key, which represents a point on a Bezier curve and up to two Bezier control points.

The Bezier curve will go through the point (time, value). The 'inPoint' parameter defines a Bezier control point in case the animation key before 'time' also defines a Bezier point. Similarly, the 'outPoint' is used as an additional Bezier control point if there is a Bezier animation key after 'time'.

For example, if there are two Bezier animation keys A and B and A's 'time' (A_time) is smaller than B's 'time' (B_time), then A and B together define a cubic Bezier curve which starting point is (A_time, A_value), the first control point is (A_outPoint.data[0], A_outPoint.data[1]), the second control point is (B_inPoint.data[0], B_inPoint.data[1]) and the end point is (B_time, B_value). Now, if there is a third Bezier animation key C and C_time > B_time, then there would be another cubic Bezier curve defined by (B_time, B_value), (B_outPoint.data[0], B_outPoint.data[1]), (C_inPoint.data[0], C_inPoint.data[1]), and (C_time, C_value).

If the animation key before 'time' is not of Bezier type, the animation value will transition linearly from that point to (time, value). Similarly, if the animation key after 'time' is not of Bezier type, the animation value will transition linearly from (time, value) to that point.

Parameters
memoryManagerThe memory manager to use.
timeThe time when the curve has value 'value'.
valueThe value the curve has at time 'time'.
interpolationThis must be KZU_ANIMATION_INTERPOLATION_BEZIER.
inPointA Bezier control point that is used in case there is a Bezier animation key before 'time'.
outPointA Bezier control point that is used in case there is a Bezier animation key after 'time'.
out_animationKeyA pointer that is set to point to the new animation key.
Returns
KZS_SUCCESS on success.
KANZI_API KzuAnimationKeyTexture* kzuAnimationKeyTextureCreate ( const KzcMemoryManager memoryManager,
kzFloat  time,
kanzi::TextureSharedPtr  outputTexture 
)

Creates new animation key for texture animation.

KANZI_API kzsError kzuAnimationKeyMatrix4x4Create ( const struct KzcMemoryManager memoryManager,
kzFloat  time,
const struct KzcMatrix4x4 outputMatrix,
struct KzuAnimationKeyMatrix4x4 **  out_animationKeyMatrix 
)

Creates animation key for matrix4x4 animation.

KANZI_API kzsError kzuAnimationKeyDelete ( struct KzuAnimationKey animationKey)

Deallocates memory reserved for animation key.

KANZI_API kzFloat kzuAnimationKeyGetTime ( const struct KzuAnimationKey key)

Gets time from a given KzuAnimationKey.

KANZI_API KzuAnimationInterpolation kzuAnimationKeyGetInterpolation ( const struct KzuAnimationKey key)

Gets interpolation type from a given KzuAnimationKey.

KANZI_API kzFloat kzuAnimationKeyFloatGetValue ( const struct KzuAnimationKeyFloat key)

Gets output value from a given KzuAnimationFloatKey.

KANZI_API void kzuAnimationKeyFloatWithTangentsGetTangents ( KzuAnimationKeyFloatWithTangents animationKey,
KzcVector2 out_inPoint,
KzcVector2 out_outPoint 
)

Gets tangents from a given KzuAnimationKeyFloatWithTangents.

KANZI_API void kzuAnimationKeySetValueSource_private ( KzuAnimationKey key,
KzuAnimationKeyValueSource  source,
kanzi::ResourceSharedPtr  resource 
)

Private function for setting value source for animation key frame.

KANZI_API enum KzuAnimationKeyValueSource kzuAnimationKeyGetValueSource ( const struct KzuAnimationKey key)

Gets value source from animation key.

KANZI_API void kzuAnimationKeyFloatSetValue ( struct KzuAnimationKeyFloat key,
kzFloat  value 
)

Sets value for animation key float.

KANZI_API kanzi::Resource* kzuAnimationKeyGetValueSourceTargetObject ( const struct KzuAnimationKey key)

Gets target object from key frame value source.

KANZI_API kzsError kzuAnimationKeySetTargetObjectPath ( struct KzuAnimationKey key,
enum KzuAnimationKeyValueSource  source,
kzString  path 
)

Sets target object path.

KANZI_API kzString kzuAnimationKeyGetTargetObjectPath ( const struct KzuAnimationKey key)

Sets target object path.

KANZI_API struct KzuAnimationKey* kzuAnimationKeyFloatToAnimationKey ( const struct KzuAnimationKeyFloat key)
KANZI_API struct KzuAnimationKeyFloat* kzuAnimationKeyFloatFromAnimationKey ( const struct KzuAnimationKey key)
KANZI_API struct KzuAnimationKey* kzuAnimationKeyFloatWithTangentsToAnimationKey ( const struct KzuAnimationKeyFloatWithTangents key)
KANZI_API struct KzuAnimationKeyFloatWithTangents* kzuAnimationKeyFloatWithTangentsFromAnimationKey ( const struct KzuAnimationKey key)
KANZI_API struct KzuAnimationKey* kzuAnimationKeyTextureToAnimationKey ( const struct KzuAnimationKeyTexture key)
KANZI_API struct KzuAnimationKeyTexture* kzuAnimationKeyToAnimationKeyTexture ( const struct KzuAnimationKey key)
KANZI_API struct KzuAnimationKey* kzuAnimationKeyMatrix4x4ToAnimationKey ( const struct KzuAnimationKeyMatrix4x4 key)
KANZI_API struct KzuAnimationKeyMatrix4x4* kzuAnimationKeyToAnimationKeyMatrix4x4 ( const struct KzuAnimationKey key)
KANZI_API kzFloat kzuAnimationKeyFloatInterpolate ( kzFloat  input,
struct KzuAnimationKeyFloat keyStart,
struct KzuAnimationKeyFloat keyEnd 
)

Returns the output value from given point input, which is located between the two keys.

KANZI_API void kzuAnimationKeyMatrix4x4Interpolate ( kzFloat  input,
const struct KzuAnimationKeyMatrix4x4 keyStart,
const struct KzuAnimationKeyMatrix4x4 keyEnd,
struct KzcMatrix4x4 out_matrix 
)

Returns the interpolated output value from input point, which is between the given two keys.

KANZI_API kanzi::Texture* kzuAnimationKeyTextureInterpolate ( const struct KzuAnimationKeyTexture keyStart,
const struct KzuAnimationKeyTexture keyEnd 
)

Returns the texture from given key frames.

The interpolation is made with step interpolation.

KANZI_API kzFloat kzuAnimationInterpolateLinear ( kzFloat  time,
kzFloat  startValue,
kzFloat  endValue,
kzFloat  startTime,
kzFloat  endTime 
)

Returns linearly interpolated value between given two values.

KANZI_API kzFloat kzuAnimationInterpolateSmoothstep ( kzFloat  time,
kzFloat  startValue,
kzFloat  endValue,
kzFloat  startTime,
kzFloat  endTime 
)

Returns smoothstep interpolated value between given two values.

KANZI_API kzFloat kzuAnimationInterpolateBezier ( kzFloat  time,
kzFloat  startValue,
kzFloat  endValue,
kzFloat  startTime,
kzFloat  endTime,
const struct KzcVector2 outTangent,
const struct KzcVector2 inTangent 
)

Returns cubic Bezier interpolated value from given values.

KANZI_API kzFloat kzuAnimationInterpolateHermite ( kzFloat  time,
kzFloat  startValue,
kzFloat  endValue,
kzFloat  startTime,
kzFloat  endTime,
const struct KzcVector2 outTangent,
const struct KzcVector2 inTangent 
)

Returns hermite interpolated value from given values.

KANZI_API kzFloat kzuAnimationKeyBezierGetValue ( kzFloat  phase,
kzFloat  startValue,
kzFloat  controlValue1,
kzFloat  controlValue2,
kzFloat  endValue 
)

Returns value of bezier for given phase value (in [0, 1]) and given control points.

KANZI_API kzFloat kzuAnimationApproximateCubicBezierParameter ( kzFloat  time,
kzFloat  p0,
kzFloat  c0,
kzFloat  c1,
kzFloat  p1 
)

Returns Bezier parameter 's' for which time of 'Bezier(s)' is 'time'.