Beispiel #1
0
        public NativeDesignView()
        {
            NativeDesignControl[] views = new NativeDesignControl[]
            {
                new NativeDesignControl(this) { ViewType = ViewTypes.Perspective },
                new NativeDesignControl(this) { ViewType = ViewTypes.Right },
                new NativeDesignControl(this) { ViewType = ViewTypes.Top },
                new NativeDesignControl(this) { ViewType = ViewTypes.Front }
            };
            foreach (var v in views)
            {
                v.Adapter.AddRenderCallback(
                    (GUILayer.SimpleRenderingContext context) => RenderCallback(this, v.Camera));
            }
            QuadView.TopLeft = views[0];
            QuadView.TopRight = views[1];
            QuadView.BottomLeft = views[2];
            QuadView.BottomRight = views[3];

            // set control names.            
            QuadView.TopLeft.Name = "TopLeft";
            QuadView.TopRight.Name = "TopRight";
            QuadView.BottomLeft.Name = "BottomLeft";
            QuadView.BottomRight.Name = "BottomRight";



            ViewMode = ViewModes.Single;
            ContextChanged += NativeDesignView_ContextChanged;
        }
Beispiel #2
0
        /// <summary>
        /// Can the client do the command?</summary>
        /// <param name="commandTag">Command</param>
        /// <returns>true, iff client can do the command</returns>
        public bool CanDoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return(false);
            }

            NativeDesignControl activeControl = (NativeDesignControl)m_designView.ActiveView;
            RenderState         rs            = activeControl.RenderState;

            if (activeControl.RenderState != m_propGrid.SelectedObject)
            {
                m_propGrid.SelectedObject = activeControl.RenderState;
            }

            switch ((Command)commandTag)
            {
            case Command.RenderSmooth:
            case Command.RenderWireFrame:
            case Command.RenderOutlined:
            case Command.RenderLight:
            case Command.RenderBackFace:
            case Command.RenderShadow:
            case Command.RenderNormals:
            case Command.RenderCycle:
                //  case Command.RealTime:
                return(true);

            case Command.RenderTextured:
                return((rs.RenderFlag & GlobalRenderFlags.Solid) != 0);
            }

            return(false);
        }
Beispiel #3
0
        public NativeDesignView()
        {
            NativeDesignControl[] views = new NativeDesignControl[]
            {
                new NativeDesignControl(this, GameEngine.GetEditorSceneManager(), GameEngine.GlobalSelection) { ViewType = ViewTypes.Perspective },
                new NativeDesignControl(this, GameEngine.GetEditorSceneManager(), GameEngine.GlobalSelection) { ViewType = ViewTypes.Right },
                new NativeDesignControl(this, GameEngine.GetEditorSceneManager(), GameEngine.GlobalSelection) { ViewType = ViewTypes.Top },
                new NativeDesignControl(this, GameEngine.GetEditorSceneManager(), GameEngine.GlobalSelection) { ViewType = ViewTypes.Front }
            };
            foreach (var v in views)
            {
                v.AddRenderCallback(RenderCallback);
            }
            QuadView.TopLeft = views[0];
            QuadView.TopRight = views[1];
            QuadView.BottomLeft = views[2];
            QuadView.BottomRight = views[3];

            // set control names.
            QuadView.TopLeft.Name = "TopLeft";
            QuadView.TopRight.Name = "TopRight";
            QuadView.BottomLeft.Name = "BottomLeft";
            QuadView.BottomRight.Name = "BottomRight";

            ViewMode = ViewModes.Single;
            ContextChanged += NativeDesignView_ContextChanged;
        }
Beispiel #4
0
        /// <summary>
        /// Updates command state for given command</summary>
        /// <param name="commandTag">Command</param>
        /// <param name="state">Command state to update</param>
        public void UpdateCommand(object commandTag, Sce.Atf.Applications.CommandState state)
        {
            if (commandTag is Command)
            {
                NativeDesignControl control = (NativeDesignControl)m_designView.ActiveView;
                GlobalRenderFlags   flags   = control.RenderState.RenderFlag;
                switch ((Command)commandTag)
                {
                case Command.RenderSmooth:
                    state.Check = (flags & GlobalRenderFlags.Solid) != 0;
                    break;

                case Command.RenderWireFrame:
                    state.Check = (flags & GlobalRenderFlags.WireFrame) != 0;
                    break;

                case Command.RenderOutlined:
                    state.Check = (flags & GlobalRenderFlags.Solid) != 0 &&
                                  (flags & GlobalRenderFlags.WireFrame) != 0;
                    break;

                case Command.RenderTextured:
                    state.Check = (flags & GlobalRenderFlags.Textured) != 0;
                    break;

                case Command.RenderLight:
                    state.Check = ((flags & GlobalRenderFlags.Lit) != 0);
                    break;

                case Command.RenderBackFace:
                    state.Check = (flags & GlobalRenderFlags.RenderBackFace) != 0;
                    break;

                case Command.RenderShadow:
                    state.Check = (flags & GlobalRenderFlags.Shadows) == GlobalRenderFlags.Shadows;
                    break;

                case Command.RenderNormals:
                    state.Check = (flags & GlobalRenderFlags.RenderNormals) == GlobalRenderFlags.RenderNormals;
                    break;
                    // case Command.RealTime:
                    //      state.Check = m_designView.RealTime;
                }
            }
        }
