예제 #1
0
        private bool IsOnChrono(Metadata _Metadata, Point _MouseCoordinates, long _iCurrentTimeStamp)
        {
            bool bIsOnChrono = false;

            for (int i = 0; i < _Metadata.Chronos.Count; i++)
            {
                int handle = _Metadata.Chronos[i].HitTest(_MouseCoordinates, _iCurrentTimeStamp);

                if (handle >= 0)
                {
                    bIsOnChrono              = true;
                    m_SelectedObjectType     = SelectedObjectType.Chrono;
                    _Metadata.SelectedChrono = i;

                    if (handle > 0)
                    {
                        m_UserAction      = UserAction.Resize;
                        m_iResizingHandle = handle;
                    }
                    else
                    {
                        m_UserAction = UserAction.Move;
                    }


                    break;
                }
            }

            return(bIsOnChrono);
        }
예제 #2
0
        private bool IsOnExtraDrawing(Metadata metadata, PointF mouseCoordinates, long currentTimestamp)
        {
            // Test if we hit an unattached drawing.

            bool isOnDrawing    = false;
            int  hitResult      = -1;
            int  currentDrawing = 0;

            while (hitResult < 0 && currentDrawing < metadata.ExtraDrawings.Count)
            {
                hitResult = metadata.ExtraDrawings[currentDrawing].HitTest(mouseCoordinates, currentTimestamp, metadata.CalibrationHelper.DistortionHelper, metadata.CoordinateSystem, metadata.CoordinateSystem.Zooming);

                if (hitResult < 0)
                {
                    currentDrawing++;
                    continue;
                }

                isOnDrawing        = true;
                selectedObjectType = SelectedObjectType.ExtraDrawing;
                metadata.SelectDrawing(metadata.ExtraDrawings[currentDrawing]);

                if (hitResult > 0)
                {
                    manipulationType = ManipulationType.Resize;
                    resizingHandle   = hitResult;
                }
                else
                {
                    manipulationType = ManipulationType.Move;
                }
            }

            return(isOnDrawing);
        }
예제 #3
0
        private bool IsOnChronometer(Metadata metadata, PointF point, long currentTimestamp)
        {
            bool isOnDrawing = false;

            foreach (AbstractDrawing drawing in metadata.ChronoManager.Drawings)
            {
                int hitResult = drawing.HitTest(point, currentTimestamp, metadata.CalibrationHelper.DistortionHelper, metadata.CoordinateSystem, metadata.CoordinateSystem.Zooming);
                if (hitResult < 0)
                {
                    continue;
                }

                isOnDrawing        = true;
                selectedObjectType = SelectedObjectType.ExtraDrawing;
                metadata.SelectDrawing(drawing);

                if (hitResult > 0)
                {
                    manipulationType = ManipulationType.Resize;
                    resizingHandle   = hitResult;
                }
                else
                {
                    manipulationType = ManipulationType.Move;
                }

                break;
            }

            return(isOnDrawing);
        }
예제 #4
0
        public DrawingToolPointer()
        {
            manipulationType   = ManipulationType.None;
            selectedObjectType = SelectedObjectType.None;
            lastPoint          = PointF.Empty;
            resizingHandle     = 0;
            imgSize            = new Size(320, 240);
            mouseDelta         = PointF.Empty;
            directZoomTopLeft  = new Point(-1, -1);

            SetupHandCursors();
        }
예제 #5
0
        public DrawingToolPointer()
        {
            m_UserAction         = UserAction.None;
            m_SelectedObjectType = SelectedObjectType.None;
            m_lastPoint          = new Point(0, 0);
            m_iResizingHandle    = 0;
            m_ImgSize            = new Size(320, 240);
            m_MouseDelta         = new Point(0, 0);
            m_DirectZoomTopLeft  = new Point(-1, -1);

            SetupHandCursors();
        }
