예제 #1
0
 private void treeView1_AfterSelect_1(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Tag != null)
     {
         propertyGrid1.SelectedObject = e.Node.Tag;
         if (e.Node.Tag is GameObject)
         {
             SceneEditorGame seg = (SceneEditorGame)apxCtrl.Game;
             seg.objectHolding = (GameObject)e.Node.Tag;
         }
     }
 }
예제 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (MetroUI.DesignMode == false)
            {
                MetroUI.Style.PropertyChanged += Style_PropertyChanged;
                MetroUI.Style.DarkStyle        = true;
            }
            ImageList ilist1 = new ImageList();

            ilist1.Images.Add(Properties.Resources.node_16);
            ilist1.Images.Add(Properties.Resources.geometry_16);
            ilist1.Images.Add(Properties.Resources.material);
            treeView1.ImageList = ilist1;

            SceneEditorGame game = new SceneEditorGame();

            //  game.Camera = new ApexEngine.Rendering.Cameras.DefaultCamera(game.InputManager, 75);
            game.Camera.Translation = new ApexEngine.Math.Vector3f(0, 2, 0);
            game.Camera.Enabled     = false;
            apxCtrl      = new ApexEngineControl(game);
            apxCtrl.Dock = DockStyle.Fill;
            pnlGameView.Controls.Add(apxCtrl);


            contextMenuStrip1.Renderer = new metroToolStripRenderer();
            metroMenuStrip2.Renderer   = new metroToolStripRenderer();



            PopulateTreeView(game.RootNode);

            /*
             *
             * SceneEditorGame orthoTop = new SceneEditorGame();
             * //  orthoTop.Camera = new ApexEngine.Rendering.Cameras.OrthoCamera(-5, 5, -5, 5, -5, 5);
             * orthoTop.Camera.Translation = new ApexEngine.Math.Vector3f(0, 0, -5);
             * // orthoTop.RenderManager.GeometryList = game.RenderManager.GeometryList;
             * ApexEngineControl orthoTopCtrl = new ApexEngineControl(orthoTop);
             * orthoTopCtrl.Dock = DockStyle.Fill;
             * pnlOrthoTop.Controls.Add(orthoTopCtrl);*/
            apxCtrl.MouseWheel += new MouseEventHandler(MouseScroll);
        }
예제 #3
0
        private void MouseScroll(object sender, MouseEventArgs e)
        {
            float           diff = ((float)e.Delta) * 0.1f;
            SceneEditorGame seg  = (SceneEditorGame)apxCtrl.Game;

            /* if (camMode == SceneEditorGame.CamModes.Grab)
             * {
             *   if (seg.objectHolding != null)
             *   {
             *    //   Vector3f ctrans = new Vector3f(seg.objectHolding.GetWorldTranslation());
             *
             *    //   ctrans.AddStore(seg.Camera.Direction.Multiply(diff));
             *       seg.objectHolding.SetLocalTranslation(seg.Camera.Translation.Add(seg.Camera.Direction.Multiply(diff)));
             *   }
             * }*/
            if (camMode == SceneEditorGame.CamModes.Rotate)
            {
                if (seg.objectHolding != null)
                {
                    seg.objectHolding.SetLocalRotation(seg.objectHolding.GetLocalRotation().Multiply(new Quaternion().SetFromAxis(rotateAxis, diff)));
                    Console.WriteLine(seg.objectHolding.GetLocalRotation());
                }
            }
        }
예제 #4
0
 private void SetCamMode(SceneEditorGame.CamModes camMode)
 {
     this.camMode = camMode;
     checkBox1.Checked = (camMode == SceneEditorGame.CamModes.Freelook);
     checkBox2.Checked = (camMode == SceneEditorGame.CamModes.Grab);
     checkBox3.Checked = (camMode == SceneEditorGame.CamModes.Rotate);
     ((SceneEditorGame)apxCtrl.Game).CamMode = camMode;
 }
예제 #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (MetroUI.DesignMode == false)
            {
                MetroUI.Style.PropertyChanged += Style_PropertyChanged;
                MetroUI.Style.DarkStyle = true;
            }
            ImageList ilist1 = new ImageList();
            ilist1.Images.Add(Properties.Resources.node_16);
            ilist1.Images.Add(Properties.Resources.geometry_16);
            ilist1.Images.Add(Properties.Resources.material);
            treeView1.ImageList = ilist1;

            SceneEditorGame game = new SceneEditorGame();
            //  game.Camera = new ApexEngine.Rendering.Cameras.DefaultCamera(game.InputManager, 75);
            game.Camera.Translation = new ApexEngine.Math.Vector3f(0, 2, 0);
            game.Camera.Enabled = false;
            apxCtrl = new ApexEngineControl(game);
            apxCtrl.Dock = DockStyle.Fill;
            pnlGameView.Controls.Add(apxCtrl);

            contextMenuStrip1.Renderer = new metroToolStripRenderer();
            metroMenuStrip2.Renderer = new metroToolStripRenderer();

            PopulateTreeView(game.RootNode);
            /*

            SceneEditorGame orthoTop = new SceneEditorGame();
              //  orthoTop.Camera = new ApexEngine.Rendering.Cameras.OrthoCamera(-5, 5, -5, 5, -5, 5);
            orthoTop.Camera.Translation = new ApexEngine.Math.Vector3f(0, 0, -5);
               // orthoTop.RenderManager.GeometryList = game.RenderManager.GeometryList;
            ApexEngineControl orthoTopCtrl = new ApexEngineControl(orthoTop);
            orthoTopCtrl.Dock = DockStyle.Fill;
            pnlOrthoTop.Controls.Add(orthoTopCtrl);*/
            apxCtrl.MouseWheel += new MouseEventHandler(MouseScroll);
        }
