private void DrawShadow(Vector3 from, Vector3?up = null) { DeviceContext.OutputMerger.DepthStencilState = null; DeviceContext.OutputMerger.BlendState = null; DeviceContext.Rasterizer.State = DeviceContextHolder.States.DoubleSidedState; DeviceContext.Rasterizer.SetViewports(_shadowViewport); DeviceContext.ClearDepthStencilView(_shadowBuffer.DepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0); DeviceContext.OutputMerger.SetTargets(_shadowBuffer.DepthView); _shadowCamera.LookAt(Vector3.Normalize(from) * _shadowCamera.FarZValue * 0.8f, Vector3.Zero, up ?? Vector3.UnitY); _shadowCamera.UpdateViewMatrix(); if (HideWheels && !_wheelMode) { var wheelNodes = new[] { "WHEEL_LF", "WHEEL_LR", "WHEEL_RF", "WHEEL_RR", "HUB_LF", "HUB_LR", "HUB_RF", "HUB_RR", "SUSP_LF", "SUSP_LR", "SUSP_RF", "SUSP_RR", }; _scene.Draw(DeviceContextHolder, _shadowCamera, SpecialRenderMode.Simple, x => !wheelNodes.Contains((x as Kn5RenderableList)?.OriginalNode.Name)); } else { _scene.Draw(DeviceContextHolder, _shadowCamera, SpecialRenderMode.Simple); } }
protected override void DrawOverride() { DrawPrepare(); base.DrawOverride(); Scene.Draw(DeviceContextHolder, Camera, SpecialRenderMode.Deferred); }