VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
AVR_GrabbableFinder.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
5 using AVR.Core;
6 
7 namespace AVR.Phys {
8  /// <summary>
9  /// Represents an (attempted) grab at a given location of an object.
10  /// </summary>
11  public class GrabLocation
12  {
13  public AVR_Grabbable grabbable; // Owner object
14  public Vector3 location => isNode ? node.transform.position : grabbable.transform.TransformPoint(_llocation); // Location being grabbed
15  public Vector3 localLocation => _llocation;
16  public float distance; // Distance between grabbed location and grab-point/hand
17 
18  private Vector3 _llocation;
19 
20  public bool isNode; // Are we grabbing a node or a collider?
21  public Collider collider; // Collider we are grabbing. Null of we grab a node
22  public AVR_GrabNode node; // Node we are grabbing. Null if we grab a collider.
23 
24  public GrabLocation(AVR_Grabbable grabbable, Vector3 location, float distance, Collider collider)
25  {
26  this.grabbable = grabbable;
27  this._llocation = grabbable.transform.InverseTransformPoint(location);
28  this.distance = distance;
29  this.collider = collider;
30  this.node = null;
31  isNode = false;
32  }
33 
34  public GrabLocation(AVR_Grabbable grabbable, Vector3 location, float distance, AVR_GrabNode node)
35  {
36  this.grabbable = grabbable;
37  this._llocation = grabbable.transform.InverseTransformPoint(location);
38  this.distance = distance;
39  this.collider = null;
40  this.node = node;
41  isNode = true;
42  }
43  }
44 
45  /// <summary>
46  /// Class to retrieve a Grabbable object from a location, volume or similar.
47  /// </summary>
48  [AVR.Core.Attributes.DocumentationUrl("class_a_v_r_1_1_phys_1_1_a_v_r___grabbable_finder.html")]
49  public abstract class AVR_GrabbableFinder : AVR_Component
50  {
51  public abstract bool getGrabLocation(out GrabLocation location);
52 
53  // Returns the closest location inside the "valid grabzone". This is used by the likes of OffsetGrabProvider
54  // for pre-grab hand movement and such
55  public virtual Vector3 closestPoint(Vector3 pos) {
56  return transform.position;
57  }
58  }
59 }
GrabLocation(AVR_Grabbable grabbable, Vector3 location, float distance, AVR_GrabNode node)
Represents an (attempted) grab at a given location of an object.
Represents a grabbable object.
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
GrabLocation(AVR_Grabbable grabbable, Vector3 location, float distance, Collider collider)
Represents a grabbable node on an AVR_Grabbable. Nodes have preset poses/constraints for the hand tha...
Definition: AVR_GrabNode.cs:15
virtual Vector3 closestPoint(Vector3 pos)
Base class for all arc-vr components. A component is typically a Monobehaviour that represents a virt...
Class to retrieve a Grabbable object from a location, volume or similar.