Exemple #1
0
        private void RenderExtras(GUILayer.SimpleRenderingContext context, DesignView designView)
        {
            bool renderSelected = RenderState.DisplayBound == DisplayFlagModes.Selection ||
                                  RenderState.DisplayCaption == DisplayFlagModes.Selection ||
                                  RenderState.DisplayPivot == DisplayFlagModes.Selection;

            if (renderSelected)
            {
                var selection = DesignView.Context.As <ISelectionContext>().Selection;
                IEnumerable <DomNode> rootDomNodes = DomNode.GetRoots(selection.AsIEnumerable <DomNode>());
                RenderProperties(context, rootDomNodes,
                                 RenderState.DisplayCaption == DisplayFlagModes.Selection,
                                 RenderState.DisplayBound == DisplayFlagModes.Selection,
                                 RenderState.DisplayPivot == DisplayFlagModes.Selection);
            }

            if (RenderState.GridMode == RenderState.GridModes.Enabled)
            {
                var          game       = designView.Context.As <IGame>();
                GridRenderer gridRender = game.Grid.Cast <GridRenderer>();
                gridRender.Render(context, Camera);
            }

            RenderProperties(context, Items,
                             RenderState.DisplayCaption == DisplayFlagModes.Always,
                             RenderState.DisplayBound == DisplayFlagModes.Always,
                             RenderState.DisplayPivot == DisplayFlagModes.Always);

            GameEngine.DrawText2D(m_pendingCaption, Util3D.CaptionFont, 1, 1, Color.White);
        }
        // render the scene.
        public void Render()
        {
            bool skipRender =
                SurfaceId == 0 ||
                GameEngine.IsInError ||
                Width == 0 ||
                Height == 0 ||
                DesignView.Context == null;

            if (skipRender)
            {
                return;
            }

            m_clk.Start();
            GameEngine.SetObjectProperty(swapChainId, SurfaceId, BkgColorPropId, DesignView.BackColor);
            GameEngine.SetRenderState(RenderState);
            GameEngine.Begin(SurfaceId, Camera.ViewMatrix, Camera.ProjectionMatrix);

            IGame        game       = DesignView.Context.As <IGame>();
            GridRenderer gridRender = game.Grid.Cast <GridRenderer>();

            gridRender.Render(Camera);

            bool renderSelected = RenderState.DisplayBound == DisplayFlagModes.Selection ||
                                  RenderState.DisplayCaption == DisplayFlagModes.Selection ||
                                  RenderState.DisplayPivot == DisplayFlagModes.Selection;


            if (renderSelected)
            {
                // for testing draw bounds for selected objects
                var selection = DesignView.Context.As <ISelectionContext>().Selection;
                IEnumerable <DomNode> rootDomNodes = DomNode.GetRoots(selection.AsIEnumerable <DomNode>());
                RenderProperties(rootDomNodes,
                                 RenderState.DisplayCaption == DisplayFlagModes.Selection,
                                 RenderState.DisplayBound == DisplayFlagModes.Selection,
                                 RenderState.DisplayPivot == DisplayFlagModes.Selection);
            }

            RenderProperties(Items,
                             RenderState.DisplayCaption == DisplayFlagModes.Always,
                             RenderState.DisplayBound == DisplayFlagModes.Always,
                             RenderState.DisplayPivot == DisplayFlagModes.Always);

            GameEngine.RenderGame();


            if (DesignView.Manipulator != null)
            {
                DesignView.Manipulator.Render(this);
            }

            string str = string.Format("View Type: {0}   time-per-frame: {1:0.00} ms", ViewType, m_clk.Milliseconds);

            GameEngine.DrawText2D(str, Util3D.CaptionFont, 1, 1, Color.White);

            RenderSystemAxis();
            GameEngine.End();
        }
Exemple #3
0
        // render the scene.
        public override void Render()
        {
            bool skipRender =
                SurfaceId == 0 ||
                GameEngine.IsInError ||
                Width == 0 ||
                Height == 0 ||
                DesignView.Context == null;

            if (skipRender)
            {
                return;
            }

            m_clk.Start();
            GameEngine.SetObjectProperty(swapChainId, SurfaceId, BkgColorPropId, DesignView.BackColor);
            GameEngine.SetRenderState(RenderState);
            GameEngine.Begin(SurfaceId, Camera.ViewMatrix, Camera.ProjectionMatrix);

            IGame        game       = DesignView.Context.As <IGame>();
            GridRenderer gridRender = game.Grid.Cast <GridRenderer>();

            gridRender.Render(Camera);

            GameEngine.RenderGame();

            bool renderSelected = RenderState.DisplayBound == DisplayFlagModes.Selection ||
                                  RenderState.DisplayCaption == DisplayFlagModes.Selection ||
                                  RenderState.DisplayPivot == DisplayFlagModes.Selection;

            if (renderSelected)
            {
                var selection = DesignView.Context.As <ISelectionContext>().Selection;
                IEnumerable <DomNode> rootDomNodes = DomNode.GetRoots(selection.AsIEnumerable <DomNode>());
                RenderProperties(rootDomNodes,
                                 RenderState.DisplayCaption == DisplayFlagModes.Selection,
                                 RenderState.DisplayBound == DisplayFlagModes.Selection,
                                 RenderState.DisplayPivot == DisplayFlagModes.Selection);
            }

            RenderProperties(Items,
                             RenderState.DisplayCaption == DisplayFlagModes.Always,
                             RenderState.DisplayBound == DisplayFlagModes.Always,
                             RenderState.DisplayPivot == DisplayFlagModes.Always);

            GameEngine.SetRendererFlag(BasicRendererFlags.Foreground | BasicRendererFlags.Lit);
            if (DesignView.Manipulator != null)
            {
                DesignView.Manipulator.Render(this);
            }

            string str = string.Format("View Type: {0}   time per frame-render call: {1:0.00} ms", ViewType, m_clk.Milliseconds);

            GameEngine.DrawText2D(str, Util3D.CaptionFont, 1, 1, Color.White);
            GameEngine.End();

            if (IsPicking)
            {// todo: use Directx to draw marque.
                using (Graphics g = CreateGraphics())
                {
                    Rectangle rect = MakeRect(FirstMousePoint, CurrentMousePoint);
                    if (rect.Width > 0 && rect.Height > 0)
                    {
                        g.DrawRectangle(s_marqueePen, rect);
                    }
                }
            }
        }