//draw the reflectionMap onto the plane public void DrawReflectionMap(Matrix viewMatrix, Matrix projectionMatrix, SkyDome skyDome) { Plane reflectionPlane = CreatePlane(heightOfWater - 0.5f, new Vector3(0, -1, 0), reflectionMatrix, projectionMatrix, true); device.ClipPlanes[0].Plane = reflectionPlane; device.ClipPlanes[0].IsEnabled = true; device.SetRenderTarget(0, reflection); device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1.0f, 0); drawEnviroment(reflectionMatrix, projectionMatrix); skyDome.DrawSkyDome(reflectionMatrix, projectionMatrix, domeRotation); device.ClipPlanes[0].IsEnabled = false; device.SetRenderTarget(0, null); reflectionMap = reflection.GetTexture(); }
public void Draw(GameTime gameTime, ChaseCamera camera, City cityToRender, SkyDome skyDome, Viewport view, bool enableWater) { domeRotation += 0.01f; if (domeRotation > 360) { domeRotation = 0; } graphics.GraphicsDevice.Viewport = view; float time = (float)gameTime.TotalGameTime.TotalMilliseconds / 100.0f; //device.RenderState.FillMode = FillMode.WireFrame; if (enableWater) { UpdateRefelectionMatrix(camera); DrawRefractionMap(camera.view, camera.projection); DrawReflectionMap(camera.view, camera.projection, skyDome); device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1.0f, 0); } drawEnviroment(camera.view, camera.projection); if (cityToRender != null) { cityToRender.Draw(gameTime, camera.view, camera.projection); } skyDome.DrawSkyDome(camera.view, camera.projection, domeRotation); if (enableWater) { drawWater(camera.view, camera.projection, camera.Position, time); } //create tree billboards DrawBillboards(camera.view, camera.projection, camera.Position); }