Example #1
0
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            state.ValidateSelectionStats();

            float   zMovement = state.CameraObj.Transform.Pos.Z - lastLocSpace.Z;
            Vector3 target    = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z + zMovement));
            Vector3 movLock   = beginLocSpace - lastLocSpace;
            Vector3 mov       = target - lastLocSpace;

            mov.Z    = zMovement;
            target.Z = 0;

            if (lockedAxis == CamViewState.LockedAxis.X)
            {
                mov = new Vector3(mov.X, 0, 0);
            }
            else if (lockedAxis == CamViewState.LockedAxis.Y)
            {
                mov = new Vector3(0, mov.Y, 0);
            }
            else
            {
                mov = state.ApplyAxisLock(mov, movLock, target + (Vector3.UnitZ * state.CameraObj.Transform.Pos.Z) - beginLocSpace);
            }

            state.MoveSelectionBy(mov);

            state.ActionLastLocSpace += mov;
        }
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            state.ValidateSelectionStats();

            float zMovement = state.CameraObj.Transform.Pos.Z - lastLocSpace.Z;
            Vector3 target = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z + zMovement));
            Vector3 movLock = beginLocSpace - lastLocSpace;
            Vector3 mov = target - lastLocSpace;
            mov.Z = zMovement;
            target.Z = 0;

            if (lockedAxis == CamViewState.LockedAxis.X)
            {
                mov = new Vector3(mov.X, 0, 0);
            }
            else if (lockedAxis == CamViewState.LockedAxis.Y)
            {
                mov = new Vector3(0, mov.Y, 0);
            }
            else
            {
                mov = state.ApplyAxisLock(mov, movLock, target + (Vector3.UnitZ * state.CameraObj.Transform.Pos.Z) - beginLocSpace);
            }

            state.MoveSelectionBy(mov);

            state.ActionLastLocSpace += mov;
        }
Example #3
0
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            state.ValidateSelectionStats();

            Vector3 spaceCoord = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z));
            float   lastAngle  = MathF.Angle(selectionCenter.X, selectionCenter.Y, lastLocSpace.X, lastLocSpace.Y);
            float   curAngle   = MathF.Angle(selectionCenter.X, selectionCenter.Y, spaceCoord.X, spaceCoord.Y);
            float   rotation   = curAngle - lastAngle;

            state.RotateSelectionBy(rotation);

            state.ActionLastLocSpace = spaceCoord;
        }
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            state.ValidateSelectionStats();

            Vector3 spaceCoord = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z));
            float lastAngle = MathF.Angle(selectionCenter.X, selectionCenter.Y, lastLocSpace.X, lastLocSpace.Y);
            float curAngle = MathF.Angle(selectionCenter.X, selectionCenter.Y, spaceCoord.X, spaceCoord.Y);
            float rotation = curAngle - lastAngle;

            state.RotateSelectionBy(rotation);

            state.ActionLastLocSpace = spaceCoord;
        }
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            state.ValidateSelectionStats();
            if (selectionRadius == 0.0f) return;

            Vector3 spaceCoord = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z));
            float lastRadius = selectionRadius;
            float curRadius = (selectionCenter - spaceCoord).Length;
            float scale = MathF.Clamp(curRadius / lastRadius, 0.0001f, 10000.0f);

            state.ScaleSelectionBy(scale);

            state.ActionLastLocSpace = spaceCoord;
            state.Invalidate();
        }
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            if (DualityEditorApp.IsSelectionChanging)
            {
                return;                                                   // Prevent Recursion in case SelectObjects triggers UpdateAction.
            }
            bool shift = (Control.ModifierKeys & Keys.Shift) != Keys.None;
            bool ctrl  = (Control.ModifierKeys & Keys.Control) != Keys.None;

            // Determine picked rect
            int pX  = Math.Max(Math.Min(mouseLoc.X, beginLoc.X), 0);
            int pY  = Math.Max(Math.Min(mouseLoc.Y, beginLoc.Y), 0);
            int pX2 = Math.Max(mouseLoc.X, beginLoc.X);
            int pY2 = Math.Max(mouseLoc.Y, beginLoc.Y);
            int pW  = Math.Max(pX2 - pX, 1);
            int pH  = Math.Max(pY2 - pY, 1);

            // Check which renderers are picked
            List <CamViewState.SelObj> picked = state.PickSelObjIn(pX, pY, pW, pH);

            // Store in internal rect selection
            ObjectSelection oldRectSel = state.ActiveRectSel;

            state.ActiveRectSel = new ObjectSelection(picked);

            // Apply internal selection to actual editor selection
            if (shift || ctrl)
            {
                if (state.ActiveRectSel.ObjectCount > 0)
                {
                    ObjectSelection added = (state.ActiveRectSel - oldRectSel) + (oldRectSel - state.ActiveRectSel);
                    state.SelectObjects(added.OfType <CamViewState.SelObj>(), shift ? SelectMode.Append : SelectMode.Toggle);
                }
            }
            else if (state.ActiveRectSel.ObjectCount > 0)
            {
                state.SelectObjects(state.ActiveRectSel.OfType <CamViewState.SelObj>());
            }
            else
            {
                state.ClearSelection();
            }

            state.Invalidate();
        }
