public void DrawGround(Camera camera, bool mirror) { camera.Reflecting = mirror; camera.Snap(); camera.SetTechnique("MultiTextured"); camera.SetParam("xTexture0", Textures[0]); camera.SetParam("xTexture1", Textures[1]); camera.SetParam("xTexture2", Textures[2]); camera.SetParam("xTexture3", Textures[3]); camera.SetParam("xWorld", Matrix.Identity); foreach (EffectPass pass in camera.Technique.Passes) { pass.Apply(); camera.device.Indices = terrainIndexBuffer; camera.device.SetVertexBuffer(terrainVertexBuffer); camera.device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3); } }
public void DrawWater(Camera camera, float time) { camera.SetTechnique("Water"); camera.SetParam("xWorld", Matrix.Identity); camera.SetParam("xView", camera.View); camera.SetParam("xProjection", camera.Projection); camera.SetParam("xReflectionView", camera.Mirror); camera.SetParam("xReflectionMap", reflectionMap); camera.SetParam("xRefractionMap", refractionMap); camera.SetParam("xWaterBumpMap", rippleMap); camera.SetParam("xWaveLength", 0.1f); camera.SetParam("xWaveHeight", 0.3f); camera.SetParam("xCamPos", camera.location); camera.SetParam("xTime", time); camera.SetParam("xWindForce", 0.001f); camera.SetParam("xWindDirection", wind); camera.Effect.CurrentTechnique.Passes[0].Apply(); camera.device.SetVertexBuffer(waterVertexBuffer); camera.device.DrawPrimitives(PrimitiveType.TriangleList, 0, waterVertexBuffer.VertexCount / 3); }
public void MapWater(Camera camera) { camera.Reflecting = false; Plane refractionPlane = CreatePlane(waterHeight + 1.5f, Vector3.Down, camera, false); camera.SetParam("ClipPlane0", new Vector4(refractionPlane.Normal, refractionPlane.D)); camera.SetParam("Clipping", true); camera.device.SetRenderTarget(refractionT); camera.device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer | ClearOptions.Stencil, Color.Transparent, 1.0f, 0); DrawGround(camera, false); camera.RevertTarget(); camera.SetParam("Clipping", false); refractionMap = refractionT; }
public void MapMirror(Camera camera, Sky sky) { camera.Reflecting = true; Plane reflectionPlane = CreatePlane(waterHeight - 0.5f, Vector3.Down, camera, true); camera.SetParam("ClipPlane0", new Vector4(reflectionPlane.Normal, reflectionPlane.D)); camera.SetParam("Clipping", true); camera.SetTarget(reflectionT); camera.device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer | ClearOptions.Stencil, Color.SteelBlue, 1.0f, 0); sky.DrawClouds(camera); DrawGround(camera, true); camera.SetParam("Clipping", false); camera.RevertTarget(); reflectionMap = reflectionT; }