예제 #6
0
 //Services
 private void SetObject(object SelectedObject)
 {
     if (SelectedObject.GetType().IsSubclassOf(typeof(SceneObject)))
     {
         _Type = SelectedObjectType.SceneObject;
         SetSceneObject((SceneObject)SelectedObject);
     }
     else if (SelectedObject.GetType().IsSubclassOf(typeof(Scene)))
     {
         _Type = SelectedObjectType.Scene;
         SetScene((Scene)SelectedObject);
     }
 }
예제 #7
0
        private bool IsOnGrids(Metadata _Metadata, Point _MouseCoordinates)
        {
            // Check wether we hit the Grid or the 3D Plane.
            bool bIsOnGrids = false;
            int  handle     = -1;

            if (_Metadata.Plane.Visible)
            {
                handle = _Metadata.Plane.HitTest(_MouseCoordinates);
                if (handle >= 0)
                {
                    bIsOnGrids               = true;
                    m_SelectedObjectType     = SelectedObjectType.Plane;
                    _Metadata.Plane.Selected = true;
                    // Handler hit ?
                    if (handle > 0)
                    {
                        m_UserAction      = UserAction.Resize;
                        m_iResizingHandle = handle;
                    }
                    else
                    {
                        m_UserAction = UserAction.Move;
                    }
                }
            }

            if (!bIsOnGrids && _Metadata.Grid.Visible)
            {
                handle = _Metadata.Grid.HitTest(_MouseCoordinates);
                if (handle >= 0)
                {
                    bIsOnGrids              = true;
                    m_SelectedObjectType    = SelectedObjectType.Grid;
                    _Metadata.Grid.Selected = true;

                    // Handler hit ?
                    if (handle > 0)
                    {
                        m_UserAction      = UserAction.Resize;
                        m_iResizingHandle = handle;
                    }
                    else
                    {
                        m_UserAction = UserAction.Move;
                    }
                }
            }

            return(bIsOnGrids);
        }
예제 #8
0
        private bool IsOnTrack(Metadata metadata, PointF mouseCoordinates, long currentTimeStamp)
        {
            // Track have their own special hit test because we need to differenciate the interactive case from the edit case.
            bool isOnDrawing = false;

            foreach (AbstractDrawing drawing in metadata.TrackManager.Drawings)
            {
                DrawingTrack track = drawing as DrawingTrack;
                if (track == null)
                {
                    continue;
                }

                int hitResult = drawing.HitTest(mouseCoordinates, currentTimeStamp, metadata.CalibrationHelper.DistortionHelper, metadata.CoordinateSystem, metadata.CoordinateSystem.Zooming);
                if (hitResult < 0)
                {
                    continue;
                }

                isOnDrawing        = true;
                selectedObjectType = SelectedObjectType.ExtraDrawing;
                metadata.SelectDrawing(drawing);

                manipulationType = ManipulationType.Move;

                switch (track.Status)
                {
                case TrackStatus.Interactive:
                    if (hitResult == 0 || hitResult == 1)
                    {
                        manipulationType = ManipulationType.Resize;
                        resizingHandle   = hitResult;
                    }
                    break;

                case TrackStatus.Configuration:
                    if (hitResult > 1)
                    {
                        manipulationType = ManipulationType.Resize;
                        resizingHandle   = hitResult;
                    }
                    break;
                }

                break;
            }

            return(isOnDrawing);
        }
