Exemplo n.º 1
0
 public void changeSubject(GameObject newSubject)
 {
     if (subject != null)
     {
         if (subjectManipHandler != null)
         {
             subjectManipHandler.release();
         }
         subject.transform.SetParent(subjectPreviousParent);
     }
     subject = newSubject;
     if (subject == null)
     {
         subjectManipHandler   = null;
         subjectPreviousParent = null;
     }
     else
     {
         subjectManipHandler   = subject.GetComponent <FocalPointVR_ManipulationHandler>();
         subjectPreviousParent = subject.transform.parent;
     }
     foreach (Light l in selectionHighlighters)
     {
         l.gameObject.SetActive(subject != null);
     }
 }
 void Update()
 {
     // TODO -- this is quite inefficient -- would be interested in a better implementation
     controllerIndex = steamTrackedObj.index.GetHashCode();
     if (SteamVR_Controller.Input(controllerIndex).GetPressDown(SteamVR_Controller.ButtonMask.Grip))
     {
         if (syndromeMode)
         {
             pointGenerator.ClosePlate();
         }
         else
         {
             pointGenerator.ClosePincer();
         }
     }
     if (SteamVR_Controller.Input(controllerIndex).GetPressUp(SteamVR_Controller.ButtonMask.Grip))
     {
         if (syndromeMode)
         {
             pointGenerator.OpenPlate();
         }
         else
         {
             pointGenerator.OpenPincer();
         }
     }
     if (SteamVR_Controller.Input(controllerIndex).GetHairTriggerDown())
     {
         setSelectionMode(true);
     }
     if (SteamVR_Controller.Input(controllerIndex).GetHairTriggerUp())
     {
         setSelectionMode(false);
     }
     if (selectionMode)
     {
         Ray          selectionRay = new Ray(transform.position, transform.forward);
         RaycastHit[] hits;
         hits = Physics.RaycastAll(selectionRay);
         float closestDistance = 999999999.9f;
         hoveredSubject = null;
         foreach (RaycastHit hit in hits)
         {
             // TODO: there has to be a better way...
             if (hit.distance < closestDistance)
             {
                 FocalPointVR_ManipulationHandler manipHandler = hit.collider.gameObject.GetComponent <FocalPointVR_ManipulationHandler>();
                 if (manipHandler != null && manipHandler.isSelectable)
                 {
                     closestDistance = hit.distance;
                     hoveredSubject  = hit.collider.gameObject;
                 }
             }
         }
     }
     if (SteamVR_Controller.Input(controllerIndex).GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x > 0.999f)
     {
         if (ixdManager.subject != hoveredSubject && hoveredSubject != null)
         {
             ixdManager.changeSubject(hoveredSubject);
         }
     }
 }
Exemplo n.º 3
0
 void Start()
 {
     col          = GetComponent <Collider>();
     rbody        = GetComponent <Rigidbody>();
     manipHandler = GetComponent <FocalPointVR_ManipulationHandler>();
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     initializationTime = Time.time;
     manipHandler       = GetComponent <FocalPointVR_ManipulationHandler>();
 }