AnimationClip.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Animation
  8. * @{
  9. */
  10. /// <summary>
  11. /// Contains animation curves for translation/rotation/scale of scene object/skeleton bones, as well as curves for
  12. /// generic property animation.
  13. /// </summary>
  14. public class AnimationClip : Resource
  15. {
  16. /// <summary>
  17. /// Returns the length of the animation clip, in seconds.
  18. /// </summary>
  19. public float Length
  20. {
  21. get { return Internal_GetLength(mCachedPtr); }
  22. }
  23. /// <summary>
  24. /// A set of all curves stored in the animation clip.
  25. /// </summary>
  26. public AnimationCurves Curves
  27. {
  28. get { return Internal_GetAnimationCurves(mCachedPtr); }
  29. set { Internal_SetAnimationCurves(mCachedPtr, value); }
  30. }
  31. /// <summary>
  32. /// A set of all events stored in the animation clip.
  33. /// </summary>
  34. public AnimationEvent[] Events
  35. {
  36. get { return Internal_GetAnimationEvents(mCachedPtr); }
  37. set { Internal_SetAnimationEvents(mCachedPtr, value); }
  38. }
  39. /// <summary>
  40. /// Constructor for internal use by the runtime.
  41. /// </summary>
  42. private AnimationClip()
  43. { }
  44. [MethodImpl(MethodImplOptions.InternalCall)]
  45. private static extern AnimationCurves Internal_GetAnimationCurves(IntPtr thisPtr);
  46. [MethodImpl(MethodImplOptions.InternalCall)]
  47. private static extern void Internal_SetAnimationCurves(IntPtr thisPtr, AnimationCurves curves);
  48. [MethodImpl(MethodImplOptions.InternalCall)]
  49. private static extern AnimationEvent[] Internal_GetAnimationEvents(IntPtr thisPtr);
  50. [MethodImpl(MethodImplOptions.InternalCall)]
  51. private static extern void Internal_SetAnimationEvents(IntPtr thisPtr, AnimationEvent[] events);
  52. [MethodImpl(MethodImplOptions.InternalCall)]
  53. private static extern float Internal_GetLength(IntPtr thisPtr);
  54. }
  55. /// <summary>
  56. /// Event that is triggered when animation reaches a certain point.
  57. /// </summary>
  58. public class AnimationEvent
  59. {
  60. /// <summary>
  61. /// Constructs a new animation event.
  62. /// </summary>
  63. /// <param name="name">Name used to identify the event when it is triggered.</param>
  64. /// <param name="time">Time at which to trigger the event, in seconds.</param>
  65. public AnimationEvent(string name, float time)
  66. {
  67. Name = name;
  68. Time = time;
  69. }
  70. /// <summary>
  71. /// Name used to identify the event when it is triggered.
  72. /// </summary>
  73. public string Name;
  74. /// <summary>
  75. /// Time at which to trigger the event, in seconds.
  76. /// </summary>
  77. public float Time;
  78. }
  79. /** @} */
  80. }