AnimationClip.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. // Constructor for runtime use only (dummy parameter to differentiate from the normal constructor)
  17. private AnimationClip(bool dummy)
  18. { }
  19. /// <summary>
  20. /// Creates a new animation clip with no curves or events.
  21. /// </summary>
  22. public AnimationClip()
  23. {
  24. Internal_CreateInstance(this);
  25. }
  26. /// <summary>
  27. /// Returns the length of the animation clip, in seconds.
  28. /// </summary>
  29. public float Length
  30. {
  31. get { return Internal_GetLength(mCachedPtr); }
  32. }
  33. /// <summary>
  34. /// A set of all curves stored in the animation clip.
  35. /// </summary>
  36. public AnimationCurves Curves
  37. {
  38. get { return Internal_GetAnimationCurves(mCachedPtr); }
  39. set { Internal_SetAnimationCurves(mCachedPtr, value); }
  40. }
  41. /// <summary>
  42. /// A set of all events stored in the animation clip.
  43. /// </summary>
  44. public AnimationEvent[] Events
  45. {
  46. get { return Internal_GetAnimationEvents(mCachedPtr); }
  47. set { Internal_SetAnimationEvents(mCachedPtr, value); }
  48. }
  49. [MethodImpl(MethodImplOptions.InternalCall)]
  50. private static extern void Internal_CreateInstance(AnimationClip instance);
  51. [MethodImpl(MethodImplOptions.InternalCall)]
  52. private static extern AnimationCurves Internal_GetAnimationCurves(IntPtr thisPtr);
  53. [MethodImpl(MethodImplOptions.InternalCall)]
  54. private static extern void Internal_SetAnimationCurves(IntPtr thisPtr, AnimationCurves curves);
  55. [MethodImpl(MethodImplOptions.InternalCall)]
  56. private static extern AnimationEvent[] Internal_GetAnimationEvents(IntPtr thisPtr);
  57. [MethodImpl(MethodImplOptions.InternalCall)]
  58. private static extern void Internal_SetAnimationEvents(IntPtr thisPtr, AnimationEvent[] events);
  59. [MethodImpl(MethodImplOptions.InternalCall)]
  60. private static extern float Internal_GetLength(IntPtr thisPtr);
  61. }
  62. /// <summary>
  63. /// Event that is triggered when animation reaches a certain point.
  64. /// </summary>
  65. public class AnimationEvent
  66. {
  67. /// <summary>
  68. /// Constructs a new animation event.
  69. /// </summary>
  70. /// <param name="name">Name used to identify the event when it is triggered.</param>
  71. /// <param name="time">Time at which to trigger the event, in seconds.</param>
  72. public AnimationEvent(string name, float time)
  73. {
  74. Name = name;
  75. Time = time;
  76. }
  77. /// <summary>
  78. /// Name used to identify the event when it is triggered.
  79. /// </summary>
  80. public string Name;
  81. /// <summary>
  82. /// Time at which to trigger the event, in seconds.
  83. /// </summary>
  84. public float Time;
  85. }
  86. /** @} */
  87. }