public float GetMultiplier(SolarSystemSimulator.CometState comet) { if (ie.isGrasped) { return(0); } if (_isPinched) { return(0); } float minDist = distanceToMultiplier.y; foreach (var hand in provider.CurrentFrame.Hands) { float grabDist = Mathf.Min(Vector3.Distance(hand.PalmPosition.ToVector3(), transform.position), Vector3.Distance(hand.GetIndex().TipPosition.ToVector3(), transform.position)); float pinchDist = Mathf.Min(Vector3.Distance(hand.GetPredictedPinchPosition(), speedHandle.position), Vector3.Distance(hand.GetIndex().TipPosition.ToVector3(), speedHandle.position)); minDist = Mathf.Min(grabDist, minDist); minDist = Mathf.Min(pinchDist, minDist); } return(Mathf.InverseLerp(distanceToMultiplier.x, distanceToMultiplier.y, minDist)); }
public void UpdateState(SolarSystemSimulator.CometState comet) { transform.localPosition = displayAnchor.TransformPoint(comet.position); transform.localRotation = displayAnchor.TransformRotation(Quaternion.LookRotation(comet.velocity)); rotationAnchor.localRotation = Quaternion.identity; float dist = comet.velocity.magnitude * speedToDistance; speedHandle.localPosition = new Vector3(0, 0, dist); rodHandle.localScale = new Vector3(1, 1, dist); }
public bool GetModifiedState(ref SolarSystemSimulator.CometState comet) { if (ie.isGrasped || _isPinched) { comet.position = displayAnchor.InverseTransformPoint(transform.position); comet.velocity = displayAnchor.InverseTransformDirection(rotationAnchor.rotation * Vector3.forward) * speedHandle.localPosition.z / speedToDistance; return(true); } else { return(false); } }