public void healthDraw(FreeCamera camera) { bbEffect.Parameters["xScale"].SetValue(this.scale); bbEffect.Parameters["xWorld"].SetValue(Matrix.Identity); bbEffect.Parameters["xView"].SetValue(camera.View); bbEffect.Parameters["xProjection"].SetValue(camera.Projection); bbEffect.Parameters["xCamPos"].SetValue(camera.Position); bbEffect.Parameters["xAmbient"].SetValue(0); StaticHelpers.StaticHelper.Device.SetVertexBuffer(VertexBuffer); foreach (EffectPass pass in bbEffect.CurrentTechnique.Passes) { pass.Apply(); StaticHelpers.StaticHelper.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, VertexBuffer.VertexCount / 3); } }
public void DrawReflectionMap( FreeCamera camera,QuadTree tree) { Plane reflectionPlane = CreatePlane(waterHeight - 0.5f , new Vector3(0, 1, 0), camera.reflectionViewMatrix, true); effect.Parameters["ClipPlane0"].SetValue(new Vector4(reflectionPlane.Normal, reflectionPlane.D)); effect.Parameters["Clipping"].SetValue(true); // Allows the geometry to be clipped for the purpose of creating a refraction map device.SetRenderTarget(reflectionRenderTarget); device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0); sky.DrawSkyDome(camera); // tree.Draw(camera, 0); effect.Parameters["Clipping"].SetValue(false); device.SetRenderTarget(null); reflectionMap = reflectionRenderTarget; }
public void DrawSkyDome(FreeCamera camera) { device.DepthStencilState = DepthStencilState.None; Matrix[] modelTransforms = new Matrix[skyDome.Bones.Count]; skyDome.CopyAbsoluteBoneTransformsTo(modelTransforms); Matrix wMatrix = Matrix.CreateTranslation(0, -0.8f, 0) * Matrix.CreateScale(1000) * Matrix.CreateFromYawPitchRoll(camera.Yaw, camera.Pitch, 0) * Matrix.CreateTranslation(camera.Position); foreach (ModelMesh mesh in skyDome.Meshes) { foreach (Effect currentEffect in mesh.Effects) { Matrix worldMatrix = modelTransforms[mesh.ParentBone.Index] * wMatrix; currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"]; currentEffect.Parameters["xWorld"].SetValue(worldMatrix); currentEffect.Parameters["xView"].SetValue(camera.View); currentEffect.Parameters["xProjection"].SetValue(camera.Projection); currentEffect.Parameters["xTexture"].SetValue(cloudMap); } mesh.Draw(); } device.BlendState = BlendState.Opaque; device.DepthStencilState = DepthStencilState.Default; }
public override void Draw(FreeCamera camera) { model.Draw(camera); }
public void DrawWater(float time, FreeCamera camera) { effect.CurrentTechnique = effect.Techniques["Water"]; Matrix worldMatrix = Matrix.Identity; effect.Parameters["xWorld"].SetValue(worldMatrix); effect.Parameters["xView"].SetValue(camera.View); effect.Parameters["xReflectionView"].SetValue(camera.reflectionViewMatrix); effect.Parameters["xProjection"].SetValue(camera.Projection); effect.Parameters["xCamPos"].SetValue(camera.Position); effect.Parameters["xReflectionMap"].SetValue(reflectionMap); effect.Parameters["xRefractionMap"].SetValue(refractionMap); effect.Parameters["xWaterBumpMap"].SetValue(waterBumpMap); effect.Parameters["xWaveLength"].SetValue(0.1f); effect.Parameters["xWaveHeight"].SetValue(0.3f); effect.Parameters["xTime"].SetValue(time); effect.Parameters["xWindForce"].SetValue(0.002f); effect.Parameters["xWindDirection"].SetValue(windDirection); effect.CurrentTechnique.Passes[0].Apply(); device.SetVertexBuffer(waterVertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleList, 0, waterVertexBuffer.VertexCount / 3); }
public void DrawRefractionMap(FreeCamera camera,QuadTree tree) { Plane refractionPlane = CreatePlane(waterHeight + 1.5f, new Vector3(0, -1, 0), camera.View, false); effect.Parameters["ClipPlane0"].SetValue(new Vector4(refractionPlane.Normal, refractionPlane.D)); effect.Parameters["Clipping"].SetValue(true); // Allows the geometry to be clipped for the purpose of creating a refraction map device.SetRenderTarget(refractionRenderTarget); device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0); sky.DrawSkyDome(camera); // tree.Draw(camera, 0); device.SetRenderTarget(null); effect.Parameters["Clipping"].SetValue(false); // Make sure you turn it back off so the whole scene doesnt keep rendering as clipped refractionMap = refractionRenderTarget; }