PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/Rendering/SceneGraph/SceneGraphNodeGeometry.cs

#
C# | 122 lines | 68 code | 8 blank | 46 comment | 5 complexity | ab7a177759ef9d0ff59c392bf2541561 MD5 | raw file
Possible License(s): Apache-2.0
  1. #region License
  2. /* Copyright : Santtu Syrjälä
  3. * License : New BSD
  4. *
  5. * SceneGraphNode for Delta Engine
  6. *
  7. * General purpose scene graph for 2D and 3D that is compatible with Delta Engines vertex constructs, cameras and rendering pipeline.
  8. *
  9. * If You find a bug, find a way to make it work faster or other additions to make it more useful please share them! You can find me in Delta Engine forums. You will get Your name
  10. * in here if YOU WISH.
  11. *
  12. * Addition : I don't wa...(of course I want) NEED money for this thing. I though would like You to include me in the credits portion of Your application if You like/use
  13. * this. It is NOT REQUIRED, though it would serve as a little thanks that would warm this programmer's heart.
  14. *
  15. * Changes :
  16. * 10.09.2011 : Release of the preview 0.1.0.0
  17. */
  18. #endregion
  19. using Delta.ContentSystem.Rendering;
  20. using Delta.Graphics.Basics;
  21. namespace Delta.Rendering.SceneGraph
  22. {
  23. /// <summary>
  24. /// SceneGraphNode for Geometry and Material based data.
  25. /// </summary>
  26. public class SceneGraphNodeGeometry : SceneGraphNode
  27. {
  28. #region Geometry (Public)
  29. /// <summary>
  30. /// Gets or Sets the Geometry to be rendered.
  31. /// </summary>
  32. public Geometry Geometry
  33. {
  34. get;
  35. set;
  36. }
  37. #endregion
  38. #region GeometryData (Public)
  39. /// <summary>
  40. /// Geometry data inside Geomertry to be rendered.
  41. /// Basically just a wrapper to Geometry property.
  42. /// </summary>
  43. public GeometryData GeometryData
  44. {
  45. get
  46. {
  47. GeometryData toReturn = null;
  48. if (Geometry != null)
  49. {
  50. toReturn = Geometry.Data;
  51. }
  52. return toReturn;
  53. }
  54. protected set
  55. {
  56. Geometry = Geometry.Create(value);
  57. }
  58. }
  59. #endregion
  60. #region Material (Public)
  61. /// <summary>
  62. /// Gets or Sets the Material in which the Geometry is rendered.
  63. /// </summary>
  64. public BaseMaterial Material
  65. {
  66. get;
  67. set;
  68. }
  69. #endregion
  70. #region Constructors
  71. /// <summary>
  72. /// Constructor for Geometry and Material.
  73. /// </summary>
  74. /// <param name="geometry">Geometry to be rendered.</param>
  75. /// <param name="material">Matrial in which the Geometry in rendered</param>
  76. public SceneGraphNodeGeometry(Geometry geometry, BaseMaterial material)
  77. {
  78. Geometry = geometry;
  79. Material = material;
  80. }
  81. /// <summary>
  82. /// Constructor for GeometryData and Material.
  83. /// Constructs the Geometry from GeometryData automatically.
  84. /// </summary>
  85. /// <param name="geometryData">Geometry Data</param>
  86. /// <param name="material">Material</param>
  87. public SceneGraphNodeGeometry(GeometryData geometryData, BaseMaterial material)
  88. {
  89. GeometryData = geometryData;
  90. Material = material;
  91. }
  92. /// <summary>
  93. /// Constructor for classes that inherit this.
  94. /// </summary>
  95. protected SceneGraphNodeGeometry()
  96. : this((Geometry)null, null)
  97. {
  98. }
  99. #endregion
  100. #region Render (Public)
  101. /// <summary>
  102. /// Overriden Render method to render the geometry based on set material.
  103. /// </summary>
  104. public override void Render()
  105. {
  106. if (Geometry != null &&
  107. Material != null)
  108. {
  109. Material.Draw(Geometry, ref worldTransformation);
  110. }
  111. }
  112. #endregion
  113. }
  114. }