Beispiel #5
0
        public NativeDesignView()
        {
            NativeDesignControl[] views = new NativeDesignControl[]
            {
                new NativeDesignControl(this)
                {
                    ViewType = ViewTypes.Perspective
                },
                new NativeDesignControl(this)
                {
                    ViewType = ViewTypes.Right
                },
                new NativeDesignControl(this)
                {
                    ViewType = ViewTypes.Top
                },
                new NativeDesignControl(this)
                {
                    ViewType = ViewTypes.Front
                }
            };
            foreach (var v in views)
            {
                v.Adapter.AddRenderCallback(
                    (GUILayer.SimpleRenderingContext context) => RenderCallback(this, v.Camera));
            }
            QuadView.TopLeft     = views[0];
            QuadView.TopRight    = views[1];
            QuadView.BottomLeft  = views[2];
            QuadView.BottomRight = views[3];

            // set control names.
            QuadView.TopLeft.Name     = "TopLeft";
            QuadView.TopRight.Name    = "TopRight";
            QuadView.BottomLeft.Name  = "BottomLeft";
            QuadView.BottomRight.Name = "BottomRight";



            ViewMode        = ViewModes.Single;
            ContextChanged += NativeDesignView_ContextChanged;
        }
Beispiel #6
0
        /// <summary>
        /// Can the client do the command?</summary>
        /// <param name="commandTag">Command</param>
        /// <returns>true, iff client can do the command</returns>
        public bool CanDoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return(false);
            }

            NativeDesignControl activeControl = (NativeDesignControl)m_designView.ActiveView;
            RenderState         rs            = activeControl.RenderState;

            var context = m_propertyGrid.PropertyGridView.EditingContext as RenderStateEditingContext;

            if (context == null || context.Item != rs)
            {
                context = new RenderStateEditingContext(rs);
                m_propertyGrid.Bind(context);
            }


            switch ((Command)commandTag)
            {
            case Command.RenderSmooth:
            case Command.RenderWireFrame:
            case Command.RenderOutlined:
            case Command.RenderLight:
            case Command.RenderBackFace:
            case Command.RenderShadow:
            case Command.RenderNormals:
            case Command.RenderCycle:
                //  case Command.RealTime:
                return(true);

            case Command.RenderTextured:
                return((rs.RenderFlag & GlobalRenderFlags.Solid) != 0);
            }

            return(false);
        }
Beispiel #7
0
        void BindToControl(NativeDesignControl ctrl)
        {
            var rs  = ctrl.RenderState;
            var cam = ctrl.Camera;

            {
                var context = m_rsPropertyGrid.GetGrid(0).PropertyGridView.EditingContext as RenderStateEditingContext;
                if (context == null || context.Item != rs)
                {
                    context = new RenderStateEditingContext(rs);
                    m_rsPropertyGrid.GetGrid(0).Bind(context);
                }
            }

            {
                var context = m_rsPropertyGrid.GetGrid(1).PropertyGridView.EditingContext as CameraEditingContext;
                if (context == null || context.Item != cam)
                {
                    context = new CameraEditingContext(cam);
                    m_rsPropertyGrid.GetGrid(1).Bind(context);
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Do a command</summary>
        /// <param name="commandTag">Command</param>
        public void DoCommand(object commandTag)
        {
            if (commandTag is Command)
            {
                NativeDesignControl control = (NativeDesignControl)m_designView.ActiveView;
                RenderState         rs      = control.RenderState;

                switch ((Command)commandTag)
                {
                case Command.RenderSmooth:
                    rs.RenderFlag &= ~(GlobalRenderFlags.WireFrame | GlobalRenderFlags.RenderBackFace);
                    rs.RenderFlag |= (GlobalRenderFlags.Solid | GlobalRenderFlags.Lit | GlobalRenderFlags.Textured);

                    break;

                case Command.RenderWireFrame:
                    rs.RenderFlag |= (GlobalRenderFlags.WireFrame);      //| RenderFlags.RenderBackFace
                    rs.RenderFlag &= ~(GlobalRenderFlags.Solid | GlobalRenderFlags.Lit | GlobalRenderFlags.Textured);

                    break;

                case Command.RenderOutlined:
                    rs.RenderFlag |= (GlobalRenderFlags.WireFrame | GlobalRenderFlags.Solid |
                                      GlobalRenderFlags.Lit | GlobalRenderFlags.Textured);
                    rs.RenderFlag &= ~GlobalRenderFlags.RenderBackFace;

                    break;

                case Command.RenderTextured:
                    rs.RenderFlag ^= GlobalRenderFlags.Textured;

                    break;

                case Command.RenderLight:
                    rs.RenderFlag ^= GlobalRenderFlags.Lit;

                    break;

                case Command.RenderBackFace:
                    rs.RenderFlag ^= GlobalRenderFlags.RenderBackFace;
                    break;

                case Command.RenderShadow:
                    rs.RenderFlag ^= GlobalRenderFlags.Shadows;
                    break;

                case Command.RenderNormals:
                    rs.RenderFlag ^= GlobalRenderFlags.RenderNormals;
                    break;

                case Command.RenderCycle:
                    GlobalRenderFlags flags = rs.RenderFlag;

                    if ((flags & GlobalRenderFlags.Solid) != 0 &&
                        (flags & GlobalRenderFlags.WireFrame) != 0)
                    {
                        // outlined -> smooth
                        goto case Command.RenderSmooth;
                    }
                    if ((flags & GlobalRenderFlags.Solid) != 0)
                    {
                        // smooth -> wireframe
                        goto case Command.RenderWireFrame;
                    }
                    // wireframe -> outlined
                    goto case Command.RenderOutlined;

                    //  case Command.RealTime:
                    //      m_designView.RealTime = !m_designView.RealTime;
                    //      break;
                }
                m_designView.ActiveView.Invalidate();
            }
        }