Example #7
0
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            state.ValidateSelectionStats();
            if (selectionRadius == 0.0f)
            {
                return;
            }

            Vector3 spaceCoord = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z));
            float   lastRadius = selectionRadius;
            float   curRadius  = (selectionCenter - spaceCoord).Length;
            float   scale      = MathF.Clamp(curRadius / lastRadius, 0.0001f, 10000.0f);

            state.ScaleSelectionBy(scale);

            state.ActionLastLocSpace = spaceCoord;
            state.Invalidate();
        }
        public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
        {
            if (DualityEditorApp.IsSelectionChanging) return; // Prevent Recursion in case SelectObjects triggers UpdateAction.

            bool shift = (Control.ModifierKeys & Keys.Shift) != Keys.None;
            bool ctrl = (Control.ModifierKeys & Keys.Control) != Keys.None;

            // Determine picked rect
            int pX = Math.Max(Math.Min(mouseLoc.X, beginLoc.X), 0);
            int pY = Math.Max(Math.Min(mouseLoc.Y, beginLoc.Y), 0);
            int pX2 = Math.Max(mouseLoc.X, beginLoc.X);
            int pY2 = Math.Max(mouseLoc.Y, beginLoc.Y);
            int pW = Math.Max(pX2 - pX, 1);
            int pH = Math.Max(pY2 - pY, 1);

            // Check which renderers are picked
            List<CamViewState.SelObj> picked = state.PickSelObjIn(pX, pY, pW, pH);

            // Store in internal rect selection
            ObjectSelection oldRectSel = state.ActiveRectSel;
            state.ActiveRectSel = new ObjectSelection(picked);

            // Apply internal selection to actual editor selection
            if (shift || ctrl)
            {
                if (state.ActiveRectSel.ObjectCount > 0)
                {
                    ObjectSelection added = (state.ActiveRectSel - oldRectSel) + (oldRectSel - state.ActiveRectSel);
                    state.SelectObjects(added.OfType<CamViewState.SelObj>(), shift ? SelectMode.Append : SelectMode.Toggle);
                }
            }
            else if (state.ActiveRectSel.ObjectCount > 0)
                state.SelectObjects(state.ActiveRectSel.OfType<CamViewState.SelObj>());
            else
                state.ClearSelection();

            state.Invalidate();
        }
        protected override void PostPerformAction(IEnumerable<CamViewState.SelObj> selObjEnum, CamViewState.ObjectAction action)
        {
            base.PostPerformAction(selObjEnum, action);
            SelShape[] selShapeArray = selObjEnum.OfType<SelShape>().ToArray();

            // Update the body directly after modifying it
            if (this.selectedBody != null) this.selectedBody.SynchronizeBodyShape();

            // Notify property changes
            DualityEditorApp.NotifyObjPropChanged(this,
                new ObjectSelection(this.selectedBody),
                ReflectionInfo.Property_RigidBody_Shapes);
            DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(selShapeArray.Select(s => s.ActualObject)));
        }
 protected override void OnBeginAction(CamViewState.ObjectAction action)
 {
     base.OnBeginAction(action);
     bool shapeAction =
         action != ObjectAction.RectSelect &&
         action != ObjectAction.None;
     if (this.selectedBody != null && shapeAction)
     {
         this.selectedBody.BeginUpdateBodyShape();
         this.EditingUserGuide.SnapPosOrigin = this.selectedBody.GameObj.Transform.Pos;
         this.EditingUserGuide.SnapScaleOrigin = Vector3.One * this.selectedBody.GameObj.Transform.Scale;
     }
 }
 protected override void OnEndAction(CamViewState.ObjectAction action)
 {
     base.OnEndAction(action);
     bool shapeAction =
         action != ObjectAction.RectSelect &&
         action != ObjectAction.None;
     if (this.selectedBody != null && shapeAction)
     {
         this.selectedBody.EndUpdateBodyShape();
     }
     if (this.createAction)
     {
         this.createAction = false;
         UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromFirst);
     }
     this.EditingUserGuide.SnapPosOrigin = Vector3.Zero;
     this.EditingUserGuide.SnapScaleOrigin = Vector3.One;
 }
 protected override void OnEndAction(CamViewState.ObjectAction action)
 {
     base.OnEndAction(action);
     bool shapeAction =
         action != ObjectAction.RectSelect &&
         action != ObjectAction.None;
     if (this.selectedBody != null && shapeAction)
     {
         this.selectedBody.EndUpdateBodyShape();
     }
     if (this.createAction)
     {
         this.createAction = false;
         UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromFirst);
     }
 }
 protected override void OnBeginAction(CamViewState.ObjectAction action)
 {
     base.OnBeginAction(action);
     bool shapeAction =
         action != ObjectAction.RectSelect &&
         action != ObjectAction.None;
     if (this.selectedBody != null && shapeAction) this.selectedBody.BeginUpdateBodyShape();
 }
 public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
 {
     state.InvalidateSelectionStats();
 }
