示例#1
0
 void Start()
 {
     SphereCollider.SetActive(false);
     if (SensoHandExample == null)
     {
         SensoHandExample = this.gameObject.GetComponent <SensoHandExample>();
     }
 }
示例#2
0
    public void OnTriggerStay(Collider col)
    {
        if (col.gameObject.GetComponentInParent <SensoHandExample>())
        {
            if (!Grabbed && !Pinched)
            {
                SensoHandExample = col.gameObject.GetComponentInParent <SensoHandExample>();
                gesture          = SensoHandExample.gameObject.GetComponent <Gestures>();
            }
            if (!gesture.PinchedOrGrabbed)
            {
                if (((SensoHandExample.HandType == Senso.EPositionType.RightHand) || (SensoHandExample.HandType == Senso.EPositionType.LeftHand)) && gesture.grab && Grab && col.gameObject.tag == "InteractableHand")
                {
                    if (Grabbed == false)
                    {
                        if (col.gameObject.TryGetComponent(out rb))
                        {
                            rb.isKinematic = true;
                            rb.useGravity  = false;
                        }

                        else
                        {
                            rb             = col.gameObject.AddComponent <Rigidbody>();
                            rb.isKinematic = true;
                            rb.useGravity  = false;
                        }
                        CreateJoint(col.gameObject);
                        Grabbed = true;
                        gesture.PinchedOrGrabbed = true;
                    }
                }

                else if (col.gameObject.tag == "InteractableFinger" && gesture.pinch && Pinch)
                {
                    if (Pinched == false)
                    {
                        if (col.gameObject.TryGetComponent(out rb))
                        {
                            rb.isKinematic = true;
                            rb.useGravity  = false;
                        }

                        else
                        {
                            rb             = col.gameObject.AddComponent <Rigidbody>();
                            rb.isKinematic = true;
                            rb.useGravity  = false;
                        }
                        CreateJoint(col.gameObject);
                        Pinched = true;
                        gesture.PinchedOrGrabbed = true;
                    }
                }
            }
        }
    }
示例#3
0
    public bool seen, active, sent;    // Whether the user is looking at this specific group of planes;  If the user is controlling the effects with the Senso Gloves; If MIDI CC number was already sent to SendMax


    // Start is called before the first frame update
    void Start()
    {
        //Load up materials for planes
        mats = new List <Material>();
        mats.Add(GameObject.Find("Materials/C1").GetComponent <Renderer>().material); // Default material of the plane
        mats.Add(GameObject.Find("Materials/C2").GetComponent <Renderer>().material); // When the plane is at the center of the HMD's view
        mats.Add(GameObject.Find("Materials/C3").GetComponent <Renderer>().material); // When the plane is also being used to control MIDI CC effects

        //Get SendMax
        max     = GameObject.Find("MaxSender");
        sendmax = max.GetComponent <SendMax>();


        active = true; //Start with using OpenBCI data to change

        children = new List <GameObject>();
        hands    = GameObject.Find("[CameraRig]/Right Hand Container");
        handData = hands.GetComponent <SensoHandExample>();
        c        = 0; //Timer for switching planes
        t        = 0; //Counter for when a plane is being seen, but no control of MIDI CC is happening
        curr     = 0; //Current plane being shown


        //Adding planes to children list
        Transform[] tr = gameObject.GetComponentsInChildren <Transform>();
        foreach (Transform c in tr)
        {
            if (c.name.StartsWith("Plane") && c != tr[0]) // We ignore the first object, because it is the parent object

            {
                children.Add(c.gameObject); // Add object if it has "Plane" in the name

                // Make all planes invisible
                c.gameObject.GetComponent <Renderer>().enabled         = false;
                c.gameObject.GetComponentInChildren <Canvas>().enabled = false;
            }
        }
        length = children.Count; //Length of list

        //Adding the other plane groups
        foreach (GameObject obj in FindObjectsOfType(typeof(GameObject)) as GameObject[])
        {
            if (obj.name.Contains("Planes"))
            {
                planes.Add(obj);
            }
        }
    }
示例#4
0
    // Start is called before the first frame update
    void Start()
    {
        OSCHandler.Instance.Init();

        // Initialize OSC clients (transmitters)
        OSCHandler.Instance.CreateClient("myClient", IPAddress.Parse(outIP), outPort);
        initVals();

        //BCI object and script
        bci     = GameObject.Find("OpenBCI");
        bcidata = bci.GetComponent <OpenBCIData>();

        //Only using right hand
        rightGlove = GameObject.Find("[CameraRig]/Right Hand Container");
        rGloveData = rightGlove.GetComponent <SensoHandExample>();
    }