VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
override void AVR.Phys.AVR_OffsetGrabProvider.makeGrab ( GrabLocation  location)
inlinevirtual

Perform a grab on with parameters given in a GrabLocation struct

Reimplemented from AVR.Phys.AVR_BasicGrabProvider.

Definition at line 53 of file AVR_OffsetGrabProvider.cs.

53  {
54  base.makeGrab(location);
55  if(grabbedObject!=null)
56  {
57  // Set desired rotation
58  if(location.isNode) {
59  grabbedObjectCenter.rotation = location.node.get_target_rotation(handVisual.transform.rotation);
60 
61  // We need to find out the position offset *under the above given rotation*. For these purposes we temporarily apply the rotation to location.grabbable,
62  // then undo it again right afterwards.
63  Quaternion tmp = location.grabbable.transform.rotation;
64  location.grabbable.transform.rotation = grabbedObjectCenter.rotation;
65  grabbedObjectCenter.position = grabPoint.position + (location.grabbable.transform.position - location.location);
66  location.grabbable.transform.rotation = tmp;
67  }
68  else
69  {
70  grabbedObjectCenter.rotation = location.grabbable.transform.rotation;
71  grabbedObjectCenter.position = grabPoint.position + (location.grabbable.transform.position - location.location);
72  }
73 
74  if(handVisual) StartCoroutine(setHand());
75  }
76  }
AVR_Grabbable grabbedObject
Object that is currently being grabbed. Null if no object is being grabbed