예제 #9
0
    public GameObject SelectObject(out SelectedObjectType type)
    {
        //first see if cursor is near any onscreen objects with markers
        Vector3 mousePos = GameManager.Inst.UIManager.GetNGUIMousePosition();
        //GameObject.Find("Sphere").transform.position = mousePos;
        //Debug.Log(mousePos);
        Dictionary <ShipBase, UISprite> unselectedShipMarkers = GameManager.Inst.UIManager.HUDPanel.UnselectedShipMarkers;

        foreach (KeyValuePair <ShipBase, UISprite> marker in unselectedShipMarkers)
        {
            if (marker.Value.alpha <= 0)
            {
                continue;
            }

            Vector3 markerPos = new Vector3(marker.Value.transform.position.x, marker.Value.transform.position.y, 0);
            //marker.Value.transform.position = mousePos;
            Debug.Log(marker.Value.transform.position);
            Debug.Log(Vector3.Distance(mousePos, markerPos));
            if (Vector3.Distance(markerPos, mousePos) < 0.1f)
            {
                type = SelectedObjectType.Ship;
                Debug.Log("Selected a ship");
                return(marker.Key.gameObject);
            }
        }

        //do a raycast to detect large objects
        GameObject aimedObject = null;
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        //ignore small ships, pickups, shields
        int mask = ~(1 << 2 | 1 << 8 | 1 << 9 | 1 << 10 | 1 << 12 | 1 << 15);

        if (Physics.Raycast(ray, out hit, 10000, mask))
        {
            Debug.Log("Hit " + hit.collider.name);
            aimedObject = hit.collider.gameObject;
            type        = SelectedObjectType.Unknown;
        }
        else
        {
            type = SelectedObjectType.Unknown;
        }



        return(aimedObject);
    }
예제 #10
0
 /// <summary>
 /// Activate document to edit property
 /// </summary>
 public void SelectDoc(MkaDocument doc)
 {
     this.DocumentArea = doc;
     this.MokkanList   = doc.MokkanList;
     if (MokkanList.SelectionCount > 0)  // mokkan property
     {
         this.propertyGrid.SelectedObjects = MokkanList.SelectedObjectsProperties;
         SelectedType = SelectedObjectType.Mokkan;
     }
     else    // glass property
     {
         this.propertyGrid.SelectedObject = doc.GlassInfo;
         SelectedType = SelectedObjectType.Glass;
     }
 }
예제 #11
0
        private bool IsOnTrack(Metadata _Metadata, Point _MouseCoordinates, long _iCurrentTimeStamp)
        {
            // Track have their own special hit test because we need to differenciate the interactive case from the edit case.
            bool bTrackHit = false;

            for (int i = 0; i < _Metadata.ExtraDrawings.Count; i++)
            {
                Track trk = _Metadata.ExtraDrawings[i] as Track;
                if (trk != null)
                {
                    // Result:
                    // -1 = miss, 0 = on traj, 1 = on Cursor, 2 = on main label, 3+ = on keyframe label.

                    int handle = trk.HitTest(_MouseCoordinates, _iCurrentTimeStamp);

                    if (handle >= 0)
                    {
                        bTrackHit                      = true;
                        m_SelectedObjectType           = SelectedObjectType.ExtraDrawing;
                        _Metadata.SelectedExtraDrawing = i;

                        if (handle > 1)
                        {
                            // Touched target or handler.
                            // The handler would have been saved inside the track object.
                            m_UserAction = UserAction.Move;
                        }
                        else if (trk.Status == TrackStatus.Interactive)
                        {
                            m_UserAction      = UserAction.Resize;
                            m_iResizingHandle = handle;
                        }
                        else
                        {
                            // edit mode + 0 or 1.
                            m_UserAction = UserAction.Move;
                        }

                        break;
                    }
                }
            }

            return(bTrackHit);
        }
예제 #12
0
        public bool OnMouseDown(Metadata metadata, int activeKeyFrameIndex, PointF mouseCoordinates, long currentTimeStamp, bool allFrames)
        {
            //--------------------------------------------------------------------------------------
            // Change the ManipulationType if we are on a Drawing, Track, etc.
            // When we later pass in the MouseMove function, we will have the right ManipulationType set
            // and we will be able to do the right thing.
            //
            // We give priority to Keyframes Drawings because they can be moved...
            // If a Drawing is under a Trajectory or Chrono, we have to be able to move it around...
            //--------------------------------------------------------------------------------------

            manipulationType = ManipulationType.None;
            metadata.UnselectAll();

            // Store position (descaled: in original image coords).
            lastPoint.X = mouseCoordinates.X;
            lastPoint.Y = mouseCoordinates.Y;

            if (IsOnDrawing(metadata, activeKeyFrameIndex, mouseCoordinates, currentTimeStamp, allFrames))
            {
                return(true);
            }

            if (IsOnTrack(metadata, mouseCoordinates, currentTimeStamp))
            {
                return(true);
            }

            if (IsOnChronometer(metadata, mouseCoordinates, currentTimeStamp))
            {
                return(true);
            }

            if (IsOnExtraDrawing(metadata, mouseCoordinates, currentTimeStamp))
            {
                return(true);
            }

            // Moving the whole image (Direct Zoom)
            selectedObjectType = SelectedObjectType.None;
            return(false);
        }
