Sky.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Sky.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 Microsoft.Xna.Framework;
  11. using Microsoft.Xna.Framework.Content;
  12. using Microsoft.Xna.Framework.Graphics;
  13. #endregion
  14. namespace GeneratedGeometry
  15. {
  16. /// <summary>
  17. /// Runtime class for loading and rendering a textured skydome
  18. /// that was created during the build process by the SkyProcessor.
  19. /// </summary>
  20. public class Sky
  21. {
  22. #region Fields
  23. public Model Model;
  24. public Texture2D Texture;
  25. #endregion
  26. /// <summary>
  27. /// Helper for drawing the skydome mesh.
  28. /// </summary>
  29. public void Draw(Matrix view, Matrix projection)
  30. {
  31. GraphicsDevice GraphicsDevice = Texture.GraphicsDevice;
  32. GraphicsDevice.BlendState = BlendState.Opaque;
  33. GraphicsDevice.RasterizerState = RasterizerState.CullNone;
  34. GraphicsDevice.DepthStencilState = DepthStencilState.None;
  35. GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
  36. view.Translation = Vector3.Zero;
  37. foreach (ModelMesh mesh in Model.Meshes)
  38. {
  39. foreach (BasicEffect effect in mesh.Effects)
  40. {
  41. effect.View = view;
  42. effect.Projection = projection;
  43. effect.Texture = Texture;
  44. effect.TextureEnabled = true;
  45. }
  46. mesh.Draw();
  47. }
  48. }
  49. }
  50. }