ModelData.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. using System;
  10. using System.Collections.Generic;
  11. using Microsoft.Xna.Framework;
  12. using Microsoft.Xna.Framework.Content;
  13. namespace CustomModelAnimation
  14. {
  15. /// <summary>
  16. /// Combines all the data needed to render and animate a skinned object.
  17. /// This is typically stored in the Tag property of the Model being animated.
  18. /// </summary>
  19. public class ModelData
  20. {
  21. /// <summary>
  22. /// Gets a collection of animation clips that operate on the root of the object.
  23. /// These are stored by name in a dictionary, so there could for instance be
  24. /// clips for "Walk", "Run", "JumpReallyHigh", etc.
  25. /// </summary>
  26. [ContentSerializer]
  27. public Dictionary<string, ModelAnimationClip> RootAnimationClips { get; private set; }
  28. /// <summary>
  29. /// Gets a collection of model animation clips. These are stored by name in a
  30. /// dictionary, so there could for instance be clips for "Walk", "Run",
  31. /// "JumpReallyHigh", etc.
  32. /// </summary>
  33. [ContentSerializer]
  34. public Dictionary<string, ModelAnimationClip> ModelAnimationClips { get; private set; }
  35. /// <summary>
  36. /// Bindpose matrices for each bone in the skeleton,
  37. /// relative to the parent bone.
  38. /// </summary>
  39. [ContentSerializer]
  40. public List<Matrix> BindPose { get; private set; }
  41. /// <summary>
  42. /// Vertex to bonespace transforms for each bone in the skeleton.
  43. /// </summary>
  44. [ContentSerializer]
  45. public List<Matrix> InverseBindPose { get; private set; }
  46. /// <summary>
  47. /// For each bone in the skeleton, stores the index of the parent bone.
  48. /// </summary>
  49. [ContentSerializer]
  50. public List<int> SkeletonHierarchy { get; private set; }
  51. /// <summary>
  52. /// Constructs a new skinning data object.
  53. /// </summary>
  54. public ModelData(
  55. Dictionary<string, ModelAnimationClip> modelAnimationClips,
  56. Dictionary<string, ModelAnimationClip> rootAnimationClips,
  57. List<Matrix> bindPose,
  58. List<Matrix> inverseBindPose,
  59. List<int> skeletonHierarchy)
  60. {
  61. ModelAnimationClips = modelAnimationClips;
  62. RootAnimationClips = rootAnimationClips;
  63. BindPose = bindPose;
  64. InverseBindPose = inverseBindPose;
  65. SkeletonHierarchy = skeletonHierarchy;
  66. }
  67. /// <summary>
  68. /// Private constructor for use by the XNB deserializer.
  69. /// </summary>
  70. private ModelData()
  71. {
  72. }
  73. }
  74. }