Skeleton.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 information about bones required for skeletal animation.
  12. /// </summary>
  13. public class Skeleton : ScriptObject
  14. {
  15. /// <summary>
  16. /// Constructor for internal runtime use only.
  17. /// </summary>
  18. private Skeleton()
  19. { }
  20. /// <summary>
  21. /// Returns the total number of bones in the skeleton.
  22. /// </summary>
  23. /// <returns>Number of bones.</returns>
  24. public int NumBones
  25. {
  26. get { return Internal_GetNumBones(mCachedPtr); }
  27. }
  28. /// <summary>
  29. /// Returns information about a bone at the provided index.
  30. /// </summary>
  31. /// <param name="boneIdx">Index of the bone to retrieve information for.</param>
  32. /// <returns>Information about the bone, or null if index was out of range.</returns>
  33. public BoneInfo GetBoneInfo(int boneIdx)
  34. {
  35. return Internal_GetBoneInfo(mCachedPtr, boneIdx);
  36. }
  37. [MethodImpl(MethodImplOptions.InternalCall)]
  38. private static extern int Internal_GetNumBones(IntPtr thisPtr);
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern BoneInfo Internal_GetBoneInfo(IntPtr thisPtr, int boneIdx);
  41. }
  42. /// <summary>
  43. /// Contains internal information about a single bone in a <see cref="Skeleton"/>.
  44. /// </summary>
  45. public class BoneInfo
  46. {
  47. /// <summary>
  48. /// Unique name of the bone.
  49. /// </summary>
  50. public string Name;
  51. /// <summary>
  52. /// Index of the parent bone (within the relevant <see cref="Skeleton"/> object). -1 if root bone.
  53. /// </summary>
  54. public int Parent;
  55. /// <summary>
  56. /// Inverse transform of the pose the skeleton was initially created in.
  57. /// </summary>
  58. public Matrix4 InvBindPose;
  59. }
  60. /** @} */
  61. }