예제 #13
0
        public bool OnMouseDown(Metadata _Metadata, int _iActiveKeyFrameIndex, Point _MouseCoordinates, long _iCurrentTimeStamp, bool _bAllFrames)
        {
            //--------------------------------------------------------------------------------------
            // Change the UserAction if we are on a Drawing, Track, etc.
            // When we later pass in the MouseMove function, we will have the right UserAction set
            // and we will be able to do the right thing.
            //
            // We give priority to Keyframes Drawings because they can be moved...
            // If a Drawing is under a Trajectory or Chrono, we have to be able to move it around...
            //
            // Maybe we could reuse the IsOndrawing, etc. functions from MetaData...
            //--------------------------------------------------------------------------------------

            bool bHit = true;

            m_UserAction = UserAction.None;

            _Metadata.UnselectAll();

            if (!IsOnDrawing(_Metadata, _iActiveKeyFrameIndex, _MouseCoordinates, _iCurrentTimeStamp, _bAllFrames))
            {
                if (!IsOnChrono(_Metadata, _MouseCoordinates, _iCurrentTimeStamp))
                {
                    if (!IsOnTrack(_Metadata, _MouseCoordinates, _iCurrentTimeStamp))
                    {
                        if (!IsOnGrids(_Metadata, _MouseCoordinates))
                        {
                            // Moving the whole image (Direct Zoom)
                            m_SelectedObjectType = SelectedObjectType.None;
                            bHit = false;
                        }
                    }
                }
            }

            // Store position (descaled: in original image coords).
            m_lastPoint.X = _MouseCoordinates.X;
            m_lastPoint.Y = _MouseCoordinates.Y;

            return(bHit);
        }
예제 #14
0
        /// <summary>
        /// Remove selection of current active object
        /// </summary>
        public void UnselectObject()
        {
            // Nothing was selected
            if (_selectedObject == null)
            {
                return;
            }

            switch (_selectedObjectType)
            {
            case SelectedObjectType.Beam:
                _selectedObject.GetComponent <Beam>().Deselect();
                break;

            case SelectedObjectType.BasicTip:
                _selectedObject.GetComponent <BasicTip>().Deselect();
                break;

            case SelectedObjectType.RotaryJoint:
                InfoPanelController.Instance.HideRotaryJointEditor();
                _selectedObject.GetComponent <RotaryJoint>().Deselect();
                break;

            case SelectedObjectType.RevoluteJoint:
                InfoPanelController.Instance.HideRevoluteJointEditor();
                _selectedObject.GetComponent <RevoluteJoint>().Deselect();
                break;

            case SelectedObjectType.None:
            default:
                break;
            }

            _selectedObject     = null;
            _selectedObjectType = SelectedObjectType.None;

            CameraOnDefault();
        }
        //====================================================================================================
        private void btnImage_MouseDown(object sender, MouseEventArgs e)
        {
            txtConsole.Text = "X = " + e.X + "    Y = " + e.Y + "\r\n" + txtConsole.Text;
            const int _rad_size = 12;

            for (int i = 0; i < _objects.Count; i++)
            {
                if (_objects[i].GetType() == typeof(STA))
                {
                    STA _tsta = (STA)_objects[i];
                    if (_tsta.x >= e.X - _rad_size && _tsta.x <= e.X + _rad_size && _tsta.y >= e.Y - _rad_size && _tsta.y <= e.Y + _rad_size)
                    {
                        //txtConsole.Text = "Station selected for move :" + i.ToString() + "\r\n" + txtConsole.Text;
                        SelectedVertex = i;
                        SelectedX      = e.X;
                        SelectedY      = e.Y;
                        SelectedZ      = e.X + e.Y;
                        _ob            = SelectedObjectType.STA;
                        return;
                    }
                }
                else if (_objects[i].GetType() == typeof(AP))
                {
                    AP _tap = (AP)_objects[i];
                    if (_tap.x >= e.X - _rad_size && _tap.x <= e.X + _rad_size && _tap.y >= e.Y - _rad_size && _tap.y <= e.Y + _rad_size)
                    {
                        //txtConsole.Text = "AP selected for move :" + i.ToString() + "\r\n" + txtConsole.Text;
                        SelectedVertex = i;
                        SelectedX      = e.X;
                        SelectedY      = e.Y;
                        SelectedZ      = e.X + e.Y;
                        _ob            = SelectedObjectType.AP;
                        return;
                    }
                }
            }
        }
