Example #1
0
        void OpenContextMenu()
        {
            if (contextmenu != null)
            {
                contextmenu.Destroy();
            }

            contextmenu = new Menu();

            //MenuItem submenuitem = new MenuItem("About TestPlugin...");
            //submenuitem.Activated += new EventHandler(Testpluginmenuitem_Activated);
            //contextmenu.Add(submenuitem);
            //contextmenu.Add(new MenuItem("item3"));

            MouseCache mousefiltermousecache = MouseCache.GetInstance();

            iMouseX = mousefiltermousecache.MouseX;
            iMouseY = mousefiltermousecache.MouseY;

            entity = Picker3dController.GetInstance().GetClickedEntity(iMouseX, iMouseY);

            contextmenucommanditems = new List <MenuItem>();
            contextmenucallbacks    = new List <ContextMenuHandler>();

            ContextMenuController.GetInstance().OnContextMenuPopup(this, new ContextMenuArgs(iMouseX, iMouseY, entity));

            AddPersistentItems();

            contextmenu.ShowAll();
            contextmenu.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
            LogFile.WriteLine("after contextmenu popup");
        }
Example #2
0
 public UIContextMenu()
 {
     MouseCache.GetInstance().MouseDown += new MouseButtonEventHandler(UIContextMenu_MouseDown);
     //CommandCombos.GetInstance().RegisterExactCommand("contextmenu", new KeyCommandHandler(
     //ContextMenuCommand));
     MouseCache.GetInstance().MouseUp += new MouseButtonEventHandler(UIContextMenu_MouseUp);
 }
Example #3
0
 public KeyNameCache()
 {
     SdlKeyCache.GetInstance().KeyDown  += new SdlDotNet.KeyboardEventHandler(KeyNameCache_KeyDown);
     SdlKeyCache.GetInstance().KeyUp    += new SdlDotNet.KeyboardEventHandler(KeyNameCache_KeyUp);
     MouseCache.GetInstance().MouseDown += new SdlDotNet.MouseButtonEventHandler(KeyNameCache_MouseDown);
     MouseCache.GetInstance().MouseUp   += new SdlDotNet.MouseButtonEventHandler(KeyNameCache_MouseUp);
 }
Example #4
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();
     }
 }
Example #5
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
            {
            }
        }
Example #6
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");
        }
Example #7
0
        public Editing3d()
        {
            selectionmodel        = SelectionModel.GetInstance();
            mousefiltermousecache = MouseCache.GetInstance();

            CommandCombos.GetInstance().RegisterCommandGroup(
                new string[] { CMD_EDITPOSITION, CMD_EDITSCALE, CMD_EDITROTATION }, new KeyCommandHandler(EditModeKeyEvent));

            CommandCombos.GetInstance().RegisterAtLeastCommand(
                "leftmousebutton", new KeyCommandHandler(MouseDown));

            mousefiltermousecache.MouseMove += new MouseMoveHandler(MouseMove);

            editing3dpos   = new Editing3dPos(this);
            editing3drot   = new Editing3dRot(this);
            editing3dscale = new Editing3dScale(this);

            RendererFactory.GetInstance().WriteNextFrameEvent += new WriteNextFrameCallback(Editing3d_WriteNextFrameEvent);
        }
        public void SelectIndividualKeyDown(string command, bool down)
        {
            if (down)
            {
                selectionmodel.ToggleClickedInSelection(false, MouseCache.GetInstance().MouseX, MouseCache.GetInstance().MouseY);
            }
            //bSelectIndividualOn = down;
            //if( bSelectIndividualOn )
            //{
            //  Test.Debug("adding capture");
            //keyandmousehandler.MouseDown += new MouseHandler( MouseDown );
            //MouseFilterMouseCacheFactory.GetInstance().MouseDown += new MouseEventHandler( MouseDown );
            //}
            //else
            //{
            //  Test.Debug("removing capture");
            //keyandmousehandler.MouseDown -= new MouseHandler( MouseDown );
//                MouseFilterMouseCacheFactory.GetInstance().MouseDown -= new MouseEventHandler( MouseDown );
//          }
        }
