Пример #1
0
        public NativeDesignControl(DesignView designView) :
            base(designView)
        {
            ClientSize = new Size(10, 10);
            if (!GameEngine.IsInError)
            {
                swapChainId = GameEngine.GetObjectTypeId("SwapChain");
                SurfaceId = GameEngine.CreateObject(swapChainId, this.Handle, IntPtr.Size);
                SizePropId = GameEngine.GetObjectPropertyId(swapChainId, "Size");
                GameEngine.SetObjectProperty(swapChainId, SurfaceId, SizePropId, ClientSize);
                BkgColorPropId = GameEngine.GetObjectPropertyId(swapChainId, "BkgColor");
                GameEngine.SetObjectProperty(swapChainId, SurfaceId, BkgColorPropId, BackColor);
                
            }
            if (s_marqueePen == null)
            {
                s_marqueePen = new Pen(Color.FromArgb(30, 30, 30), 2);
                s_marqueePen.DashPattern = new float[] { 3, 3 };
            }

            m_renderState = new RenderState();
            m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit | GlobalRenderFlags.Shadows;
            m_renderState.WireFrameColor = Color.DarkBlue;
            m_renderState.SelectionColor = Color.FromArgb(66, 255, 161);
            BackColor = SystemColors.ControlDark;
            m_renderState.Changed += (sender, e) => Invalidate();
        }
Пример #2
0
        public NativeDesignControl(DesignView designView, GUILayer.EditorSceneManager sceneManager, GUILayer.ObjectSet selection)
            : base(designView, sceneManager, selection)
        {
            if (s_marqueePen == null)
            {
                s_marqueePen = new Pen(Color.FromArgb(30, 30, 30), 2);
                s_marqueePen.DashPattern = new float[] { 3, 3 };
            }

            m_renderState = new RenderState();
            m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit | GlobalRenderFlags.Shadows;
            m_renderState.WireFrameColor = Color.DarkBlue;
            m_renderState.SelectionColor = Color.FromArgb(66, 255, 161);
            BackColor = SystemColors.ControlDark;
            m_renderState.OnChanged += (sender, e) => Invalidate();

            base.AddRenderCallback(RenderExtras);
        }
Пример #3
0
        private void Init()
        {
            NativeObjectAdapter curLevel = GameEngine.GetGameLevel();
            try
            {
                // create new document by creating a Dom node of the root type defined by the schema                 
                DomNode rootNode = new DomNode(m_schemaLoader.GameType, m_schemaLoader.GameRootElement);
                INameable nameable = rootNode.Cast<INameable>();
                nameable.Name = "ThumbnailGenerator";

                NativeObjectAdapter gameLevel = rootNode.Cast<NativeObjectAdapter>();
                GameEngine.CreateObject(gameLevel);
                GameEngine.SetGameLevel(gameLevel);
                gameLevel.UpdateNativeOjbect();
                NativeGameWorldAdapter gworld = rootNode.Cast<NativeGameWorldAdapter>();

                m_game = rootNode.Cast<IGame>();
                IGameObjectFolder rootFolder = m_game.RootGameObjectFolder;                
                m_renderSurface = new TextureRenderSurface(96, 96);
                m_renderState = new RenderState();
                m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit | GlobalRenderFlags.Shadows;


            }
            finally
            {
                GameEngine.SetGameLevel(curLevel);
            }


            m_mainWindow.Closed += delegate
            {
                GameEngine.DestroyObject(m_game.Cast<NativeObjectAdapter>());
                m_renderSurface.Dispose();
                m_renderState.Dispose();
            };

        }
Пример #4
0
 public static void SetRenderState(RenderState renderState)
 {
     GameEngine.NativeSetRenderState(renderState.InstanceId);
 }