예제 #6
0
        private void renderboundingBoxesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SceneEditorGame seg = (SceneEditorGame)apxCtrl.Game;

            seg.BoundingBoxes = renderboundingBoxesToolStripMenuItem.Checked;
        }
예제 #7
0
        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            SceneEditorGame seg = (SceneEditorGame)apxCtrl.Game;

            seg.Centered = checkBox4.Checked;
        }
예제 #8
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            SceneEditorGame seg = (SceneEditorGame)apxCtrl.Game;

            if (e.KeyCode == Keys.C)
            {
                seg.Centered = !seg.Centered;
                Console.WriteLine("Centered: " + seg.Centered);
                checkBox4.Checked = seg.Centered;
                if (seg.Centered)
                {
                    //   if (seg.objectHolding != null)
                    //    {
                    //       Vector3f diff = seg.objectHolding.GetLocalTranslation().Subtract(objectHolding.)
                    // }


                    if (seg.objectHolding != null)
                    {
                        seg.objectHolding.SetLocalTranslation(seg.objectHolding.GetLocalTranslation().Subtract(seg.objectHolding.GetLocalBoundingBox().Center.Subtract(new Vector3f(0f, seg.objectHolding.GetLocalBoundingBox().Center.Y, 0f))));
                    }
                }
                else
                {
                    if (seg.objectHolding != null)
                    {
                        seg.objectHolding.SetLocalTranslation(seg.objectHolding.GetLocalTranslation().Add(seg.objectHolding.GetLocalBoundingBox().Center.Subtract(new Vector3f(0f, seg.objectHolding.GetLocalBoundingBox().Center.Y, 0f))));
                    }
                }
            }
            else if (e.KeyCode == Keys.F)
            {
                this.SetCamMode(SceneEditorGame.CamModes.Freelook);
            }
            else if (e.KeyCode == Keys.G)
            {
                this.SetCamMode(SceneEditorGame.CamModes.Grab);
            }
            else if (e.KeyCode == Keys.R)
            {
                this.SetCamMode(SceneEditorGame.CamModes.Rotate);
            }
            else if (e.KeyCode == Keys.X)
            {
                if (camMode == SceneEditorGame.CamModes.Grab)
                {
                    seg.MovingX = !seg.MovingX;
                    seg.MovingY = false;
                    seg.MovingZ = false;
                    if (!seg.MovingX)
                    {
                        seg.lastMouseX = seg.InputManager.GetMouseX();
                        seg.lastMouseY = seg.InputManager.GetMouseY();
                    }
                    if (seg.objectHolding != null)
                    {
                        seg.offsetLoc.Set(seg.objectHolding.GetWorldTranslation());
                        //  Vector2f proj = apxCtrl.Game.Camera.Project(seg.objectHolding.GetWorldTranslation());
                    }
                }
                else if (camMode == SceneEditorGame.CamModes.Rotate)
                {
                    rotateAxis.Set(Vector3f.UnitX);
                }
            }
            else if (e.KeyCode == Keys.Y)
            {
                if (camMode == SceneEditorGame.CamModes.Grab)
                {
                    seg.MovingY = !seg.MovingY;
                    seg.MovingX = false;
                    seg.MovingZ = false;
                    if (!seg.MovingY)
                    {
                        seg.lastMouseX = seg.InputManager.GetMouseX();
                        seg.lastMouseY = seg.InputManager.GetMouseY();
                    }
                    if (seg.objectHolding != null)
                    {
                        seg.offsetLoc.Set(seg.objectHolding.GetWorldTranslation());
                        //  Vector2f proj = apxCtrl.Game.Camera.Project(seg.objectHolding.GetWorldTranslation());
                    }
                }
                else if (camMode == SceneEditorGame.CamModes.Rotate)
                {
                    rotateAxis.Set(Vector3f.UnitY);
                }
            }
            else if (e.KeyCode == Keys.Z)
            {
                if (camMode == SceneEditorGame.CamModes.Grab)
                {
                    seg.MovingZ = !seg.MovingZ;
                    seg.MovingY = false;
                    seg.MovingX = false;
                    if (!seg.MovingZ)
                    {
                        seg.lastMouseX = seg.InputManager.GetMouseX();
                        seg.lastMouseY = seg.InputManager.GetMouseY();
                    }
                    if (seg.objectHolding != null)
                    {
                        //  Vector2f proj = apxCtrl.Game.Camera.Project(seg.objectHolding.GetWorldTranslation());
                    }
                }
                else if (camMode == SceneEditorGame.CamModes.Rotate)
                {
                    rotateAxis.Set(Vector3f.UnitZ);
                }
            }
        }