public bool Grab(Body other) { if (!IsGrabbed(other) && GrabbedComponents.Count < MaxGrabs) { Matrix m = Matrix.Identity; m = GlobalTransform; m.Translation = GlobalTransform.Translation + new Vector3(0, 0.0f, 0.5f); other.GlobalTransform = m; GrabbedItem item = new GrabbedItem { Component = other, LocalTransform = Matrix.Invert(GlobalTransform) * other.GlobalTransform }; GrabbedComponents.Add(item); other.LocalTransform = item.LocalTransform; AddChild(other); return(true); } else { return(false); } }
private void HandleStartGrab() { GrabbedItem = GrabPreview.Grabbable; if (GrabPreview.WasThumbnail) { PreviewBox.StartThumbnailGrab(); GrabbedItem.StartThumbGrab(); } else { PreviewBox.StartGrab(); GrabbedItem.StartGrab(); } }
private void HandleStopGrabbing() { PreviewBox.EndGrab(); GrabbedItem.EndGrab(); GrabbedItem = null; }
public bool Grab(Body other) { if(!IsGrabbed(other) && GrabbedComponents.Count < MaxGrabs) { Matrix m = Matrix.Identity; m = GlobalTransform; m.Translation = GlobalTransform.Translation + new Vector3(0, 0.0f, 0.5f); other.GlobalTransform = m; GrabbedItem item = new GrabbedItem { Component = other, LocalTransform = Matrix.Invert(GlobalTransform) * other.GlobalTransform }; GrabbedComponents.Add(item); other.LocalTransform = item.LocalTransform; AddChild(other); return true; } else { return false; } }