VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Quaternion AVR.Phys.AVR_Grabbable.getTargetRotation ( )
inlineprivate

Definition at line 291 of file AVR_Grabbable.cs.

291  {
292  if (!isGrabbed) {
293  return transform.rotation;
294  }
295  else if (AttachedHands.Count == 1) {
296  return AttachedHands[0].getTargetRotation();
297  }
298  else {
299  // TODO: This sometimes leads to weird rotations.
300  // This is the simplest way to get the average of multiple quaternions:
301  float w = 1f / AttachedHands.Count;
302  Quaternion avg = Quaternion.identity;
303  for (int i = 0; i < AttachedHands.Count; i++)
304  {
305  Quaternion q = AttachedHands[i].getTargetRotation();
306  avg *= Quaternion.Slerp(Quaternion.identity, q, w);
307  }
308  return avg;
309  }
310  }
bool isGrabbed
True if the object is being grabbed, otherwise false.
List< AVR_BasicGrabProvider > AttachedHands
List of hands that are currently grabbing this object.