PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Utilities/Graphics/ShaderFeatures/AmbientDiffuseShaderFeature.cs

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