public void Draw(BaseEffect effect) { if (this.Geometry == null) { return; } GraphicsDevice graphicsDevice = this.Mesh.GraphicsDevice; if (this.AlwaysOnTop.HasValue) { GraphicsDeviceExtensions.GetDssCombiner(graphicsDevice).DepthBufferFunction = this.AlwaysOnTop.Value ? CompareFunction.Always : CompareFunction.LessEqual; } if (this.Blending.HasValue) { GraphicsDeviceExtensions.SetBlendingMode(graphicsDevice, this.Blending.Value); } if (this.SamplerState != null) { for (int index = 0; index < this.Mesh.UsedSamplers; ++index) { graphicsDevice.SamplerStates[index] = this.SamplerState; } } if (this.CullMode.HasValue) { GraphicsDeviceExtensions.SetCullMode(graphicsDevice, this.CullMode.Value); } if (this.NoAlphaWrite.HasValue) { GraphicsDeviceExtensions.GetBlendCombiner(graphicsDevice).ColorWriteChannels = ColorWriteChannels.Red | ColorWriteChannels.Green | ColorWriteChannels.Blue; } effect.Prepare(this); GraphicsDeviceExtensions.ApplyCombiners(graphicsDevice); this.Geometry.Draw(effect); }
private void ClearDepth(Mesh mesh) { bool depthWrites = mesh.DepthWrites; ColorWriteChannels colorWriteChannels = GraphicsDeviceExtensions.GetBlendCombiner(this.GraphicsDevice).ColorWriteChannels; mesh.DepthWrites = true; GraphicsDeviceExtensions.SetColorWriteChannels(this.GraphicsDevice, ColorWriteChannels.None); mesh.AlwaysOnTop = true; mesh.Position += this.CameraManager.InverseView.Forward * 2f; mesh.Draw(); mesh.AlwaysOnTop = false; mesh.Position -= this.CameraManager.InverseView.Forward * 2f; GraphicsDeviceExtensions.SetColorWriteChannels(this.GraphicsDevice, colorWriteChannels); mesh.DepthWrites = depthWrites; }