Esempio n. 1
0
    public Material functionalculloff; //this material does not have culling - this is vital for proper rendering
    // Use this for initialization - attach to a hemisphere with regions attached
    void Start()
    {
        thisObject = this.gameObject; //the gameobject is not actually the one that contains the important components - it is the child of the child
        int childNum = thisObject.transform.childCount;

        for (int i = 0; i < childNum; i++)
        {
            Transform child    = thisObject.transform.GetChild(i);
            Transform newchild = child.GetChild(0); //newchild actually contains the important components
            newchild.gameObject.AddComponent <Rigidbody>();
            newchild.gameObject.GetComponent <Rigidbody>().useGravity  = true;
            newchild.gameObject.GetComponent <Rigidbody>().isKinematic = true;              //rigid body is added and set up so the regions can be grabbed and interacted with
            newchild.gameObject.AddComponent <MeshCollider>();                              //collider is also necessary for grabbing
            //  newchild.gameObject.GetComponent<SphereCollider>().radius = 4;
            newchild.transform.name = child.name;                                           //the name is moved from the empty placeholder to the gameobject that actually contains the mesh
            //       newchild.GetComponent<MeshRenderer>().material = culloff;
            newchild.gameObject.GetComponent <MeshRenderer>().material = functionalculloff; //uses the culloff material to render properly
            //for adding original position script
            newchild.gameObject.AddComponent <resetScript>();
            newchild.gameObject.AddComponent <resetColor>();
            newchild.gameObject.AddComponent <States>();            //adds the necessary scripts
            resetScript go  = newchild.GetComponent <resetScript>();
            resetColor  col = newchild.GetComponent <resetColor>(); //sets up the scripts to be called
            col.initialColor();
            go.initialPosition();                                   //calls the scripts to initialize position and color - these can then be reset later
        }
    }
    // Use this for initialization
    void Start()
    {
        thisObject = this.gameObject;                   //this sets the object to be the object the script is attached too
        int childNum = thisObject.transform.childCount; //this gets the number of children - this line is used to get the number of regions in the hemisphere

        for (int i = 0; i < childNum; i++)
        {
            Transform child    = thisObject.transform.GetChild(i); //each region is grabbed
            Transform newchild = child.GetChild(0);                //the actual functional Transform is really the child of an empty placeholder that is automatically generated upon import- this gets the Transform with the necessary components
            newchild.gameObject.AddComponent <Rigidbody>();
            newchild.gameObject.GetComponent <Rigidbody>().useGravity  = true;
            newchild.gameObject.GetComponent <Rigidbody>().isKinematic = true; //the above add a rigidbody and the necesary components - these are required for interaction with the hands
            newchild.gameObject.AddComponent <MeshCollider>();                 //this adds a meshcollider- allows the hands collider to know when interaction is occuring and thus when an object can be grabbed
            //  newchild.gameObject.GetComponent<SphereCollider>().radius = 4;
            newchild.transform.name = child.name;                              //this moves the name of the region from the empty placeholder to the functional Transform
            //       newchild.GetComponent<MeshRenderer>().material = culloff;

            //for adding original position script
            newchild.gameObject.AddComponent <resetScript>();
            newchild.gameObject.AddComponent <resetColor>();        //these add the two listed scripts to each functional group so they can be used
            resetScript go  = newchild.GetComponent <resetScript>();
            resetColor  col = newchild.GetComponent <resetColor>(); //these lines are necessary for actually using the newly attached scripts
            col.initialColor();
            go.initialPosition();                                   //these two lines set the initial qualties of the gameobjects so they can be reset when necessary
        }
    }
    // Use this for initialization
    void Start()
    {
        thisObject = this.gameObject;
        int childNum = thisObject.transform.childCount;

        for (int i = 0; i < childNum; i++)
        {
            Transform child    = thisObject.transform.GetChild(i);
            Transform newchild = child.GetChild(0);
            newchild.gameObject.AddComponent <Rigidbody>();
            newchild.gameObject.GetComponent <Rigidbody>().useGravity  = true;
            newchild.gameObject.GetComponent <Rigidbody>().isKinematic = true;
            newchild.gameObject.AddComponent <MeshCollider>();
            //  newchild.gameObject.GetComponent<SphereCollider>().radius = 4;
            newchild.transform.name = child.name;
            //       newchild.GetComponent<MeshRenderer>().material = culloff;
            newchild.gameObject.GetComponent <MeshRenderer>().material = functionalculloff;
            //for adding original position script
            newchild.gameObject.AddComponent <resetScript>();
            newchild.gameObject.AddComponent <resetColor>();
            newchild.gameObject.AddComponent <States>();
            resetScript go  = newchild.GetComponent <resetScript>();
            resetColor  col = newchild.GetComponent <resetColor>();
            col.initialColor();
            go.initialPosition();
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        resetScript r = this.GetComponent <resetScript>();

        if (this.gameObject.transform.position != r.returninitPos() || this.gameObject.transform.rotation != r.returnRot())
        {
            resetScript res = this.gameObject.GetComponent <resetScript>();
            res.resetPos();
            parse();
        }
    }
Esempio n. 5
0
    public void reset(List <string> arr)
    {
        this.gameObject.AddComponent <resetScript>();
        resetScript r        = this.GetComponent <resetScript>();
        int         numchild = parent.transform.childCount;

        for (int i = 0; i < numchild; i++)
        {
            Transform child = parent.transform.GetChild(i);
            for (int x = 0; x < child.childCount; x++)
            {
                Transform real = child.GetChild(x).GetChild(0);     //gets the actual surface file

                real.GetComponent <Renderer>().material = orig;

                States s = real.GetComponent <States>();
                s.setTransparent(false);
            }
        }
    }
Esempio n. 6
0
    public void Update()
    {
        bool  bothGrab = false;
        float dist1;

        if (grabbedObject != null)
        {
            lastRotation    = currentRotation;
            currentRotation = grabbedObject.transform.rotation;
        }
        if (holding && neighbor.holding)
        {
            if (neighbor.getName() == text.text)
            {
                bothGrab = true;
                dist1    = Vector3.Distance(this.transform.position, neighbor.transform.position);
                expand(dist1, grabbedObject);
            }
        }


        if (/*/!neighbor.holding &&/*/ !grabbing && Input.GetAxis(buttonName) == 1)
        {
            GrabObject();                                                                         //just added the neighbor.holding part
        }
        if (grabbing && Input.GetAxis(buttonName) < 1)
        {
            DropObject(bothGrab);
            if (/*/neighbor.transform.GetChild(2) != null  &&/*/ neighbor.transform.childCount > 2)     //modified 6/10/2018 - then changed to 2 from 1 6/11/2018
            {
                Transform   neiChi   = neighbor.transform.GetChild(2);
                resetScript neiChiRS = neiChi.GetComponent <resetScript>();
                if (neiChi.GetComponent <resetScript>() != null)
                {
                    neiChiRS.resetParent();
                }
            }
        }
        ;
    }
Esempio n. 7
0
 public TextAsset ss;  //somatosensory system
 // Use this for initialization
 void Start()
 {
     this.gameObject.AddComponent <resetScript>();
     resetScript r = this.GetComponent <resetScript>();
 }
Esempio n. 8
0
    public void transformation(List <string> arr)
    {
        this.gameObject.AddComponent <resetScript>();
        resetScript r        = this.GetComponent <resetScript>();
        int         numchild = parent.transform.childCount;

        /*/  for(int i = 0; i < arr.Count; i++)
         * {
         *
         *        arr[i]= arr[i].TrimEnd();   delete this section
         *
         * } /*/

        arr = trim(arr);
        List <Transform> finalcut = new List <Transform>();

        for (int i = 0; i < numchild; i++)
        {
            Transform child = parent.transform.GetChild(i);
            for (int x = 0; x < child.childCount; x++)
            {
                for (int y = 0; y < arr.Count; y++)
                {
                    Transform real = child.GetChild(x).GetChild(0); //gets the actual surface file
                    if (child.GetChild(x).name.Contains(arr[y].TrimEnd()) || (arr[y].TrimEnd()).Contains(child.GetChild(x).name) || string.Equals(arr[y], child.GetChild(x).name) || arr[y].Contains("Lever"))
                    {
                        if (arr[y].Contains("Lever"))
                        {
                            for (int m = 0; m < levs.Length; m++)
                            {
                                if (arr[y] == levs[m].name)
                                {
                                    finalcut.Add(levs[m]);
                                }
                            }
                        }
                        else
                        {
                            finalcut.Add(real);
                        }
                        //   real.GetComponent<Renderer>().material = mat; //sets the material off the component
                        //   real.GetComponent<Renderer>().material.color = col;
                    }
                    else
                    {
                        //     print(child.GetChild(x).name);
                        //    print(real.name);
                        real.GetComponent <Renderer>().material = transparent;
                        States s = real.GetComponent <States>();
                        s.setTransparent(true);  //sets the surface to transparent to prevent laser or hand interaction
                    }
                }
            }
        }
        for (int i = 0; i < finalcut.Count; i++)
        {
            // Color coler = col;

            if (finalcut[i].name.Contains("Lever"))
            {
                for (int x = 0; x < levs.Length; x++)
                {
                    if (levs[x].name == finalcut[i].name)
                    {
                        col = levs[x].GetComponent <TextMesh>().color;
                        //             print("proper lever");
                    }
                }
            }
            //    print(coler);
            else
            {
                States s = finalcut[i].GetComponent <States>();
                s.setTransparent(false);
                finalcut[i].GetComponent <Renderer>().material       = mat;
                finalcut[i].GetComponent <Renderer>().material.color = col;
                resetColor res = finalcut[i].GetComponent <resetColor>();
                res.initialColor();
            }
        }
    }
Esempio n. 9
0
    public void laserCollide(Ray cast, bool txtON)
    {
        raycast = new Ray(transform.position, transform.forward);
        RaycastHit hitInfo;
        bool       hit = Physics.Raycast(cast, out hitInfo, length);

        if (hitInfo.collider != null && hitInfo.collider.gameObject != null)
        {
            if (hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("grabbable"))
            {
                if (hitInfo.collider.gameObject.GetComponent <States>() != null)
                {
                    States s = hitInfo.collider.gameObject.GetComponent <States>();  //just tried adding this section to test for transparency - if transparent should do essentially nothing
                    if (!s.isTransparent())
                    {
                        daLaser.GetComponent <MeshRenderer>().material = laserHitColor;
                        GameObject touchedObject = hitInfo.collider.gameObject;

                        if (/*/originalColor &&/*/ originalObject == null)
                        {
                            //       full = true;
                            laserActivity(touchedObject, txtON);
                        }
                        else if (touchedObject.name != originalObject.name)  //this checks to see if new object reached that is touching old object
                        {
                            resetName();
                            laserDeactivate();
                            laserActivity(touchedObject, txtON);
                        }

                        if (OVRInput.Get(OVRInput.Button.One))  //raises the object in chunks
                        {
                            Vector3 m = touchedObject.transform.position;
                            float   y = m.y;
                            y   = y + 0.006f;
                            m.y = y;
                            touchedObject.transform.position = m;
                            touchedObject.GetComponent <Rigidbody>().useGravity      = false;
                            touchedObject.GetComponent <Rigidbody>().velocity        = Vector3.zero;
                            touchedObject.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
                            //    touchedObject.transform.parent = transform;
                            //    touchedObject.transform.position = transform.position;
                        }
                        if (OVRInput.Get(OVRInput.Button.Two))  //moves object to the hand with the laser
                        {
                            grabbedObject = touchedObject;
                            grabbedObject.transform.parent = transform;
                            //   grabbedObject.transform.position = transform.position;
                            //print(Vector3.MoveTowards(grabbedObject.transform.position, transform.position, 0.05f));
                            grabbedObject.transform.position = Vector3.MoveTowards(grabbedObject.transform.position, transform.position, 0.05f);

                            grabbedObject.transform.parent = null;
                            grabbedObject.GetComponent <Rigidbody>().velocity        = Vector3.zero;
                            grabbedObject.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
                            grabbedObject.GetComponent <Rigidbody>().useGravity      = false;
                        }
                        if (OVRInput.Get(OVRInput.Button.Three)) //this activates the reset script so the object returns to its original position
                        {
                            resetScript go = touchedObject.GetComponent <resetScript>();
                            go.activate();
                        }
                        if (touchedObject.GetComponent <TMPro.Examples.FloatText>() != null)
                        {
                            //         Destroy(touchedObject.GetComponent<TMPro.Examples.FloatText>(), 2);
                        }
                        if (txtON && floatHer < 1 && touchedObject.GetComponent <TMPro.Examples.FloatText>() == null)
                        {
                            touchedObject.AddComponent <TMPro.Examples.FloatText>();
                            TMPro.Examples.FloatText t = touchedObject.GetComponent <TMPro.Examples.FloatText>();
                            t.floatStart(touchedObject.name, touchedObject.GetComponent <Renderer>().material.color);
                            floatHer = floatHer += 1;
                        }
                    }
                    else
                    {
                        daLaser.GetComponent <Renderer>().material = laserColor;
                        if (/*/!originalColor&&/*/ originalObject != null)
                        {
                            resetName();   //these were commented out on 2/12/2018
                            laserDeactivate();
                        }
                    }
                }
            }
        }
        else if (/*/!originalColor &&/*/ originalObject != null)
        {
            laserDeactivate();
            resetName();
        }
        if (hitInfo.collider == null || hitInfo.collider.gameObject == null)
        {
            daLaser.GetComponent <MeshRenderer>().material = laserColor;
        }
    }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        thisObject = this.gameObject;
        int childNum = thisObject.transform.childCount;

        for (int i = 0; i < childNum; i++)
        {
            Transform child    = thisObject.transform.GetChild(i);
            Transform newchild = child.GetChild(0);
            newchild.gameObject.AddComponent <Rigidbody>();
            newchild.gameObject.GetComponent <Rigidbody>().useGravity  = true;
            newchild.gameObject.GetComponent <Rigidbody>().isKinematic = true;
            newchild.gameObject.AddComponent <MeshCollider>();
            // newchild.gameObject.GetComponent<SphereCollider>().radius = 4;
            newchild.transform.name = child.name;
            newchild.GetComponent <MeshRenderer>().material = culloff;
            // newchild.gameObject.AddComponent<FlipMesh>();
            newchild.gameObject.AddComponent <resetScript>();
            newchild.gameObject.AddComponent <resetColor>();
            newchild.gameObject.AddComponent <RenameScript>();
            newchild.gameObject.AddComponent <States>();
            resetScript  go     = newchild.GetComponent <resetScript>();
            RenameScript rename = newchild.GetComponent <RenameScript>();
            go.initialPosition();
        }
        for (int i = 0; i < childNum; i++)
        {
            Transform child    = thisObject.transform.GetChild(i);
            Transform newchild = child.GetChild(0);
            if (child.name == "rh.bankssts")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(25, 100, 40, 0);
            }
            else if (child.name == "rh.caudalanteriorcingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(125, 100, 160, 0);
            }
            else if (child.name == "rh.caudalmiddlefrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(100, 25, 0, 0);
            }
            else if (child.name == "rh.corpuscallosum")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(120, 70, 50, 0);
            }
            else if (child.name == "rh.cuneus")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 20, 100, 0);
            }
            else if (child.name == "rh.entorhinal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 20, 10, 0);
            }
            else if (child.name == "rh.fusiform")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(180, 220, 140, 0);
            }
            else if (child.name == "rh.inferiorparietal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 60, 220, 0);
            }
            else if (child.name == "rh.inferiortemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(180, 40, 120, 0);
            }
            else if (child.name == "rh.isthmuscingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(140, 20, 140, 0);
            }
            else if (child.name == "rh.lateraloccipital")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 30, 140, 0);
            }
            else if (child.name == "rh.lateralorbitofrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(35, 75, 50, 0);
            }
            else if (child.name == "rh.lingual")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(225, 140, 140, 0);
            }
            else if (child.name == "rh.medialorbitofrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(200, 35, 75, 0);
            }
            else if (child.name == "rh.middletemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(160, 100, 50, 0);
            }
            else if (child.name == "rh.parahippocampal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 220, 60, 0);
            }
            else if (child.name == "rh.paracentral")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(60, 220, 60, 0);
            }
            else if (child.name == "rh.parsopercularis")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 180, 140, 0);
            }
            else if (child.name == "rh.parsorbitalis")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 100, 50, 0);
            }
            else if (child.name == "rh.parstriangularis")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 60, 20, 0);
            }
            else if (child.name == "rh.pericalcarine")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(120, 100, 60, 0);
            }
            else if (child.name == "rh.postcentral")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 20, 20, 0);
            }
            else if (child.name == "rh.posteriorcingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(220, 180, 220, 0);
            }
            else if (child.name == "rh.precentral")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(60, 20, 220, 0);
            }
            else if (child.name == "rh.precuneus")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(160, 140, 180, 0);
            }
            else if (child.name == "rh.rostralanteriorcingulate")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(80, 20, 140, 0);
            }
            else if (child.name == "rh.rostralmiddlefrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(75, 50, 125, 0);
            }
            else if (child.name == "rh.superiorfrontal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 220, 160, 0);
            }
            else if (child.name == "rh.superiorparietal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(20, 180, 140, 0);
            }
            else if (child.name == "rh.superiortemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(140, 220, 220, 0);
            }
            else if (child.name == "rh.supramarginal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(80, 160, 20, 0);
            }
            else if (child.name == "rh.frontalpole")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(100, 0, 100, 0);
            }
            else if (child.name == "rh.temporalpole")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(70, 70, 70, 0);
            }
            else if (child.name == "rh.transversetemporal")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(150, 150, 200, 0);
            }
            else if (child.name == "rh.insula")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(255, 192, 32, 0);
            }
            else if (child.name == "rh.unlabelled")
            {
                newchild.GetComponent <MeshRenderer>().material.color = new Color32(25, 5, 25, 0);
            }
            resetColor   col    = newchild.GetComponent <resetColor>();
            RenameScript rename = newchild.GetComponent <RenameScript>();
            newchild.name = rename.reName(newchild.name, "Right");
            col.initialColor();
        }
    }