Update() public method

Allows the component to run logic.
public Update ( ) : void
return void
Exemplo n.º 1
0
        public void renderReflection(GameTime gameTime)
        {
            // Reflect the camera's properties across the water plane
            Vector3 reflectedCameraPosition = myGame.camera.Position;

            reflectedCameraPosition.Y = -reflectedCameraPosition.Y
                                        + position.Y * 2;

            Vector3 reflectedCameraTarget = myGame.camera.Target;

            reflectedCameraTarget.Y = -reflectedCameraTarget.Y
                                      + position.Y * 2;

            // Create a temporary camera to render the reflected scene
            TargetCamera reflectionCamera = new TargetCamera(myGame, reflectedCameraPosition, reflectedCameraTarget);

            reflectionCamera.Update();

            // Set the reflection camera's view matrix to the water effect
            waterEffect.Parameters["ReflectedView"].SetValue(reflectionCamera.View);

            // Create the clip plane
            Vector4 clipPlane = new Vector4(0, 1, 0, -position.Y);

            // Set the render target
            myGame.GraphicsDevice.SetRenderTarget(reflectionTarg);
            myGame.GraphicsDevice.Clear(Color.Black);

            // Draw all objects with clip plane
            Camera oldCamera = myGame.camera;

            myGame.camera = reflectionCamera;
            foreach (IRenderable renderable in Objects)
            {
                renderable.SetClipPlane(clipPlane);

                renderable.Draw();
                //reflectionCamera.View,
                //    reflectionCamera.Projection,
                //    reflectedCameraPosition);

                renderable.SetClipPlane(null);
            }
            myGame.camera = oldCamera;

            myGame.GraphicsDevice.SetRenderTarget(null);

            // Set the reflected scene to its effect parameter in
            // the water effect
            waterEffect.Parameters["ReflectionMap"].SetValue(reflectionTarg);
        }
Exemplo n.º 2
0
        public void renderReflection(Camera camera)
        {
            // Reflect the camera's properties across the water plane
            Vector3 reflectedCameraPosition = ((FreeCamera)camera).Position;

            reflectedCameraPosition.Y = -reflectedCameraPosition.Y
                                        + waterMesh.Position.Y * 2;

            Vector3 reflectedCameraTarget = ((FreeCamera)camera).Target;

            reflectedCameraTarget.Y = -reflectedCameraTarget.Y
                                      + waterMesh.Position.Y * 2;

            // Create a temporary camera to render the reflected scene
            Camera reflectionCamera = new TargetCamera(
                reflectedCameraPosition, reflectedCameraTarget, graphics);

            reflectionCamera.Update();

            // Set the reflection camera's view matrix to the water effect
            waterEffect.Parameters["ReflectedView"].SetValue(
                reflectionCamera.View);

            // Create the clip plane
            Vector4 clipPlane = new Vector4(0, 1, 0, -waterMesh.Position.Y);

            // Set the render target
            graphics.SetRenderTarget(reflectionTarg);
            graphics.Clear(Color.Black);

            // Draw all objects with clip plane
            foreach (IRenderable renderable in Objects)
            {
                renderable.SetClipPlane(clipPlane);

                renderable.Draw(reflectionCamera.View,
                                reflectionCamera.Projection,
                                reflectedCameraPosition);

                renderable.SetClipPlane(null);
            }

            graphics.SetRenderTarget(null);

            // Set the reflected scene to its effect parameter in
            // the water effect
            waterEffect.Parameters["ReflectionMap"].SetValue(reflectionTarg);
        }
Exemplo n.º 3
0
        public void renderReflection(GameTime gameTime)
        {
            // Reflect the camera's properties across the water plane
            Vector3 reflectedCameraPosition = myGame.camera.Position;
            reflectedCameraPosition.Y = -reflectedCameraPosition.Y
                + position.Y * 2;

            Vector3 reflectedCameraTarget = myGame.camera.Target;
            reflectedCameraTarget.Y = -reflectedCameraTarget.Y
                + position.Y * 2;

            // Create a temporary camera to render the reflected scene
            TargetCamera reflectionCamera = new TargetCamera(myGame,reflectedCameraPosition,reflectedCameraTarget);

            reflectionCamera.Update();

            // Set the reflection camera's view matrix to the water effect
            waterEffect.Parameters["ReflectedView"].SetValue(reflectionCamera.View);

            // Create the clip plane
            Vector4 clipPlane = new Vector4(0, 1, 0, -position.Y);

            // Set the render target
            myGame.GraphicsDevice.SetRenderTarget(reflectionTarg);
            myGame.GraphicsDevice.Clear(Color.Black);

            // Draw all objects with clip plane
            Camera oldCamera = myGame.camera;
            myGame.camera = reflectionCamera;
            foreach (IRenderable renderable in Objects)
            {
                renderable.SetClipPlane(clipPlane);

                renderable.Draw();
                //reflectionCamera.View,
                //    reflectionCamera.Projection,
                //    reflectedCameraPosition);

                renderable.SetClipPlane(null);
            }
            myGame.camera = oldCamera;

            myGame.GraphicsDevice.SetRenderTarget(null);

            // Set the reflected scene to its effect parameter in
            // the water effect
            waterEffect.Parameters["ReflectionMap"].SetValue(reflectionTarg);
        }