Ejemplo n.º 1
0
        private void RenderSelection(Widget canvas)
        {
            if (Document.Current.PreviewScene)
            {
                return;
            }
            var vp = GetCurrentViewport3D();

            if (vp?.Camera == null)
            {
                return;
            }
            canvas.PrepareRendererState();
            var nodes = Document.Current.SelectedNodes().Editable().OfType <Node3D>().ToList();

            if (nodes.Count == 0)
            {
                return;
            }
            var cameraProjection = vp.Camera?.Projection ?? Matrix44.Identity;

            Renderer.Flush();
            Renderer.PushState(
                RenderState.CullMode |
                RenderState.World |
                RenderState.View |
                RenderState.Projection |
                RenderState.DepthState);
            Renderer.View       = vp.Camera.View;
            Renderer.Projection = Viewport3D.MakeProjection(vp.Width, vp.Height, vp.LocalToWorldTransform, cameraProjection, Renderer.Projection);
            Renderer.DepthState = DepthState.DepthReadWrite;
            Renderer.Clear(ClearOptions.DepthBuffer);
            foreach (var node in nodes)
            {
                RenderGizmo(node);
            }
            Renderer.PopState();
        }