Exemplo n.º 1
0
        public void RenderReflection(Camera.Camera camera, GameTime gameTime)
        {
            var reflectedCameraPosition = camera.Position;

            reflectedCameraPosition.X = -reflectedCameraPosition.X + mirrorMesh.Position.X * 2;
            var reflectedCameraTarget = camera.Target;

            reflectedCameraTarget.X = -reflectedCameraTarget.X + mirrorMesh.Position.X * 2;
            var reflectionCamera = new TargetCamera(graphics)
            {
                Position = reflectedCameraPosition,
                Target   = reflectedCameraTarget
            };

            reflectionCamera.Update(gameTime);
            mirrorEffect.Parameters["ReflectedView"].SetValue(reflectionCamera.ViewMatrix);
            var clipPlane = new Vector4(1, 0, 0, -mirrorMesh.Position.X);

            graphics.SetRenderTarget(reflectionTarg);
            graphics.Clear(Color.Black);
            foreach (var renderable in Objects)
            {
                renderable.SetClipPlane(clipPlane);
                renderable.Draw(reflectionCamera);
                renderable.SetClipPlane(null);
            }
            graphics.SetRenderTarget(null);
            mirrorEffect.Parameters["ReflectionMap"].SetValue(reflectionTarg);
        }
Exemplo n.º 2
0
 protected override void Initialize()
 {
     LoadVertices();
     effect       = Content.Load <Effect>("Shader");
     liquidEffect = Content.Load <Effect>("Liquid");
     CreateBillboardSystems();
     metroTexture       = Content.Load <Texture2D>("metro");
     liquidTextTexture  = Content.Load <Texture2D>("Texture");
     perlinNoiseTexture = Content.Load <Texture2D>("perlin2");
     camera             = new Camera.Camera(graphics.GraphicsDevice);
     CreateModels();
     CreateMirror();
     spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
     base.Initialize();
 }
Exemplo n.º 3
0
 public void PreDraw(Camera.Camera camera, GameTime gameTime)
 {
     RenderReflection(camera, gameTime);
 }