Пример #1
0
 public EditController()
 {
     CommandCombos.GetInstance().RegisterAtLeastCommand("increaseheight", new KeyCommandHandler(handler_IncreaseHeight));
     CommandCombos.GetInstance().RegisterAtLeastCommand("decreaseheight", new KeyCommandHandler(handler_DecreaseHeight));
     MetaverseClient.GetInstance().Tick     += new MetaverseClient.TickHandler(EditController_Tick);
     ViewerState.GetInstance().StateChanged += new ViewerState.StateChangedHandler(EditController_StateChanged);
 }
        public void ContextMenuProperties(object source, ContextMenuArgs e)
        {
            if (entitypropertiesdialog != null)
            {
                entitypropertiesdialog.Destroy();
            }

            LogFile.WriteLine("opening properties box ...");

            Glade.XML app = new Glade.XML(EnvironmentHelper.GetExeDirectory() + "/metaverse.client.glade", "entitypropertiesdialog", "");
            app.Autoconnect(this);

            PropertyInfos     = new List <EntityPropertyInfo>();
            ControlsIndex     = new Dictionary <string, Widget>();
            nextpropertyindex = 0;

            thisentity.RegisterProperties(this);
            LoadProperties();
            // Show();

            ViewerState.GetInstance().ActivateEdit3d();

            // hack to add a semblance of user-friendliness
            //DialogHelpers.ShowInfoMessageModal(null, "Hold down z to move the object, x to change scale and v to rotate.");
            new MessageBox(MessageBox.MessageType.Info, "Editing controls", "Hold down z to move the object, x to change scale and v to rotate.", null);

            entitypropertiesdialog.ShowAll();
            //entitypropertiesdialog.Show();

            selectionmodel.Clear();
            selectionmodel.ToggleObjectInSelection(thisentity, true);
            LogFile.WriteLine("...opened");
        }
Пример #3
0
 void MainTerrainWindow_KeyDown(string keyname)
 {
     if (keyname.ToLower() == "t")
     {
         //ShowWindow();
         ViewerState.GetInstance().ActivateEditTerrain();
     }
 }
 public UIEntityPropertiesDialog()
 {
     selectionmodel = SelectionModel.GetInstance();
     ContextMenuController.GetInstance().ContextMenuPopup += new ContextMenuHandler(_ContextMenuPopup);
     ViewerState.GetInstance().StateChanged += new ViewerState.StateChangedHandler(UIEntityPropertiesDialog_StateChanged);
     //    SetFormSize();
     //KeyNameCache.GetInstance().KeyDown += new KeyNameCache.KeyDownHandler( UIEntityPropertiesDialog_KeyDown );
 }
Пример #5
0
        //DateTime inittime;
        //bool opened = false;
        //void MainTerrainWindow_Tick()
        //{
        //  if (!opened && DateTime.Now.Subtract( inittime ).TotalMilliseconds > 5000)
        //{
        //  ShowWindow();
        //opened = false;
        //}
        //}

        void mainwindow_Destroyed(object sender, EventArgs e)
        {
            ViewerState.GetInstance().FinishEditTerrain();
            Glade.XML app = new Glade.XML(EnvironmentHelper.GetExeDirectory() + "/TerrainEditing.glade", "mainwindow", "");
            app.Autoconnect(this);
            windowshown = true;
            HideWindow();
            mainwindow.Destroyed += new EventHandler(mainwindow_Destroyed);
        }
Пример #6
0
 void PlayerMovement_MouseMove()
 {
     //LogFile.WriteLine("PlayerMovement.MouseMove " + bcapturing);
     //if ( InMouseMoveDrag &&
     //   ViewerState.GetInstance().CurrentViewerState == ViewerState.ViewerStateEnum.MouseLook)
     if (ViewerState.GetInstance().CurrentViewerState == ViewerState.ViewerStateEnum.MouseLook)
     {
         avatarzrot = startavatarzrot - (double)(MouseCache.GetInstance().MouseX - istartmousex) * fAvatarTurnSpeed;
         avataryrot = Math.Min(Math.Max(startavataryrot + (double)(MouseCache.GetInstance().MouseY - istartmousey) * fAvatarTurnSpeed, -90), 90);
         UpdateAvatarObjectRotAndPos();
     }
 }