예제 #16
0
        private bool DrawingHitTest(Metadata _Metadata, int _iKeyFrameIndex, Point _MouseCoordinates, long _iCurrentTimeStamp)
        {
            bool     bDrawingHit     = false;
            Keyframe kf              = _Metadata.Keyframes[_iKeyFrameIndex];
            int      hitRes          = -1;
            int      iCurrentDrawing = 0;

            while (hitRes < 0 && iCurrentDrawing < kf.Drawings.Count)
            {
                hitRes = kf.Drawings[iCurrentDrawing].HitTest(_MouseCoordinates, _iCurrentTimeStamp);
                if (hitRes >= 0)
                {
                    bDrawingHit                    = true;
                    m_SelectedObjectType           = SelectedObjectType.Drawing;
                    _Metadata.SelectedDrawing      = iCurrentDrawing;
                    _Metadata.SelectedDrawingFrame = _iKeyFrameIndex;

                    // Handler hit ?
                    if (hitRes > 0)
                    {
                        m_UserAction      = UserAction.Resize;
                        m_iResizingHandle = hitRes;
                    }
                    else
                    {
                        m_UserAction = UserAction.Move;
                    }
                }
                else
                {
                    iCurrentDrawing++;
                }
            }

            return(bDrawingHit);
        }
예제 #17
0
        private bool IsOnExtraDrawing(Metadata _Metadata, Point _MouseCoordinates, long _iCurrentTimeStamp)
        {
            // Test if we hit an unattached drawing.

            bool bIsOnDrawing    = false;
            int  hitRes          = -1;
            int  iCurrentDrawing = 0;

            while (hitRes < 0 && iCurrentDrawing < _Metadata.ExtraDrawings.Count)
            {
                hitRes = _Metadata.ExtraDrawings[iCurrentDrawing].HitTest(_MouseCoordinates, _iCurrentTimeStamp);
                if (hitRes >= 0)
                {
                    bIsOnDrawing                   = true;
                    m_SelectedObjectType           = SelectedObjectType.ExtraDrawing;
                    _Metadata.SelectedExtraDrawing = iCurrentDrawing;

                    // Handler hit ?
                    if (hitRes > 0)
                    {
                        m_UserAction      = UserAction.Resize;
                        m_iResizingHandle = hitRes;
                    }
                    else
                    {
                        m_UserAction = UserAction.Move;
                    }
                }
                else
                {
                    iCurrentDrawing++;
                }
            }

            return(bIsOnDrawing);
        }
예제 #18
0
        private bool DrawingHitTest(Metadata metadata, int keyFrameIndex, PointF mouseCoordinates, long currentTimeStamp, DistortionHelper distorter, CoordinateSystem transformer)
        {
            bool isOnDrawing    = false;
            int  hitResult      = -1;
            int  currentDrawing = 0;

            Keyframe kf = metadata.Keyframes[keyFrameIndex];

            while (hitResult < 0 && currentDrawing < kf.Drawings.Count)
            {
                hitResult = kf.Drawings[currentDrawing].HitTest(mouseCoordinates, currentTimeStamp, distorter, transformer, transformer.Zooming);

                if (hitResult < 0)
                {
                    currentDrawing++;
                    continue;
                }

                isOnDrawing        = true;
                selectedObjectType = SelectedObjectType.Drawing;
                metadata.SelectDrawing(kf.Drawings[currentDrawing]);
                metadata.SelectKeyframe(kf);

                if (hitResult > 0)
                {
                    manipulationType = ManipulationType.Resize;
                    resizingHandle   = hitResult;
                }
                else
                {
                    manipulationType = ManipulationType.Move;
                }
            }

            return(isOnDrawing);
        }
