using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace BansheeEngine
{
/** @addtogroup Animation
* @{
*/
///
/// Handles animation playback. Takes one or multiple animation clips as input and evaluates them every animation update
/// tick depending on set properties. The evaluated data is used by the core thread for skeletal animation, by the sim
/// thread for updating attached scene objects and bones (if skeleton is attached), or the data is made available for
/// manual queries in the case of generic animation.
///
public partial class Animation : Component
{
private Animation(bool __dummy0) { }
protected Animation() { }
///
/// Determines the default clip to play as soon as the component is enabled. If more control over playing clips is needed
/// use the play(), blend() and crossFade() methods to queue clips for playback manually, and setState() method for
/// modify their states individually.
///
[ShowInInspector]
public AnimationClip DefaultClip
{
get { return Internal_getDefaultClip(mCachedPtr); }
set { Internal_setDefaultClip(mCachedPtr, value); }
}
///
/// Determines the wrap mode for all active animations. Wrap mode determines what happens when animation reaches the
/// first or last frame.
///
[ShowInInspector]
public AnimWrapMode WrapMode
{
get { return Internal_getWrapMode(mCachedPtr); }
set { Internal_setWrapMode(mCachedPtr, value); }
}
///
/// Determines the speed for all animations. The default value is 1.0f. Use negative values to play-back in reverse.
///
[ShowInInspector]
public float Speed
{
get { return Internal_getSpeed(mCachedPtr); }
set { Internal_setSpeed(mCachedPtr, value); }
}
/// Checks if any animation clips are currently playing.
[ShowInInspector]
public bool IsPlaying
{
get { return Internal_isPlaying(mCachedPtr); }
}
///
/// Determines bounds that will be used for animation and mesh culling. Only relevant if setUseBounds() is set to true.
///
[ShowInInspector]
public AABox Bounds
{
get
{
AABox temp;
Internal_getBounds(mCachedPtr, out temp);
return temp;
}
set { Internal_setBounds(mCachedPtr, ref value); }
}
///
/// Determines should animation bounds be used for visibility determination (culling). If false the bounds of the mesh
/// attached to the relevant CRenderable component will be used instead.
///
[ShowInInspector]
public bool UseBounds
{
get { return Internal_getUseBounds(mCachedPtr); }
set { Internal_setUseBounds(mCachedPtr, value); }
}
///
/// Enables or disables culling of the animation when out of view. Culled animation will not be evaluated.
///
[ShowInInspector]
public bool Cull
{
get { return Internal_getEnableCull(mCachedPtr); }
set { Internal_setEnableCull(mCachedPtr, value); }
}
///
/// Triggered when the list of properties animated via generic animation curves needs to be recreated (script only).
///
partial void RebuildFloatProperties(AnimationClip p0);
///
/// Triggered when generic animation curves values need be applied to the properties they effect (script only).
///
partial void _UpdateFloatProperties();
/// Triggers a callback in script code when animation event is triggered (script only).
partial void EventTriggered(AnimationClip p0, string p1);
/// Plays the specified animation clip.
/// Clip to play.
public void Play(AnimationClip clip)
{
Internal_play(mCachedPtr, clip);
}
///
/// Plays the specified animation clip on top of the animation currently playing in the main layer. Multiple such clips
/// can be playing at once, as long as you ensure each is given its own layer. Each animation can also have a weight that
/// determines how much it influences the main animation.
///
/// Clip to additively blend. Must contain additive animation curves.
///
/// Determines how much of an effect will the blended animation have on the final output. In range [0, 1].
///
///
/// Applies the blend over a specified time period, increasing the weight as the time passes. Set to zero to blend
/// immediately. In seconds.
///
///
/// Layer to play the clip in. Multiple additive clips can be playing at once in separate layers and each layer has its
/// own weight.
///
public void BlendAdditive(AnimationClip clip, float weight, float fadeLength = 0f, uint layer = 0)
{
Internal_blendAdditive(mCachedPtr, clip, weight, fadeLength, layer);
}
///
/// Blend multiple animation clips between each other using linear interpolation. Unlike normal animations these
/// animations are not advanced with the progress of time, and is instead expected the user manually changes the
/// parameter.
///
///
/// Information about the clips to blend. Clip positions must be sorted from lowest to highest.
///
///
/// Parameter that controls the blending. Range depends on the positions of the provided animation clips.
///
public void Blend1D(Blend1DInfo info, float t)
{
Internal_blend1D(mCachedPtr, ref info, t);
}
///
/// Blend four animation clips between each other using bilinear interpolation. Unlike normal animations these animations
/// are not advanced with the progress of time, and is instead expected the user manually changes the parameter.
///
/// Information about the clips to blend.
///
/// Parameter that controls the blending, in range [(0, 0), (1, 1)]. t = (0, 0) means top left animation has full
/// influence, t = (1, 0) means top right animation has full influence, t = (0, 1) means bottom left animation has full
/// influence, t = (1, 1) means bottom right animation has full influence.
///
public void Blend2D(Blend2DInfo info, Vector2 t)
{
Internal_blend2D(mCachedPtr, ref info, ref t);
}
///
/// Fades the specified animation clip in, while fading other playing animation out, over the specified time period.
///
/// Clip to fade in.
/// Determines the time period over which the fade occurs. In seconds.
public void CrossFade(AnimationClip clip, float fadeLength)
{
Internal_crossFade(mCachedPtr, clip, fadeLength);
}
///
/// Samples an animation clip at the specified time, displaying only that particular frame without further playback.
///
/// Animation clip to sample.
/// Time to sample the clip at.
public void Sample(AnimationClip clip, float time)
{
Internal_sample(mCachedPtr, clip, time);
}
///
/// Stops playing all animations on the provided layer. Specify -1 to stop animation on the main layer (non-additive
/// animations).
///
public void Stop(uint layer)
{
Internal_stop(mCachedPtr, layer);
}
/// Stops playing all animations.
public void StopAll()
{
Internal_stopAll(mCachedPtr);
}
/// Retrieves detailed information about a currently playing animation clip.
/// Clip to retrieve the information for.
///
/// Animation clip state containing the requested information. Only valid if the method returns true.
///
/// True if the state was found (animation clip is playing), false otherwise.
public bool GetState(AnimationClip clip, out AnimationClipState state)
{
return Internal_getState(mCachedPtr, clip, out state);
}
///
/// Changes the state of a playing animation clip. If animation clip is not currently playing the playback is started for
/// the clip.
///
/// Clip to change the state for.
/// New state of the animation (e.g. changing the time for seeking).
public void SetState(AnimationClip clip, AnimationClipState state)
{
Internal_setState(mCachedPtr, clip, ref state);
}
///
/// Changes a weight of a single morph channel, determining how much of it to apply on top of the base mesh.
///
///
/// Name of the morph channel to modify. This depends on the mesh the animation is currently animating.
///
/// Weight that determines how much of the channel to apply to the mesh, in range [0, 1].
public void SetMorphChannelWeight(string name, float weight)
{
Internal_setMorphChannelWeight(mCachedPtr, name, weight);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setDefaultClip(IntPtr thisPtr, AnimationClip clip);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern AnimationClip Internal_getDefaultClip(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setWrapMode(IntPtr thisPtr, AnimWrapMode wrapMode);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern AnimWrapMode Internal_getWrapMode(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setSpeed(IntPtr thisPtr, float speed);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getSpeed(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_play(IntPtr thisPtr, AnimationClip clip);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_blendAdditive(IntPtr thisPtr, AnimationClip clip, float weight, float fadeLength, uint layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_blend1D(IntPtr thisPtr, ref Blend1DInfo info, float t);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_blend2D(IntPtr thisPtr, ref Blend2DInfo info, ref Vector2 t);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_crossFade(IntPtr thisPtr, AnimationClip clip, float fadeLength);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_sample(IntPtr thisPtr, AnimationClip clip, float time);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_stop(IntPtr thisPtr, uint layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_stopAll(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_isPlaying(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_getState(IntPtr thisPtr, AnimationClip clip, out AnimationClipState state);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setState(IntPtr thisPtr, AnimationClip clip, ref AnimationClipState state);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setMorphChannelWeight(IntPtr thisPtr, string name, float weight);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setBounds(IntPtr thisPtr, ref AABox bounds);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getBounds(IntPtr thisPtr, out AABox __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setUseBounds(IntPtr thisPtr, bool enable);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_getUseBounds(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setEnableCull(IntPtr thisPtr, bool enable);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_getEnableCull(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern uint Internal_getNumClips(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern AnimationClip Internal_getClip(IntPtr thisPtr, uint idx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal__refreshClipMappings(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal__getGenericCurveValue(IntPtr thisPtr, uint curveIdx, out float value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal__togglePreviewMode(IntPtr thisPtr, bool enabled);
private void Internal__scriptRebuildFloatProperties(AnimationClip p0)
{
RebuildFloatProperties(p0);
}
private void Internal__scriptUpdateFloatProperties()
{
_UpdateFloatProperties();
}
private void Internal__scriptOnEventTriggered(AnimationClip p0, string p1)
{
EventTriggered(p0, p1);
}
}
/** @} */
}