Пример #7
0
 void handler_DecreaseHeight(string command, bool down)
 {
     //LogFile.WriteLine("EditController.handler_decreaseheight");
     if (down)
     {
         if (ViewerState.GetInstance().CurrentViewerState == ViewerState.ViewerStateEnum.Terrain)
         {
             LastDateTime   = DateTime.Now;
             decreaseheight = true;
             ApplyBrush(true);
         }
     }
     else
     {
         decreaseheight = false;
     }
 }
Пример #8
0
        public PlayerMovement()
        {
            Test.Debug("instantiating PlayerMovement()");

            Config config = Config.GetInstance();

            //XmlElement minnode = (XmlElement)config.clientconfig.SelectSingleNode("worldboundingboxmin");
            //XmlElement maxnode =(XmlElement) config.clientconfig.SelectSingleNode("worldboundingboxmax");
            WorldBoundingBoxMin = new Vector3(0, 0, config.mingroundheight);
            WorldBoundingBoxMax = new Vector3(config.world_xsize, config.world_ysize, config.ceiling);
            Test.WriteOut(WorldBoundingBoxMin);
            Test.WriteOut(WorldBoundingBoxMax);

            XmlElement movementnode = (XmlElement)config.clientconfig.SelectSingleNode("movement");

            fAvatarAcceleration = Convert.ToDouble(movementnode.GetAttribute("acceleration"));
            fAvatarTurnSpeed    = Convert.ToDouble(movementnode.GetAttribute("turnspeed"));
            fAvatarMoveSpeed    = Convert.ToDouble(movementnode.GetAttribute("movespeed"));
            fVerticalMoveSpeed  = Convert.ToDouble(movementnode.GetAttribute("verticalmovespeed"));
            fDeceleration       = Convert.ToDouble(movementnode.GetAttribute("deceleration"));

            camera = Camera.GetInstance();
            //KeyFilterComboKeys keyfiltercombokeys = KeyFilterComboKeys.GetInstance();

            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "moveleft", new KeyCommandHandler(MoveLeft));
            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "moveright", new KeyCommandHandler(MoveRight));
            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "movebackwards", new KeyCommandHandler(MoveBackwards));
            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "moveforwards", new KeyCommandHandler(MoveForwards));
            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "moveup", new KeyCommandHandler(MoveUp));
            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "movedown", new KeyCommandHandler(MoveDown));

            ViewerState.GetInstance().StateChanged += new ViewerState.StateChangedHandler(PlayerMovement_StateChanged);
            MouseCache.GetInstance().MouseMove += new MouseMoveHandler(PlayerMovement_MouseMove);
            MetaverseClient.GetInstance().worldstorage.terrainmodel.TerrainModified += new TerrainModel.TerrainModifiedHandler(terrainmodel_TerrainModified);

            timekeeper = new TimeKeeper();

            Test.Debug("PlayerMovement instantiated");
        }
