//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using System.Runtime.CompilerServices;
namespace BansheeEngine
{
/** @addtogroup Animation
* @{
*/
///
/// Contains animation curves for translation/rotation/scale of scene object/skeleton bones, as well as curves for
/// generic property animation.
///
public class AnimationClip : Resource
{
// Constructor for runtime use only (dummy parameter to differentiate from the normal constructor)
private AnimationClip(bool dummy)
{ }
///
/// Creates a new animation clip with no curves or events.
///
public AnimationClip()
{
Internal_CreateInstance(this);
}
///
/// Returns the length of the animation clip, in seconds.
///
public float Length
{
get { return Internal_GetLength(mCachedPtr); }
}
///
/// Returns the number of samples per second the animation clip curves were sampled at. This value is not used by
/// the animation clip or curves directly since unevenly spaced keyframes are supported. But it can be of value when
/// determining the original sample rate of an imported animation or similar.
///
public int SampleRate
{
get { return Internal_GetSampleRate(mCachedPtr); }
set { Internal_SetSampleRate(mCachedPtr, value); }
}
///
/// A set of all curves stored in the animation clip.
///
public AnimationCurves Curves
{
get { return Internal_GetAnimationCurves(mCachedPtr); }
set { Internal_SetAnimationCurves(mCachedPtr, value); }
}
///
/// A set of all events stored in the animation clip.
///
public AnimationEvent[] Events
{
get { return Internal_GetAnimationEvents(mCachedPtr); }
set { Internal_SetAnimationEvents(mCachedPtr, value); }
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_CreateInstance(AnimationClip instance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern AnimationCurves Internal_GetAnimationCurves(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetAnimationCurves(IntPtr thisPtr, AnimationCurves curves);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern AnimationEvent[] Internal_GetAnimationEvents(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetAnimationEvents(IntPtr thisPtr, AnimationEvent[] events);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_GetLength(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_GetSampleRate(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetSampleRate(IntPtr thisPtr, int sampleRate);
}
///
/// Event that is triggered when animation reaches a certain point.
///
public class AnimationEvent
{
///
/// Constructs a new animation event.
///
/// Name used to identify the event when it is triggered.
/// Time at which to trigger the event, in seconds.
public AnimationEvent(string name, float time)
{
Name = name;
Time = time;
}
///
/// Name used to identify the event when it is triggered.
///
public string Name;
///
/// Time at which to trigger the event, in seconds.
///
public float Time;
}
/** @} */
}