PageRenderTime 122ms CodeModel.GetById 60ms app.highlight 3ms RepoModel.GetById 57ms app.codeStats 0ms

/Rendering/SceneGraph/SceneGraphNodeGeometry.cs

#
C# | 122 lines | 68 code | 8 blank | 46 comment | 5 complexity | ab7a177759ef9d0ff59c392bf2541561 MD5 | raw file
  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
 20using Delta.ContentSystem.Rendering;
 21using Delta.Graphics.Basics;
 22
 23namespace Delta.Rendering.SceneGraph
 24{
 25	/// <summary>
 26	/// SceneGraphNode for Geometry and Material based data.
 27	/// </summary>
 28	public class SceneGraphNodeGeometry : SceneGraphNode
 29	{
 30		#region Geometry (Public)
 31		/// <summary>
 32		/// Gets or Sets the Geometry to be rendered.
 33		/// </summary>
 34		public Geometry Geometry
 35		{
 36			get;
 37			set;
 38		}
 39		#endregion
 40
 41		#region GeometryData (Public)
 42		/// <summary>
 43		/// Geometry data inside Geomertry to be rendered. 
 44		/// Basically just a wrapper to Geometry property.
 45		/// </summary>
 46		public GeometryData GeometryData
 47		{
 48			get
 49			{
 50				GeometryData toReturn = null;
 51				if (Geometry != null)
 52				{
 53					toReturn = Geometry.Data;
 54				}
 55				return toReturn;
 56			}
 57			protected set
 58			{
 59				Geometry = Geometry.Create(value);
 60			}
 61		}
 62		#endregion
 63
 64		#region Material (Public)
 65		/// <summary>
 66		/// Gets or Sets the Material in which the Geometry is rendered.
 67		/// </summary>
 68		public BaseMaterial Material
 69		{
 70			get;
 71			set;
 72		}
 73		#endregion
 74
 75		#region Constructors
 76		/// <summary>
 77		/// Constructor for Geometry and Material.
 78		/// </summary>
 79		/// <param name="geometry">Geometry to be rendered.</param>
 80		/// <param name="material">Matrial in which the Geometry in rendered</param>
 81		public SceneGraphNodeGeometry(Geometry geometry, BaseMaterial material)
 82		{
 83			Geometry = geometry;
 84			Material = material;
 85		}
 86
 87		/// <summary>
 88		/// Constructor for GeometryData and Material.
 89		/// Constructs the Geometry from GeometryData automatically.
 90		/// </summary>
 91		/// <param name="geometryData">Geometry Data</param>
 92		/// <param name="material">Material</param>
 93		public SceneGraphNodeGeometry(GeometryData geometryData, BaseMaterial material)
 94		{
 95			GeometryData = geometryData;
 96			Material = material;
 97		}
 98
 99		/// <summary>
100		/// Constructor for classes that inherit this.
101		/// </summary>
102		protected SceneGraphNodeGeometry()
103			: this((Geometry)null, null)
104		{
105		}
106		#endregion
107
108		#region Render (Public)
109		/// <summary>
110		/// Overriden Render method to render the geometry based on set material.
111		/// </summary>
112		public override void Render()
113		{
114			if (Geometry != null &&
115			    Material != null)
116			{
117				Material.Draw(Geometry, ref worldTransformation);
118			}
119		}
120		#endregion
121	}
122}