1 using System.Collections;
2 using System.Collections.Generic;
25 protected override void Start() {
27 if(!handVisual) handVisual = transform.parent.GetComponentInChildren<
AVR_Hand>();
28 grabbedObjectCenter =
new GameObject(
"grabbedObjectCenter").transform;
29 grabbedObjectCenter.SetParent(grabPoint);
34 return grabbedObjectCenter.position;
39 return grabbedObjectCenter.rotation;
44 return grabbedObjectCenter;
50 if (handVisual != null) StartCoroutine(unsetHand());
54 base.makeGrab(location);
55 if(grabbedObject!=null)
59 grabbedObjectCenter.rotation = location.node.get_target_rotation(handVisual.transform.rotation);
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;
70 grabbedObjectCenter.rotation = location.grabbable.transform.rotation;
71 grabbedObjectCenter.position = grabPoint.position + (location.grabbable.transform.position - location.location);
74 if(handVisual) StartCoroutine(setHand());
80 if (IsOnline && !IsOwner)
return;
83 if (grabbedObject == null && handVisual != null && grabbableFinder.getGrabLocation(out
GrabLocation grabLocation) && !grabLocation.isNode)
85 handVisual.SqueezeOn(grabLocation.collider, grabPoint.position - grabLocation.location);
88 Vector3 far_away = 100.0f * (grabLocation.location - grabPoint.position);
89 Vector3 smth = grabbableFinder.closestPoint(far_away);
90 float entrydist = Vector3.Distance(smth, grabPoint.position);
91 float currentdist = Vector3.Distance(grabPoint.position, grabLocation.location);
93 float max_pregrab_adapt_factor = 0.35f;
94 float max_pregrab_grace_dist = 0.03f;
95 float w = Mathf.Max(0, max_pregrab_adapt_factor - (Mathf.Max(0, currentdist - max_pregrab_grace_dist) / entrydist));
97 handVisual.SetSqueezeWeight(w);
100 else if (grabbedObject == null && handVisual)
112 handVisual.disableColliders();
114 yield
return new WaitForSecondsRealtime(Time.fixedDeltaTime + 0.01f);
116 yield
return new WaitUntil(() => Vector3.Distance(grabbedObject.transform.position, getTargetPosition()) < 0.05f);
120 if(grabLocation.isNode) {
121 handVisual.ApplyNodePose(grabLocation.node);
125 handVisual.SqueezeOn(grabbedObject);
126 handVisual.SetSqueezeWeight(1.0f);
128 handVisual.SetFakeParent(grabbedObject.transform);
133 handVisual.enableColliders();
135 handVisual.UnsetFakeParent();
139 yield
return new WaitForEndOfFrame();
virtual IEnumerator setHand()
virtual IEnumerator unsetHand()
override Transform getTargetTransform()
getTargetPosition() and getTargetRotation() combined into one transform. The grabbed objects transfor...
Represents an (attempted) grab at a given location of an object.
override Quaternion getTargetRotation()
Target rotation the grabbed object should "strive" towards in world space. There will be force trying...
override void makeGrab(GrabLocation location)
Perform a grab on with parameters given in a GrabLocation struct
override Vector3 getTargetPosition()
Target position the grabbed object should "strive" towards in world coordiantes. There will be force ...
Transform grabbedObjectCenter
Location an rotation the grabbed objects transform will strive to adopt. Eg: if we grab a pan by its ...
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
Simplest GrabProvider. Grabbed objects will move their center (obj.transform.position) towards the re...
AVR_Hand handVisual
HandVisual
Interactive hand model that adapts itself to grabbed objects. Only works with Offset- or AdvancedOffs...
Same as BasicGrabProvider but additionally allows grabbing objects at an offset. (Eg. you may grab a pan by its handle instead of just its center) Also allows the usage of an AVR_Hand. Use this if you require grabbing larger / more complex objects.
override void makeRelease()
Ends a grab. Is called when the respective "releaseEvent" is true.