Esempio n. 1
0
 private void DrawVoid(IRenderArgs renderArgs, Vector3 position)
 {
     // Void
     renderArgs.GraphicsDevice.SetVertexBuffer(SkyPlane);
     SkyPlaneEffect.World             = Matrix.CreateTranslation(0, -4, 0) * Matrix.CreateTranslation(position);
     SkyPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3()
                                        * new Vector3(0.2f, 0.2f, 0.6f)
                                        + new Vector3(0.04f, 0.04f, 0.1f);
     foreach (var pass in SkyPlaneEffect.CurrentTechnique.Passes)
     {
         pass.Apply();
     }
     renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
 }
Esempio n. 2
0
        private void DrawSky(IRenderArgs renderArgs, Vector3 position)
        {
            // Sky
            SkyPlaneEffect.FogColor = AtmosphereColor.ToVector3();
            SkyPlaneEffect.World    = Matrix.CreateRotationX(MathHelper.Pi)
                                      * Matrix.CreateTranslation(0, 100, 0)
                                      * Matrix.CreateRotationX(MathHelper.TwoPi * CelestialAngle) * Matrix.CreateTranslation(position);
            SkyPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3();

            renderArgs.GraphicsDevice.SetVertexBuffer(SkyPlane);
            foreach (var pass in SkyPlaneEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
            }
            renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
        }
Esempio n. 3
0
        public void Draw(GameTime gameTime)
        {
            Game.GraphicsDevice.Clear(AtmosphereColor);
            Game.GraphicsDevice.SetVertexBuffer(SkyPlane);

            var position = Game.Camera.Position;
            var yaw      = Game.Camera.Yaw;

            Game.Camera.Position = TrueCraft.API.Vector3.Zero;
            Game.Camera.Yaw      = 0;
            Game.Camera.ApplyTo(SkyPlaneEffect);
            Game.Camera.Yaw = yaw;
            Game.Camera.ApplyTo(CelestialPlaneEffect);
            Game.Camera.Position = position;
            // Sky
            SkyPlaneEffect.FogColor = AtmosphereColor.ToVector3();
            SkyPlaneEffect.World    = Matrix.CreateRotationX(MathHelper.Pi)
                                      * Matrix.CreateTranslation(0, 100, 0)
                                      * Matrix.CreateRotationX(MathHelper.TwoPi * CelestialAngle);
            SkyPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3(); foreach (var pass in SkyPlaneEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                SkyPlaneEffect.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
            }

            // Sun
            Game.GraphicsDevice.SetVertexBuffer(CelestialPlane);
            var backup = Game.GraphicsDevice.BlendState;

            Game.GraphicsDevice.BlendState        = BlendState.Additive;
            Game.GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
            CelestialPlaneEffect.Texture          = Game.TextureMapper.GetTexture("terrain/sun.png");
            CelestialPlaneEffect.World            = Matrix.CreateRotationX(MathHelper.Pi)
                                                    * Matrix.CreateTranslation(0, 100, 0)
                                                    * Matrix.CreateRotationX(MathHelper.TwoPi * CelestialAngle);
            foreach (var pass in CelestialPlaneEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                CelestialPlaneEffect.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
            }
            // Moon
            CelestialPlaneEffect.Texture = Game.TextureMapper.GetTexture("terrain/moon.png");
            CelestialPlaneEffect.World   = Matrix.CreateTranslation(0, -100, 0)
                                           * Matrix.CreateRotationX(MathHelper.TwoPi * CelestialAngle);
            foreach (var pass in CelestialPlaneEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                CelestialPlaneEffect.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
            }
            Game.GraphicsDevice.BlendState        = backup;
            Game.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            // Void
            Game.GraphicsDevice.SetVertexBuffer(SkyPlane);
            SkyPlaneEffect.World             = Matrix.CreateTranslation(0, -16, 0);
            SkyPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3()
                                               * new Vector3(0.2f, 0.2f, 0.6f)
                                               + new Vector3(0.04f, 0.04f, 0.1f);
            foreach (var pass in SkyPlaneEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                SkyPlaneEffect.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
            }
        }