Пример #9
0
        MainTerrainWindow()
        {
            Glade.XML app = new Glade.XML(EnvironmentHelper.GetExeDirectory() + "/TerrainEditing.glade", "mainwindow", "");
            app.Autoconnect(this);
            //raiselower.Activate();
            MetaverseClient.GetInstance().worldstorage.terrainmodel.TerrainModified += new TerrainModel.TerrainModifiedHandler(MainUIWindow_TerrainModified);
            HideWindow();

            mainwindow.Destroyed += new EventHandler(mainwindow_Destroyed);
            ViewerState.GetInstance().StateChanged += new ViewerState.StateChangedHandler(MainTerrainWindow_StateChanged);

            ContextMenuController.GetInstance().RegisterPersistentContextMenu(new string[] { "Edit Terrain..." },
                                                                              new ContextMenuHandler(EditTerrainContextMenuHandler));

            //inittime = DateTime.Now;
            //MetaverseClient.GetInstance().Tick += new MetaverseClient.TickHandler( MainTerrainWindow_Tick );
            KeyNameCache.GetInstance().KeyDown += new KeyNameCache.KeyDownHandler(MainTerrainWindow_KeyDown);
        }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="IsInitialMouseclick">When mouse button is initially pressed, this is true.</param>
        void ApplyBrush(bool IsInitialMouseclick)
        {
            if (!(increaseheight || decreaseheight))
            {
                return;
            }

            if (ViewerState.GetInstance().CurrentViewerState != ViewerState.ViewerStateEnum.Terrain)
            {
                return;
            }

            if (CurrentEditBrush.GetInstance().BrushEffect == null ||
                CurrentEditBrush.GetInstance().BrushShape == null)
            {
                return;
            }

            if (!(IsInitialMouseclick || CurrentEditBrush.GetInstance().BrushEffect.Repeat))
            {
                return;
            }

            Vector3 intersectpoint = EditingHelper.GetIntersectPoint();

            if (intersectpoint == null)
            {
                return;
            }

            double x = intersectpoint.x;
            double y = intersectpoint.y;

            if (x >= 0 && y >= 0 &&
                x < (MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightMapWidth) &&
                y < (MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightMapHeight))
            {
                double milliseconds = DateTime.Now.Subtract(LastDateTime).TotalMilliseconds;
                LastDateTime = DateTime.Now;
                CurrentEditBrush.GetInstance().BrushEffect.ApplyBrush(
                    CurrentEditBrush.GetInstance().BrushShape, CurrentEditBrush.GetInstance().BrushSize,
                    x, y, increaseheight, milliseconds);
            }
        }
Пример #11
0
        void CurrentEditSpot_WriteNextFrameEvent(Vector3 camerapos)
        {
            if (ViewerState.GetInstance().CurrentViewerState != ViewerState.ViewerStateEnum.Terrain)
            {
                return;
            }
            Vector3 intersectpoint = EditingHelper.GetIntersectPoint();

            if (intersectpoint != null)
            {
                double distancefromcamera = (intersectpoint - camerapos).Det();
                GraphicsHelperFactory.GetInstance().SetMaterialColor(new Color(0, 0, 1));
                Gl.glPushMatrix();
                Gl.glTranslated(intersectpoint.x, intersectpoint.y, intersectpoint.z + 0.01 * distancefromcamera);
                Gl.glScaled(0.01 * distancefromcamera, 0.01 * distancefromcamera, 0.01 * distancefromcamera);
                GraphicsHelperFactory.GetInstance().DrawSphere();
                Gl.glPopMatrix();
            }
        }
Пример #12
0
        //const string CMD_ZOOM = "camerazoom";
        //const string CMD_PAN = "camerapan";
        //const string CMD_ORBIT = "cameraorbit";

        public Camera()
        {
            MouseCache mousefiltermousecache = MouseCache.GetInstance();

            ViewerState.GetInstance().StateChanged += new ViewerState.StateChangedHandler(Camera_StateChanged);

            //  CommandCombos.GetInstance().RegisterCommandGroup(
            //    new string[]{ CMD_ZOOM, CMD_PAN, CMD_ORBIT }, new KeyCommandHandler(CameraModeHandler));
            //CommandCombos.GetInstance().RegisterCommand(
            //  "cameraorbit", new KeyCommandHandler(CameraModeOrbitHandler));
            //CommandCombos.GetInstance().RegisterCommand(
            //  "camerapan", new KeyCommandHandler(CamerModePanHandler));
            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "toggleviewpoint", new KeyCommandHandler(ToggleViewpointHandler));
            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "leftmousebutton", new KeyCommandHandler(MouseDown));
            MouseCache.GetInstance().MouseMove += new MouseMoveHandler(Camera_MouseMove);

            RendererFactory.GetInstance().PreDrawEvent += new PreDrawCallback(Camera_PreDrawEvent);
        }
