public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers) { State state = _state as State; if (state == null) { return(null); } ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (modifiers == Keys.Shift) { mparams.KeepAspectRatio = true; } if (button == System.Windows.Forms.MouseButtons.Right) { result.Target = state; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Bounds.X, location.Y - state.Bounds.Y); } else { mparams.CornerGrabbed = state.HandleAtLocation(location); if (mparams.CornerGrabbed == -1) { return(null); } result.Target = state; mparams.AbsoluteDrag = false; } return(result); }
public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers, bool fromEditor) { State state = _state as State; if (state == null) { return(null); } ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (fromEditor) { mparams.DisableIK = true; } if (button == MouseButtons.Right) { result.Target = state.Root; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Root.Location.X, location.Y - state.Root.Location.Y); } else { Joint.State target = state.Root.JointAtLocation(location); if (target == null) { return(null); } result.Target = target; mparams.AbsoluteDrag = false; } return(result); }
public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers) { State state = _state as State; if (state == null) return null; ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (button == System.Windows.Forms.MouseButtons.Right) { result.Target = state; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Bounds.X, location.Y - state.Bounds.Y); } else { mparams.CornerGrabbed = state.HandleAtLocation(location); if (mparams.CornerGrabbed == -1) return null; result.Target = state; mparams.AbsoluteDrag = false; } return result; }
public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers) { State state = _state as State; if (state == null) return null; ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (button == System.Windows.Forms.MouseButtons.Right) { result.Target = state; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Location.X, location.Y - state.Location.Y); } else { if (!MathUtil.IsPointInPoint(location, state.Location, 4)) return null; result.Target = state; mparams.AbsoluteDrag = false; } return result; }
public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers) { State state = _state as State; if (state == null) return null; ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; mparams.AbsoluteOffset = new List<PointF>(); if (button == System.Windows.Forms.MouseButtons.Right) { result.Target = state; mparams.AbsoluteDrag = true; for(int i = 0; i < state.Points.Count; i++) mparams.AbsoluteOffset.Add(new PointF(location.X - state.Points[i].X, location.Y - state.Points[i].Y)); } else { for (int i = 0; i < state.Points.Count; i++) { if (MathUtil.IsPointInPoint(location, state.Points[i], 4)) { result.Target = state.Points[i]; mparams.PointIndex = i; } } if (result.Target == null) return null; result.Target = state; mparams.AbsoluteDrag = false; } return result; }
public ManipulateResult TryManipulate(IEntityState _state, Point location, MouseButtons button, Keys modifiers) { State state = _state as State; if (state == null) { return(null); } ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (modifiers == Keys.Shift) { mparams.PivotDrag = true; } else if (modifiers == Keys.Alt) { mparams.DisableIK = true; } if (button == MouseButtons.Right) { result.Target = state.Root; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Root.Location.X, location.Y - state.Root.Location.Y); } else { Joint.State target = state.Root.JointAtLocation(location); if (target == null) { return(null); } if (mparams.PivotDrag && target.Parent != null) { mparams.PivotLength = (float)MathUtil.Length(target.Location, target.Parent.Location); mparams.PivotAngle = (float)MathUtil.Angle(target.Location, target.Parent.Location); // you need to go through every descendant (not child) of target here and store their angle and distance to target's parent mparams.PivotInfo = new Dictionary <Joint.State, Tuple <float, float> >(); Stack <Joint.State> open = new Stack <Joint.State>(); open.Push(target); while (open.Count > 0) { Joint.State current = open.Pop(); foreach (Joint.State child in current.Children) { open.Push(child); float distance = (float)MathUtil.Length(target.Parent.Location, child.Location); float angle = (float)MathUtil.Angle(child.Location, target.Parent.Location); // or the other way around, depends mparams.PivotInfo[child] = new Tuple <float, float>(distance, angle); } } } result.Target = target; mparams.AbsoluteDrag = false; } return(result); }