AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
RigidbodyExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 #if UNITY_WSA && UNITY_2017_2_OR_NEWER
5 using UnityEngine;
6 using UnityEngine.XR.WSA.Input;
7 
8 namespace HoloToolkit.Unity.InputModule.Examples.Grabbables
9 {
10  public static class RigidbodyExtensions
11  {
12  public static ControllerReleaseData GetThrowReleasedVelocityAndAngularVelocity(this Rigidbody _rigidbody, Vector3 centerOfMassOfRigidbody, InteractionSourcePose poseInfo)
13  {
14  Vector3 setVel = default(Vector3);
15  Vector3 angVel = default(Vector3);
16  Vector3 controllerPos = default(Vector3);
17  Vector3 controllerVelocity = default(Vector3);
18  Vector3 controllerAngularVelocity = default(Vector3);
19  poseInfo.TryGetPosition(out controllerPos);
20  poseInfo.TryGetVelocity(out controllerVelocity);
21  poseInfo.TryGetAngularVelocity(out controllerAngularVelocity);
22  float dist = Vector3.Distance(centerOfMassOfRigidbody, controllerPos);
23 
24  //vel = velocityOfController + angularVelOfController * distBetween grabbable center of mass and controllerPos;
25  //setVel = controllerVelocity + controllerAngularVelocity + (controllerAngularVelocity *-1) * dist;
26  setVel = controllerVelocity;
27  Debug.Log(" SetVal = ControllerVelocity ( " + controllerVelocity + ") controllerAngVel ((" + controllerAngularVelocity + ") * -1 )" + " * dist (" + dist + ")");
28 
29  return new ControllerReleaseData(setVel, angVel);
30  }
31  }
32 }
33 #endif