Пример #13
0
        void BrushShapeController_WriteNextFrameEvent(Vector3 camerapos)
        {
            if (ViewerState.GetInstance().CurrentViewerState == ViewerState.ViewerStateEnum.Terrain)
            {
                if (CurrentEditBrush.GetInstance().BrushShape != null)
                {
                    if (CurrentEditBrush.GetInstance().BrushEffect.Repeat)
                    {
                        Vector3 intersectpos = EditingHelper.GetIntersectPoint();
                        if (intersectpos == null)
                        {
                            return;
                        }

                        Gl.glDisable(Gl.GL_LIGHTING);
                        Gl.glColor3ub(0, 255, 200);
                        CurrentEditBrush.GetInstance().BrushShape.Render(intersectpos);
                        Gl.glColor3ub(255, 255, 255);
                        Gl.glEnable(Gl.GL_LIGHTING);
                    }
                }
            }
        }
Пример #14
0
 public void MouseDown(string command, bool down)
 {
     if (ViewerState.GetInstance().CurrentViewerState == ViewerState.ViewerStateEnum.Edit3d)
     {
         InEditDrag = down;
         if (down)
         {
             if (editbartype == EditBarType.Pos)
             {
                 InitiateTranslateEdit(mousefiltermousecache.MouseX, mousefiltermousecache.MouseY);
             }
             else if (editbartype == EditBarType.Rot)
             {
                 InitiateRotateEdit(mousefiltermousecache.MouseX, mousefiltermousecache.MouseY);
             }
             else if (editbartype == EditBarType.Scale)
             {
                 InitiateScaleEdit(mousefiltermousecache.MouseX, mousefiltermousecache.MouseY);
             }
         }
         else
         {
             if (editbartype != EditBarType.None)
             {
                 EditDone();
             }
         }
     }
     else
     {
         if (editbartype != EditBarType.None)
         {
             EditDone();
         }
         InEditDrag = false;
     }
 }
 void UIEntityPropertiesDialog_StateChanged(ViewerState.ViewerStateEnum currenteditstate, ViewerState.ViewerStateEnum newviewstate)
 {
     if (currenteditstate != ViewerState.ViewerStateEnum.Edit3d)
     {
         if (entitypropertiesdialog != null)
         {
             entitypropertiesdialog.Destroy();
             entitypropertiesdialog = null;
         }
     }
 }
Пример #16
0
        void Camera_StateChanged(ViewerState.ViewerStateEnum neweditstate, ViewerState.ViewerStateEnum newviewstate)
        {
            switch (newviewstate)
            {
                case ViewerState.ViewerStateEnum.CameraOrbit:
                    CurrentMove = CameraMoveType.Orbit;
                    break;

                case ViewerState.ViewerStateEnum.CameraPan:
                    CurrentMove = CameraMoveType.Pan;
                    break;

                case ViewerState.ViewerStateEnum.CameraZoom:
                    CurrentMove = CameraMoveType.AltZoom;
                    break;

                default:
                    CurrentMove = CameraMoveType.Pan;
                    break;
            }
        }
Пример #17
0
        void PlayerMovement_StateChanged(ViewerState.ViewerStateEnum neweditstate, ViewerState.ViewerStateEnum newviewstate)
        {
            //bcapturing = down;

            if (newviewstate == ViewerState.ViewerStateEnum.MouseLook)
            {
                LogFile.WriteLine("PlayerMovement.ActivateMouseLook");
                istartmousex = MouseCache.GetInstance().MouseX;
                istartmousey = MouseCache.GetInstance().MouseY;
                startavatarzrot = avatarzrot;
                startavataryrot = avataryrot;
            }
            else
            {
            }
        }
Пример #18
0
 void EditTerrainContextMenuHandler(object o, ContextMenuArgs e)
 {
     ViewerState.GetInstance().ActivateEditTerrain();
     //mainwindow.Show();
 }
Пример #19
0
 void EditController_StateChanged(ViewerState.ViewerStateEnum neweditstate, ViewerState.ViewerStateEnum newviewstate)
 {
 }
Пример #20
0
 void MainTerrainWindow_StateChanged( ViewerState.ViewerStateEnum currenteditstate, ViewerState.ViewerStateEnum newviewstate)
 {
     if (currenteditstate == ViewerState.ViewerStateEnum.Terrain)
     {
         ShowWindow();
     }
     else
     {
         HideWindow();
     }
 }