Example #15
0
 public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis)
 {
     state.InvalidateSelectionStats();
 }
Example #16
0
 protected override void PostPerformAction(IEnumerable<CamViewState.SelObj> selObjEnum, CamViewState.ObjectAction action)
 {
     base.PostPerformAction(selObjEnum, action);
     if (action == ObjectAction.Move)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos);
     }
     else if (action == ObjectAction.Rotate)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos,
             ReflectionInfo.Property_Transform_RelativeAngle);
     }
     else if (action == ObjectAction.Scale)
     {
         DualityEditorApp.NotifyObjPropChanged(
             this,
             new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)),
             ReflectionInfo.Property_Transform_RelativePos,
             ReflectionInfo.Property_Transform_RelativeScale);
     }
 }
Example #17
0
		public void SetCurrentState(CamViewState state)
		{
			if (this.activeState == state) return;
			if (this.activeState != null) this.activeState.OnLeaveState();

			this.activeState = state;
			if (this.activeState != null)
			{
				if (this.stateSelector.Items.Count == 0) this.InitStateSelector();
				this.stateSelector.SelectedIndex = this.stateSelector.Items.IndexOf(this.stateSelector.Items.Cast<StateEntry>().FirstOrDefault(e => e.StateType == this.activeState.GetType()));
			}
			else
				this.stateSelector.SelectedIndex = -1;

			// No glControl yet? We're not initialized properly and this is the initial state. Enter the state later.
			if (this.graphicsControl != null)
			{
				if (this.activeState != null) this.activeState.OnEnterState();
				this.RenderableControl.Invalidate();
			}
		}
Example #18
0
			public StateEntry(Type stateType, CamViewState state)
			{
				this.stateType = stateType;
				this.state = state;
			}