/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
- #region License
- /* Copyright : Santtu Syrjälä
- * License : New BSD
- *
- * SceneGraphNode for Delta Engine
- *
- * General purpose scene graph for 2D and 3D that is compatible with Delta Engines vertex constructs, cameras and rendering pipeline.
- *
- * 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
- * in here if YOU WISH.
- *
- * 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
- * this. It is NOT REQUIRED, though it would serve as a little thanks that would warm this programmer's heart.
- *
- * Changes :
- * 10.09.2011 : Release of the preview 0.1.0.0
- */
- #endregion
-
- using Delta.ContentSystem.Rendering;
- using Delta.Graphics.Basics;
-
- namespace Delta.Rendering.SceneGraph
- {
- /// <summary>
- /// SceneGraphNode for Geometry and Material based data.
- /// </summary>
- public class SceneGraphNodeGeometry : SceneGraphNode
- {
- #region Geometry (Public)
- /// <summary>
- /// Gets or Sets the Geometry to be rendered.
- /// </summary>
- public Geometry Geometry
- {
- get;
- set;
- }
- #endregion
-
- #region GeometryData (Public)
- /// <summary>
- /// Geometry data inside Geomertry to be rendered.
- /// Basically just a wrapper to Geometry property.
- /// </summary>
- public GeometryData GeometryData
- {
- get
- {
- GeometryData toReturn = null;
- if (Geometry != null)
- {
- toReturn = Geometry.Data;
- }
- return toReturn;
- }
- protected set
- {
- Geometry = Geometry.Create(value);
- }
- }
- #endregion
-
- #region Material (Public)
- /// <summary>
- /// Gets or Sets the Material in which the Geometry is rendered.
- /// </summary>
- public BaseMaterial Material
- {
- get;
- set;
- }
- #endregion
-
- #region Constructors
- /// <summary>
- /// Constructor for Geometry and Material.
- /// </summary>
- /// <param name="geometry">Geometry to be rendered.</param>
- /// <param name="material">Matrial in which the Geometry in rendered</param>
- public SceneGraphNodeGeometry(Geometry geometry, BaseMaterial material)
- {
- Geometry = geometry;
- Material = material;
- }
-
- /// <summary>
- /// Constructor for GeometryData and Material.
- /// Constructs the Geometry from GeometryData automatically.
- /// </summary>
- /// <param name="geometryData">Geometry Data</param>
- /// <param name="material">Material</param>
- public SceneGraphNodeGeometry(GeometryData geometryData, BaseMaterial material)
- {
- GeometryData = geometryData;
- Material = material;
- }
-
- /// <summary>
- /// Constructor for classes that inherit this.
- /// </summary>
- protected SceneGraphNodeGeometry()
- : this((Geometry)null, null)
- {
- }
- #endregion
-
- #region Render (Public)
- /// <summary>
- /// Overriden Render method to render the geometry based on set material.
- /// </summary>
- public override void Render()
- {
- if (Geometry != null &&
- Material != null)
- {
- Material.Draw(Geometry, ref worldTransformation);
- }
- }
- #endregion
- }
- }