CustomEffectModelProcessor.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // CustomEffectModelProcessor.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.ComponentModel;
  12. using System.Collections.Generic;
  13. using Microsoft.Xna.Framework;
  14. using Microsoft.Xna.Framework.Graphics;
  15. using Microsoft.Xna.Framework.Content.Pipeline;
  16. using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
  17. using Microsoft.Xna.Framework.Content.Pipeline.Processors;
  18. #endregion
  19. namespace CustomEffectPipeline
  20. {
  21. /// <summary>
  22. /// Overloaded model processor that calls our new material processor.
  23. /// </summary>
  24. [ContentProcessor]
  25. public class CustomEffectModelProcessor : ModelProcessor
  26. {
  27. [DisplayName("Custom Effect")]
  28. [Description("The custom effect applied to the model.")]
  29. public string CustomEffect
  30. {
  31. get { return customEffect; }
  32. set { customEffect = value; }
  33. }
  34. private string customEffect;
  35. /// <summary>
  36. /// Use the CustomEffectMaterialProcessor for all of the materials in the model.
  37. /// We pass the processor parameter along to the material processor for the
  38. /// effect file name.
  39. /// </summary>
  40. protected override MaterialContent ConvertMaterial(MaterialContent material,
  41. ContentProcessorContext context)
  42. {
  43. OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();
  44. processorParameters.Add("CustomEffect", customEffect);
  45. processorParameters["ColorKeyColor"] = this.ColorKeyColor;
  46. processorParameters["ColorKeyEnabled"] = this.ColorKeyEnabled;
  47. processorParameters["TextureFormat"] = this.TextureFormat;
  48. processorParameters["GenerateMipmaps"] = this.GenerateMipmaps;
  49. processorParameters["ResizeTexturesToPowerOfTwo"] =
  50. this.ResizeTexturesToPowerOfTwo;
  51. return context.Convert<MaterialContent, MaterialContent>(material,
  52. "CustomEffectMaterialProcessor", processorParameters);
  53. }
  54. }
  55. }