GameResourceModel.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // GameResourceModel.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 System.Text;
  13. using Microsoft.Xna.Framework;
  14. using Microsoft.Xna.Framework.Graphics;
  15. #endregion
  16. namespace RobotGameData.Resource
  17. {
  18. /// <summary>
  19. /// saves the transform matrix of the read-in model class and the bones of
  20. /// the model’s initial state.
  21. /// </summary>
  22. public class ModelData
  23. {
  24. public Model model = null;
  25. public Matrix[] boneTransforms = null;
  26. }
  27. /// <summary>
  28. /// a resource element structure with Model class.
  29. /// When a model(.FBX or .X) file is loaded from the resource manager,
  30. /// it gets stored here.
  31. /// </summary>
  32. public class GameResourceModel : GameResourceBase
  33. {
  34. #region Fields
  35. ModelData modelData = new ModelData();
  36. #endregion
  37. #region Properties
  38. public ModelData ModelData
  39. {
  40. get { return modelData; }
  41. }
  42. #endregion
  43. /// <summary>
  44. /// Constructor.
  45. /// </summary>
  46. /// <param name="key">key name</param>
  47. /// <param name="assetName">asset name</param>
  48. /// <param name="resource">model resource</param>
  49. public GameResourceModel(string key, string assetName, Model resource)
  50. : base(key, assetName)
  51. {
  52. this.modelData.model = resource;
  53. this.modelData.boneTransforms = new Matrix[resource.Bones.Count];
  54. this.modelData.model.CopyBoneTransformsTo(this.modelData.boneTransforms);
  55. this.resource = (object)this.modelData;
  56. }
  57. protected override void Dispose(bool disposing)
  58. {
  59. if (disposing)
  60. {
  61. if (modelData != null)
  62. {
  63. modelData.model = null;
  64. modelData = null;
  65. }
  66. }
  67. base.Dispose(disposing);
  68. }
  69. }
  70. }