Example #9
0
        void Camera_MouseMove()
        {
            //if (ViewerState.GetInstance().CurrentViewState == ViewerState.ViewerStateEnum.RoamingCamera)
            //{
            switch (CurrentMove)
            {
            case CameraMoveType.AltZoom:
                UpdateAltZoomCamera(MouseCache.GetInstance().MouseX, MouseCache.GetInstance().MouseY);
                break;

            case CameraMoveType.Orbit:
                UpdateOrbitCamera(MouseCache.GetInstance().MouseX, MouseCache.GetInstance().MouseY);
                break;

            case CameraMoveType.Pan:
                UpdatePanCamera(MouseCache.GetInstance().MouseX, MouseCache.GetInstance().MouseY);
                break;
            }
            //}
        }
Example #10
0
        public void MouseDown(string command, bool down)
        {
            //if (ViewerState.GetInstance().CurrentViewState == ViewerState.ViewerStateEnum.RoamingCamera)
            //{
            switch (CurrentMove)
            {
            case CameraMoveType.AltZoom:
                InitiateZoomCamera(MouseCache.GetInstance().MouseX, MouseCache.GetInstance().MouseY);
                break;

            case CameraMoveType.Orbit:
                InitiateOrbitCamera(MouseCache.GetInstance().MouseX, MouseCache.GetInstance().MouseY);
                break;

            case CameraMoveType.Pan:
                InitiatePanCamera(MouseCache.GetInstance().MouseX, MouseCache.GetInstance().MouseY);
                break;
            }
            //}
        }
Example #11
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);
        }
Example #12
0
        /// <summary>
        /// Return current mouse intersect point to x-y plane on map, in display coordinates
        /// </summary>
        /// <returns></returns>
        public static Vector3 GetIntersectPoint()
        {
            // intersect mousevector with x-z plane.
            TerrainModel terrain     = MetaverseClient.GetInstance().worldstorage.terrainmodel;
            Vector3      mousevector = GraphicsHelperFactory.GetInstance().GetMouseVector(
                Camera.GetInstance().CameraPos,
                Camera.GetInstance().CameraRot,
                MouseCache.GetInstance().MouseX,
                MouseCache.GetInstance().MouseY);
            Vector3 camerapos = Camera.GetInstance().CameraPos;
            int     width     = terrain.HeightMapWidth;
            int     height    = terrain.HeightMapHeight;

            //Vector3 planenormal = mvMath.ZAxis;
            mousevector.Normalize();
            if (mousevector.z < -0.0005)
            {
                //Vector3 intersectionpoint = camerapos + mousevector * (Vector3.DotProduct(camerapos, planenormal) + 0) /
                //  (Vector3.DotProduct(mousevector, planenormal));
                Vector3 intersectpoint = camerapos - mousevector * (camerapos.z / mousevector.z);
                //Console.WriteLine("intersection: " + intersectionpoint.ToString());
                double heightmapx = intersectpoint.x;
                double heightmapy = intersectpoint.y;
                if (heightmapx >= 0 && heightmapy >= 0 &&
                    heightmapx < width && heightmapy < height)
                {
                    intersectpoint.z = terrain.Map[(int)heightmapx, (int)heightmapy];
                    return(intersectpoint);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                //                Console.WriteLine("no intersection");
                return(null);
            }
        }
 MouseMoveConfigMappings() // protected constructor, to enforce singleton
 {
     MouseMoveConfigsByName = Config.GetInstance().MouseMoveConfigsByName;
     mousefiltermousecache  = MouseCache.GetInstance();
     config = Config.GetInstance();
 }
Example #14
0
 Layer2MouseEvents()
 {
     MouseCache.GetInstance().MouseDown += new SdlDotNet.MouseButtonEventHandler(Layer2MouseEvents_MouseDown);
     MouseCache.GetInstance().MouseUp   += new SdlDotNet.MouseButtonEventHandler(Layer2MouseEvents_MouseUp);
     MouseCache.GetInstance().MouseMove += new MouseMoveHandler(Layer2MouseEvents_MouseMove);
 }
 // protected constructor, to enforce singleton
 MouseMoveConfigMappings()
 {
     MouseMoveConfigsByName = Config.GetInstance().MouseMoveConfigsByName;
     mousefiltermousecache = MouseCache.GetInstance();
     config = Config.GetInstance();
 }