/** Moves the object kinematically. */
 public override void MoveTo(ReadonlyList<Hand> hands, PhysicsMoveInfo info, Vector3 solvedPosition, Quaternion solvedRotation) {
   if (info.shouldTeleport) {
     _obj.warper.Teleport(solvedPosition, solvedRotation);
   } else {
     _obj.rigidbody.MovePosition(solvedPosition);
     _obj.rigidbody.MoveRotation(solvedRotation);
   }
 }
Beispiel #2
0
        protected override void OnHandsHoldPhysics(ReadonlyList <Hand> hands)
        {
            base.OnHandsHoldPhysics(hands);

            PhysicsMoveInfo info = new PhysicsMoveInfo();

            info.remainingDistanceLastFrame = Vector3.Distance(_warper.RigidbodyPosition, _solvedPosition);
            info.shouldTeleport             = _notifiedOfTeleport;

            _controllers.HoldingPoseController.GetHoldingPose(hands, out _solvedPosition, out _solvedRotation);

            _controllers.MoveToController.MoveTo(hands, info, _solvedPosition, _solvedRotation);

            if (_controllers.ThrowingController != null)
            {
                _controllers.ThrowingController.OnHold(hands);
            }
        }
    /** Moves the object by applying  forces and torque. */
    public override void MoveTo(ReadonlyList<Hand> hands, PhysicsMoveInfo info, Vector3 solvedPosition, Quaternion solvedRotation) {
      if (info.shouldTeleport) {
        _obj.warper.Teleport(solvedPosition, solvedRotation);
      } else {
        Vector3 targetVelocity = PhysicsUtility.ToLinearVelocity(_obj.warper.RigidbodyPosition, solvedPosition, Time.fixedDeltaTime);
        Vector3 targetAngularVelocity = PhysicsUtility.ToAngularVelocity(_obj.warper.RigidbodyRotation, solvedRotation, Time.fixedDeltaTime);

        float targetSpeedSqrd = targetVelocity.sqrMagnitude;
        if (targetSpeedSqrd > _maxVelocitySqrd) {
          float targetPercent = (_maxVelocity * _obj.Manager.SimulationScale) / Mathf.Sqrt(targetSpeedSqrd);
          targetVelocity *= targetPercent;
          targetAngularVelocity *= targetPercent;
        }

        float followStrength = _strengthByDistance.Evaluate(info.remainingDistanceLastFrame / _obj.Manager.SimulationScale);
        Vector3 lerpedVelocity = Vector3.Lerp(_obj.rigidbody.velocity, targetVelocity, followStrength);
        Vector3 lerpedAngularVelocity = Vector3.Lerp(_obj.rigidbody.angularVelocity, targetAngularVelocity, followStrength);

        Vector3 centerOfMassOffset = _obj.warper.RigidbodyRotation * _obj.rigidbody.centerOfMass;
        _obj.rigidbody.velocity = lerpedVelocity + Vector3.Cross(lerpedAngularVelocity, centerOfMassOffset);
        _obj.rigidbody.angularVelocity = lerpedAngularVelocity;
      }
    }
    protected override void OnHandsHoldPhysics(ReadonlyList<Hand> hands) {
      base.OnHandsHoldPhysics(hands);

      PhysicsMoveInfo info = new PhysicsMoveInfo();
      info.remainingDistanceLastFrame = Vector3.Distance(_warper.RigidbodyPosition, _solvedPosition);
      info.shouldTeleport = _notifiedOfTeleport;

      _controllers.HoldingPoseController.GetHoldingPose(hands, out _solvedPosition, out _solvedRotation);

      _controllers.MoveToController.MoveTo(hands, info, _solvedPosition, _solvedRotation);

      if (_controllers.ThrowingController != null) {
        _controllers.ThrowingController.OnHold(hands);
      }
    }
 /**
 * Move the interactable object to or towards the Interaction Engine's desired position.
 * 
 * @param hands the list of Leap.Hand objects involved in the interaction.
 * @param info hints about the move.
 * @param solvedPosition the target position calculated by the Interaction Engine.
 * @param solvedRotation the target rotation calculated by the Interaction Engine.
 * @since 4.1.4
 */
 public abstract void MoveTo(ReadonlyList<Hand> hands, PhysicsMoveInfo info, Vector3 solvedPosition, Quaternion solvedRotation);
Beispiel #6
0
 /**
  * Move the interactable object to or towards the Interaction Engine's desired position.
  *
  * If info.shouldTeleport is true, this function must move the object using a teleport-style
  * movement, ie.e by changing the transform.position and transform.rotation, or the
  * RigidBody.position and RigidBody.rotation properties directly. InteractionBehaviour.NotifyTeleport() does
  * not be called in MoveTo().
  *
  * If info.shouldTeleport is false, this function must move the object using linear and angular
  * forces and velocities.
  *
  * @param hands the list of Leap.Hand objects involved in the interaction.
  * @param info hints about the move.
  * @param solvedPosition the target position calculated by the Interaction Engine.
  * @param solvedRotation the target rotation calculated by the Interaction Engine.
  * @since 4.1.4
  */
 public abstract void MoveTo(ReadonlyList <Hand> hands, PhysicsMoveInfo info, Vector3 solvedPosition, Quaternion solvedRotation);