예제 #19
0
    /*
     * private void ShiftShield(bool isToFront)
     * {
     *      if(PlayerShip.Shield != null && PlayerShip.Shield.Type == ShieldType.Fighter)
     *      {
     *              FighterShield shield = (FighterShield)PlayerShip.Shield;
     *              float frontPortion = shield.FrontCapacity / shield.TotalCapacity;
     *              float totalAmount = shield.FrontAmount + shield.RearAmount;
     *              if(isToFront)
     *              {
     *                      frontPortion = Mathf.Clamp01(frontPortion + 0.1f);
     *
     *              }
     *              else
     *              {
     *                      frontPortion = Mathf.Clamp01(frontPortion - 0.1f);
     *
     *              }
     *
     *              shield.FrontCapacity = shield.TotalCapacity * frontPortion;
     *              shield.RearCapacity = shield.TotalCapacity * (1 - frontPortion);
     *              shield.FrontAmount = totalAmount * frontPortion;
     *              shield.RearAmount = totalAmount * (1 - frontPortion);
     *      }
     * }
     */

    private void SelectObject()
    {
        GameManager.Inst.UIManager.HUDPanel.OnClearSelectedObject();

        SelectedObjectType type = SelectedObjectType.Unknown;
        GameObject         go   = GameManager.Inst.CursorManager.SelectObject(out type);

        TargetShip = null;

        if (go != null)
        {
            GameManager.Inst.SoundManager.UI.PlayOneShot(GameManager.Inst.SoundManager.GetClip("Select"));

            if (type == SelectedObjectType.Unknown)
            {
                //attempt to figure out what it is

                StationBase station = go.GetComponent <StationBase>();
                if (station != null)
                {
                    SelectedObjectType = SelectedObjectType.Station;
                    SelectedObject     = station;
                    GameManager.Inst.UIManager.HUDPanel.OnSelectPlanetOrStation(station.transform, station.DisplayName);
                    return;
                }

                StationComponent stationComp = go.GetComponent <StationComponent>();
                if (stationComp != null)
                {
                    SelectedObjectType = SelectedObjectType.Station;
                    SelectedObject     = stationComp.ParentStation;
                    GameManager.Inst.UIManager.HUDPanel.OnSelectPlanetOrStation(stationComp.ParentStation.transform, stationComp.ParentStation.DisplayName);
                    return;
                }

                Planet planet = go.GetComponent <Planet>();
                if (planet != null)
                {
                    SelectedObjectType = SelectedObjectType.Planet;
                    SelectedObject     = planet;
                    GameManager.Inst.UIManager.HUDPanel.OnSelectPlanetOrStation(planet.transform, planet.DisplayName);
                    return;
                }
            }
            else if (type == SelectedObjectType.Ship)
            {
                ShipBase ship = go.GetComponent <ShipBase>();
                if (ship != null)
                {
                    SelectedObjectType = SelectedObjectType.Ship;
                    SelectedObject     = ship;
                    GameManager.Inst.UIManager.HUDPanel.OnSelectShip(ship);
                    TargetShip = ship;
                    return;
                }
            }
        }
        else
        {
            GameManager.Inst.UIManager.HUDPanel.OnClearSelectedObject();
        }
    }
예제 #20
0
 private PropertyInfo GetPropertyInfo(string propertyName)
 {
     return(SelectedObjectType.GetProperty(propertyName));
 }
예제 #21
0
 /// <summary>
 /// Activate bat to edit property
 /// </summary>
 public void SelectBat(MkaBatManager bat)
 {
     this.propertyGrid.SelectedObject = bat.BatInfo;
     SelectedType = SelectedObjectType.Bat;
 }