Пример #5
0
            public NativeViewControl()
            {
                ClientSize = new Size(16, 16);
                if (!GameEngine.IsInError)
                {
                    swapChainId = GameEngine.GetObjectTypeId("SwapChain");
                    SurfaceId = GameEngine.CreateObject(swapChainId, this.Handle, IntPtr.Size);
                    SizePropId = GameEngine.GetObjectPropertyId(swapChainId, "Size");
                    GameEngine.SetObjectProperty(swapChainId, SurfaceId, SizePropId, ClientSize);
                    BkgColorPropId = GameEngine.GetObjectPropertyId(swapChainId, "BkgColor");
                    GameEngine.SetObjectProperty(swapChainId, SurfaceId, BkgColorPropId, BackColor);

                }

                m_renderState = new RenderState();
                m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit;
                m_renderState.WireFrameColor = Color.DarkBlue;
                m_renderState.SelectionColor = Color.FromArgb(66, 255, 161);
                BackColor = SystemColors.ControlDark;


                #region Context menu
                GlobalRenderFlags[] flags = new GlobalRenderFlags[] 
                {
                    GlobalRenderFlags.Solid,
                    GlobalRenderFlags.WireFrame,
                    GlobalRenderFlags.Textured, 
                    GlobalRenderFlags.RenderBackFace,
                    GlobalRenderFlags.Lit
                };
                ContextMenuStrip cntx = new ContextMenuStrip();
                foreach (var flag in flags)
                {
                    ToolStripMenuItem item =
                        new ToolStripMenuItem(flag.ToString());
                    item.Tag = flag;
                    item.Click += delegate(object sender, EventArgs e)
                    {
                        ToolStripMenuItem menu = (ToolStripMenuItem)sender;
                        RenderState.RenderFlag = RenderState.RenderFlag ^ (GlobalRenderFlags)menu.Tag;
                        this.Invalidate();
                    };

                    cntx.Items.Add(item);
                }



                cntx.Items.Add(new ToolStripSeparator());
                ToolStripMenuItem views = new ToolStripMenuItem("View");
                cntx.Items.Add(views);
                views.DropDownOpening += delegate
                {
                    foreach (ToolStripMenuItem item in views.DropDownItems)
                    {
                        item.Checked = (ViewType == (ViewTypes)item.Tag);
                    }
                };

                foreach (var val in Enum.GetValues(typeof(ViewTypes)))
                {
                    ViewTypes viewtype = (ViewTypes)val;
                    ToolStripMenuItem item = new ToolStripMenuItem(viewtype.ToString());
                    item.Tag = viewtype;
                    item.Click += delegate(object sender, EventArgs e)
                    {
                        ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
                        this.ViewType = (ViewTypes)menuItem.Tag;
                    };

                    views.DropDownItems.Add(item);
                }


                cntx.Opening += delegate
                {
                    GlobalRenderFlags renderflags = RenderState.RenderFlag;
                    foreach (ToolStripItem item in cntx.Items)
                    {
                        if (item is ToolStripSeparator) break;
                        ((ToolStripMenuItem)item).Checked = (renderflags & (GlobalRenderFlags)item.Tag) != 0;
                    }
                };

                this.ContextMenuStrip = cntx;
                #endregion
            }
Пример #6
0
 public RenderStateEditingContext(RenderState rs)
 {
     m_items[0] = rs;
 }
Пример #7
0
            public NativeViewControl()
            {
                ClientSize = new Size(16, 16);
                if (!GameEngine.IsInError)
                {
                    swapChainId = GameEngine.GetObjectTypeId("SwapChain");
                    SurfaceId   = GameEngine.CreateObject(swapChainId, this.Handle, IntPtr.Size);
                    SizePropId  = GameEngine.GetObjectPropertyId(swapChainId, "Size");
                    GameEngine.SetObjectProperty(swapChainId, SurfaceId, SizePropId, ClientSize);
                    BkgColorPropId = GameEngine.GetObjectPropertyId(swapChainId, "BkgColor");
                    GameEngine.SetObjectProperty(swapChainId, SurfaceId, BkgColorPropId, BackColor);
                }

                m_renderState                = new RenderState();
                m_renderState.RenderFlag     = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit;
                m_renderState.WireFrameColor = Color.DarkBlue;
                m_renderState.SelectionColor = Color.FromArgb(66, 255, 161);
                BackColor = SystemColors.ControlDark;


                #region Context menu
                GlobalRenderFlags[] flags = new GlobalRenderFlags[]
                {
                    GlobalRenderFlags.Solid,
                    GlobalRenderFlags.WireFrame,
                    GlobalRenderFlags.Textured,
                    GlobalRenderFlags.RenderBackFace,
                    GlobalRenderFlags.Lit
                };
                ContextMenuStrip cntx = new ContextMenuStrip();
                foreach (var flag in flags)
                {
                    ToolStripMenuItem item =
                        new ToolStripMenuItem(flag.ToString());
                    item.Tag    = flag;
                    item.Click += delegate(object sender, EventArgs e)
                    {
                        ToolStripMenuItem menu = (ToolStripMenuItem)sender;
                        RenderState.RenderFlag = RenderState.RenderFlag ^ (GlobalRenderFlags)menu.Tag;
                        this.Invalidate();
                    };

                    cntx.Items.Add(item);
                }



                cntx.Items.Add(new ToolStripSeparator());
                ToolStripMenuItem views = new ToolStripMenuItem("View");
                cntx.Items.Add(views);
                views.DropDownOpening += delegate
                {
                    foreach (ToolStripMenuItem item in views.DropDownItems)
                    {
                        item.Checked = (ViewType == (ViewTypes)item.Tag);
                    }
                };

                foreach (var val in Enum.GetValues(typeof(ViewTypes)))
                {
                    ViewTypes         viewtype = (ViewTypes)val;
                    ToolStripMenuItem item     = new ToolStripMenuItem(viewtype.ToString());
                    item.Tag    = viewtype;
                    item.Click += delegate(object sender, EventArgs e)
                    {
                        ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
                        this.ViewType = (ViewTypes)menuItem.Tag;
                    };

                    views.DropDownItems.Add(item);
                }


                cntx.Opening += delegate
                {
                    GlobalRenderFlags renderflags = RenderState.RenderFlag;
                    foreach (ToolStripItem item in cntx.Items)
                    {
                        if (item is ToolStripSeparator)
                        {
                            break;
                        }
                        ((ToolStripMenuItem)item).Checked = (renderflags & (GlobalRenderFlags)item.Tag) != 0;
                    }
                };

                this.ContextMenuStrip = cntx;
                #endregion
            }
Пример #8
0
 public static void SetRenderState(RenderState renderState)
 {
     GameEngine.NativeSetRenderState(renderState.InstanceId);
 }
Пример #9
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;
                }
                control.Invalidate();
                m_propGrid.Refresh();
            }
        }