Пример #1
0
        public void DrawReflectionMap(DwarfTime gameTime, PlayState game, float waterHeight, Matrix reflectionViewMatrix, Effect effect, GraphicsDevice device)
        {
            if (!DrawReflections)
            {
                return;
            }
            Plane reflectionPlane = CreatePlane(waterHeight, new Vector3(0, -1, 0), reflectionViewMatrix, true);

            effect.Parameters["ClipPlane0"].SetValue(new Vector4(reflectionPlane.Normal, reflectionPlane.D));
            effect.Parameters["Clipping"].SetValue(1);
            effect.Parameters["GhostMode"].SetValue(0);
            device.SetRenderTarget(reflectionRenderTarget);


            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1.0f, 0);
            effect.Parameters["xView"].SetValue(reflectionViewMatrix);

            //game.DrawSky();

            if (DrawTerrainReflected)
            {
                game.DrawSky(gameTime, reflectionViewMatrix, 0.25f);
                game.Draw3DThings(gameTime, effect, reflectionViewMatrix);
            }
            else
            {
                game.DrawSky(gameTime, reflectionViewMatrix, 0.25f);
            }

            Drawer3D.Render(device, effect, false);

            if (DrawComponentsReflected)
            {
                effect.Parameters["xView"].SetValue(reflectionViewMatrix);
                game.DrawComponents(gameTime, effect, reflectionViewMatrix, ComponentManager.WaterRenderType.Reflective, waterHeight);
            }

            effect.Parameters["Clipping"].SetValue(0);
            device.SetRenderTarget(null);

            ReflectionMap = reflectionRenderTarget;
        }