DynamicModelContent.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #region License
  2. // Copyright 2016 Kastellanos Nikolaos
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using System;
  17. using System.Collections.Generic;
  18. using Microsoft.Xna.Framework.Content;
  19. using Microsoft.Xna.Framework.Content.Pipeline.Processors;
  20. namespace nkast.Aether.Content.Pipeline.Graphics
  21. {
  22. public class DynamicModelContent
  23. {
  24. [Flags]
  25. public enum BufferType : int
  26. {
  27. /// <summary>
  28. /// Use the default BufferReader
  29. /// </summary>
  30. Default = int.MinValue,
  31. /// <summary>
  32. /// Deserialize a Dynamic Buffer
  33. /// </summary>
  34. Dynamic = 0,
  35. /// <summary>
  36. /// Deserialize a Dynamic Buffer with BufferUsage.WriteOnly
  37. /// </summary>
  38. DynamicWriteOnly = 0x01,
  39. }
  40. protected internal ModelContent Source { get; protected set; }
  41. public BufferType VertexBufferType = BufferType.Dynamic;
  42. public BufferType IndexBufferType = BufferType.Dynamic;
  43. // Summary:
  44. // Gets the collection of bones that are referenced by this model.
  45. public ModelBoneContentCollection Bones { get { return Source.Bones; } }
  46. // Summary:
  47. // Gets the collection of meshes that are associated with this model.
  48. [ContentSerializerIgnore]
  49. public List<DynamicModelMeshContent> Meshes { get; private set; }
  50. // Summary:
  51. // Gets the root bone of this model
  52. [ContentSerializerIgnore]
  53. public ModelBoneContent Root { get { return Source.Root; } }
  54. // Summary:
  55. // Gets a user defined tag object.
  56. [ContentSerializer(SharedResource = true)]
  57. public object Tag { get { return Source.Tag; } set { Source.Tag = value; } }
  58. public DynamicModelContent(ModelContent source)
  59. {
  60. this.Source = source;
  61. //deep clone Meshes
  62. Meshes = new List<DynamicModelMeshContent>(source.Meshes.Count);
  63. foreach(var mesh in source.Meshes)
  64. Meshes.Add(new DynamicModelMeshContent(mesh));
  65. }
  66. }
  67. }