예제 #22
0
        private bool IsOnTrack(Metadata _Metadata, Point _MouseCoordinates, long _iCurrentTimeStamp)
        {
            bool bTrackHit = false;

            for (int i = 0; i < _Metadata.Tracks.Count; i++)
            {
                // Result:
                // -1 = miss, 0 = on traj, 1 = on Cursor, 2 = on main label, 3+ = on keyframe label.

                int handle = _Metadata.Tracks[i].HitTest(_MouseCoordinates, _iCurrentTimeStamp);

                if (handle >= 0)
                {
                    bTrackHit               = true;
                    m_SelectedObjectType    = SelectedObjectType.Track;
                    _Metadata.SelectedTrack = i;

                    if (_Metadata.Tracks[i].Status == Track.TrackStatus.Interactive)
                    {
                        // Trajectory is in interactive mode.

                        if (handle == 0)
                        {
                            // Mouse touched the trajectory.
                            m_UserAction = UserAction.Move;

                            // We should update the playhead now. No need to wait for the next mouse move.
                            _Metadata.Tracks[i].MoveCursor(_MouseCoordinates.X, _MouseCoordinates.Y);
                        }
                        else if (handle == 1)
                        {
                            // Mouse touched the cursor. We'll update the playhead when mouse move.
                            m_UserAction = UserAction.Move;
                        }
                        else
                        {
                            // Mouse touched a Label.
                            m_UserAction      = UserAction.Resize;
                            m_iResizingHandle = handle;
                        }
                    }
                    else
                    {
                        // Trajectory is in edit mode.
                        // We react to labels and cursor.

                        if (handle == 1)
                        {
                            // Mouse touched the cursor.
                            m_UserAction = UserAction.Move;
                        }
                        else if (handle > 1)
                        {
                            // Mouse touched a Label.
                            m_UserAction      = UserAction.Resize;
                            m_iResizingHandle = handle;
                        }
                    }

                    break;
                }
            }

            return(bTrackHit);
        }
예제 #23
0
        private void Update()
        {
            if (ModelManager.Instance.Mode != ApplicationMode.Construction)
            {
                return;
            }

            if (Input.GetMouseButtonDown(0))
            {
                // Check if the mouse was clicked over a UI element
                if (EventSystem.current.IsPointerOverGameObject())
                {
                    return;
                }

                if (!Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out var hit))
                {
                    // Did not hit anything
                    UnselectObject();
                    CameraOnDefault();
                }
                else
                {
                    // If we clicked on the same object
                    if (hit.transform == _selectedObject)
                    {
                        UnselectObject();
                        return;
                    }

                    // If we clicked on different object
                    UnselectObject();
                    // Save selected object
                    _selectedObject = hit.transform;
                    // Detect type of selected object
                    switch (hit.transform.tag)
                    {
                    case "Beam":
                        _selectedObjectType = SelectedObjectType.Beam;
                        _selectedObject.GetComponent <Beam>().Select();
                        CameraOnSelected();
                        break;

                    case "Tip":
                        _selectedObjectType = SelectedObjectType.BasicTip;
                        _selectedObject.GetComponent <BasicTip>().Select();
                        CameraOnSelected();
                        break;

                    case "RotaryJoint":
                        _selectedObjectType = SelectedObjectType.RotaryJoint;
                        var rotaryJoint = hit.transform.GetComponent <RotaryJoint>();
                        rotaryJoint.Select();
                        InfoPanelController.Instance.ShowRotaryJointEditor(rotaryJoint);
                        CameraOnSelected();
                        break;

                    case "RevoluteJoint":
                        _selectedObjectType = SelectedObjectType.RevoluteJoint;
                        var revoluteJoint = hit.transform.GetComponent <RevoluteJoint>();
                        revoluteJoint.Select();
                        InfoPanelController.Instance.ShowRevoluteJointEditor(revoluteJoint);
                        CameraOnSelected();
                        break;

                    default:
                        CameraOnDefault();
                        break;
                    }
                }
            }
        }