PageRenderTime 183ms CodeModel.GetById 70ms app.highlight 4ms RepoModel.GetById 54ms app.codeStats 13ms

/Utilities/Graphics/ShaderFeatures/AmbientDiffuseShaderFeature.cs

#
C# | 114 lines | 66 code | 9 blank | 39 comment | 0 complexity | fe02904597ff3b28aeeb44bedbd73782 MD5 | raw file
  1using System.Collections.Generic;
  2using System.IO;
  3using Delta.Utilities.Datatypes;
  4
  5namespace Delta.Utilities.Graphics.ShaderFeatures
  6{
  7	/// <summary>
  8	/// Ambient diffuse shader feature
  9	/// </summary>
 10	public class AmbientDiffuseShaderFeature : IShaderFeature
 11	{
 12		#region AmbientColor (Public)
 13		/// <summary>
 14		/// Default ambient color, usually not used, but can be set here in the
 15		/// BasicShaderFeature. When used, mostly affected by lighting
 16		/// calculations.
 17		/// </summary>
 18		public Color AmbientColor = ShaderConstants.DefaultAmbientColor;
 19		#endregion
 20
 21		#region DiffuseColor (Public)
 22		/// <summary>
 23		/// Default diffuse color, usually not used, but can be set here in the
 24		/// BasicShaderFeature. When used, mostly affected by lighting
 25		/// calculations.
 26		/// </summary>
 27		public Color DiffuseColor = ShaderConstants.DefaultDiffuseColor;
 28		#endregion
 29
 30		#region ShaderFeature (Public)
 31		/// <summary>
 32		/// Which shader feature flag is this ShaderFeature class using?
 33		/// Important for loading this file via ShaderData.LoadShaderFeature.
 34		/// Each flag should obviously only have one class for it!
 35		/// </summary>
 36		public ShaderFeatureFlags ShaderFeature
 37		{
 38			get
 39			{
 40				return ShaderFeatureFlags.AmbientDiffuse;
 41			}
 42		}
 43		#endregion
 44
 45		#region RequiredShaderFeatures (Public)
 46		/// <summary>
 47		/// Which shader feature flags are required for this ShaderFeature.
 48		/// Very important for creating of a new ShaderFeature.
 49		/// </summary>
 50		public ShaderFeatureFlags RequiredShaderFeatures
 51		{
 52			get
 53			{
 54				return ShaderFeatureFlags.Basic;
 55			}
 56		}
 57		#endregion
 58
 59		#region Parameters (Public)
 60		/// <summary>
 61		/// Parameters as a dictionary, will be generated on the fly when
 62		/// requested.
 63		/// </summary>
 64		public Dictionary<string, object> Parameters
 65		{
 66			get
 67			{
 68				Dictionary<string, object> ret = new Dictionary<string, object>();
 69				ret.Add("AmbientColor", AmbientColor);
 70				ret.Add("DiffuseColor", DiffuseColor);
 71				return ret;
 72			}
 73		}
 74		#endregion
 75
 76		#region Constructors
 77		/// <summary>
 78		/// Create ambient diffuse shader feature
 79		/// </summary>
 80		public AmbientDiffuseShaderFeature()
 81		{
 82		}
 83
 84		/// <summary>
 85		/// Create ambient diffuse shader feature and load automatically
 86		/// the ShaderFeatures from a binary data stream.
 87		/// </summary>
 88		public AmbientDiffuseShaderFeature(BinaryReader reader)
 89		{
 90			Load(reader);
 91		}
 92		#endregion
 93
 94		#region ISaveLoadBinary Members
 95		/// <summary>
 96		/// Load this ShaderFeature from a binary data stream.
 97		/// </summary>
 98		public void Load(BinaryReader reader)
 99		{
100			AmbientColor.Load(reader);
101			DiffuseColor.Load(reader);
102		}
103
104		/// <summary>
105		/// Save this ShaderFeature to a binary data stream.
106		/// </summary>
107		public void Save(BinaryWriter writer)
108		{
109			AmbientColor.Save(writer);
110			DiffuseColor.Save(writer);
111		}
112		#endregion
113	}
114}