2
0

CustomAvatarAnimationData.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // CustomAvatarAnimationData.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;
  11. using System.Collections.Generic;
  12. using Microsoft.Xna.Framework;
  13. using Microsoft.Xna.Framework.Content;
  14. #endregion
  15. namespace CustomAvatarAnimation
  16. {
  17. /// <summary>
  18. /// The type contains the animation data for a single animation
  19. /// </summary>
  20. public class CustomAvatarAnimationData
  21. {
  22. /// <summary>
  23. /// The name of the animation clip
  24. /// </summary>
  25. [ContentSerializer]
  26. public string Name { get; private set; }
  27. /// <summary>
  28. /// The total length of the animation.
  29. /// </summary>
  30. [ContentSerializer]
  31. public TimeSpan Length { get; private set; }
  32. /// <summary>
  33. /// A combined list containing all the keyframes for all bones,
  34. /// sorted by time.
  35. /// </summary>
  36. [ContentSerializer]
  37. public List<AvatarKeyFrame> Keyframes { get; private set; }
  38. /// <summary>
  39. /// A combined list containing all the keyframes for expressions,
  40. /// sorted by time.
  41. /// </summary>
  42. [ContentSerializer]
  43. public List<AvatarExpressionKeyFrame> ExpressionKeyframes { get; private set; }
  44. #region Initialization
  45. /// <summary>
  46. /// Private constructor for use by the XNB deserializer.
  47. /// </summary>
  48. private CustomAvatarAnimationData() { }
  49. /// <summary>
  50. /// Constructs a new CustomAvatarAnimationData object.
  51. /// </summary>
  52. /// <param name="name">The name of the animation.</param>
  53. /// <param name="length">The length of the animation.</param>
  54. /// <param name="keyframes">The keyframes in the animation.</param>
  55. public CustomAvatarAnimationData(string name, TimeSpan length,
  56. List<AvatarKeyFrame> keyframes,
  57. List<AvatarExpressionKeyFrame> expressionKeyframes)
  58. {
  59. // safety-check the parameters
  60. if (String.IsNullOrEmpty(name))
  61. {
  62. throw new ArgumentNullException("name");
  63. }
  64. if (length <= TimeSpan.Zero)
  65. {
  66. throw new ArgumentOutOfRangeException("length",
  67. "The length of the animation cannot be zero.");
  68. }
  69. if ((keyframes == null) || (keyframes.Count <= 0))
  70. {
  71. throw new ArgumentNullException("keyframes");
  72. }
  73. // assign the parameters
  74. Name = name;
  75. Length = length;
  76. Keyframes = keyframes;
  77. ExpressionKeyframes = expressionKeyframes;
  78. }
  79. #endregion
  80. }
  81. }