SkinningData.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // SkinningData.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System.Collections.Generic;
  11. using Microsoft.Xna.Framework;
  12. using Microsoft.Xna.Framework.Content;
  13. #endregion
  14. namespace SkinnedModel
  15. {
  16. /// <summary>
  17. /// Combines all the data needed to render and animate a skinned object.
  18. /// This is typically stored in the Tag property of the Model being animated.
  19. /// </summary>
  20. public class SkinningData
  21. {
  22. /// <summary>
  23. /// Constructs a new skinning data object.
  24. /// </summary>
  25. public SkinningData(Dictionary<string, AnimationClip> animationClips,
  26. List<Matrix> bindPose, List<Matrix> inverseBindPose,
  27. List<int> skeletonHierarchy,
  28. Dictionary<string, int> boneIndices)
  29. {
  30. AnimationClips = animationClips;
  31. BindPose = bindPose;
  32. InverseBindPose = inverseBindPose;
  33. SkeletonHierarchy = skeletonHierarchy;
  34. BoneIndices = boneIndices;
  35. }
  36. /// <summary>
  37. /// Private constructor for use by the XNB deserializer.
  38. /// </summary>
  39. private SkinningData()
  40. {
  41. }
  42. /// <summary>
  43. /// Gets a collection of animation clips. These are stored by name in a
  44. /// dictionary, so there could for instance be clips for "Walk", "Run",
  45. /// "JumpReallyHigh", etc.
  46. /// </summary>
  47. [ContentSerializer]
  48. public Dictionary<string, AnimationClip> AnimationClips { get; private set; }
  49. /// <summary>
  50. /// Bindpose matrices for each bone in the skeleton,
  51. /// relative to the parent bone.
  52. /// </summary>
  53. [ContentSerializer]
  54. public List<Matrix> BindPose { get; private set; }
  55. /// <summary>
  56. /// Vertex to bonespace transforms for each bone in the skeleton.
  57. /// </summary>
  58. [ContentSerializer]
  59. public List<Matrix> InverseBindPose { get; private set; }
  60. /// <summary>
  61. /// For each bone in the skeleton, stores the index of the parent bone.
  62. /// </summary>
  63. [ContentSerializer]
  64. public List<int> SkeletonHierarchy { get; private set; }
  65. /// <summary>
  66. /// Dictionary mapping bone names to their indices in the preceding lists.
  67. /// </summary>
  68. [ContentSerializer]
  69. public Dictionary<string, int> BoneIndices { get; private set; }
  70. }
  71. }