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 } }
public void highlightRegions(GameObject t) { for (int i = 0; i < a.Length; i++) { Transform child = a[i].transform.GetChild(0); // child.GetComponent<Renderer>().material = (Material)Instantiate(mat); child.GetComponent <Renderer>().material.color = col; resetColor c = child.GetComponent <resetColor>(); c.initialColor(); } for (int i = 0; i < t.transform.childCount; i++) { Transform child = t.transform.GetChild(i); bool contains = false; for (int x = 0; x < a.Length; x++) { if (child.name == a[x].transform.name) { contains = true; } } if (!contains) { child.GetChild(0).GetComponent <Renderer>().material = transparent; States s = child.GetChild(0).GetComponent <States>(); resetColor c = child.GetChild(0).GetComponent <resetColor>(); c.initialColor(); s.setTransparent(true); } } }
// 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(); } }
/*/ public void resetColor() * { * originalObject = null; * * // originalColor = true; * full = false; * * } * /*/ public void setColor() { resetColor col = originalObject.GetComponent <resetColor>(); col.setColor(); col.colorSet(); }
public void laserDeactivate() { resetColor col = originalObject.GetComponent <resetColor>(); // originalObject.GetComponent<Renderer>().material.color = ogColor; // col.setColor(); // resetName(); if (originalObject.GetComponent <TMPro.Examples.FloatText>() != null) //potentially wrong because did not check original object all the way trhiugh { Destroy(originalObject.GetComponent <TMPro.Examples.FloatText>(), 2f); col.setColor(); col.colorSet(); //Invoke("setColor", 0.1f); resetName(); // Invoke("resetName", 0.1f); originalObject = null; // originalColor = true; // Invoke("resetColor", 0.1f); } else { originalObject = null; col.setColor(); col.colorSet(); // originalColor = true; } if (grabbedObject != null) { grabbedObject.transform.parent = null; } }
// 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 } }
public void laserActivity(GameObject chunk, bool txtON) //this method is called when a grabbale game object is highlighted { resetColor chunkCol = chunk.GetComponent <resetColor>(); Color newColor; if (chunk.GetComponent <Renderer>() != null) { if (/*/originalColor/*/ chunkCol.originalColor()) { Color objectColor = chunk.GetComponent <Renderer>().material.color; ogColor = chunk.GetComponent <Renderer>().material.color; originalObject = chunk; float opaque = objectColor.a * 0.5f; float blue = objectColor.b * 0.5f; float green = objectColor.g * 0.5f; float red = objectColor.r * 0.5f; float opaqueness = opaque * 0.1f; newColor = new Vector4(red, green, blue, opaqueness); if (txtON && chunk.GetComponent <TMPro.Examples.FloatText>() == null && floatHer < 1)// && timer<1/*/timer>timerLimit &&(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)|| OVRInput.Get(OVRInput.Button.SecondaryIndexTrigger)/*/) { /*/ print("hello"); * chunk.AddComponent<TMPro.Examples.FloatText>(); * TMPro.Examples.FloatText t = chunk.GetComponent<TMPro.Examples.FloatText>(); * t.floatStart(chunk.name, newColor); * chunk.AddComponent<TimeHold>(); * floatHer = floatHer += 1; /*/ } chunk.GetComponent <Renderer>().material.color = newColor; //changed from object color so far this block does nothing // originalColor = false; chunkCol.colorSet(); States s = chunk.GetComponent <States>(); if (this.name == "hand_left" && !s.isTransparent()) { GameObject hand = GameObject.Find("hand_left"); Hand h = hand.GetComponent <Hand>(); h.setName(chunk.name); } else if (this.name == "hand_right" && !s.isTransparent()) { GameObject hand = GameObject.Find("hand_right"); Hand h = hand.GetComponent <Hand>(); h.setName(chunk.name.ToString()); } // chunk.GetComponent<Renderer>().material = laserHitColor; } } }
public void DropObject(bool bothGrab) { grabbing = false; if (grabbedObject != null && !bothGrab) { //for unhighlighting // Renderer rend = grabbedObject.GetComponent<Renderer>(); // rend.material.shader = original; if (grabbedObject.GetComponent <resetColor>() != null) { resetColor col = grabbedObject.GetComponent <resetColor>(); col.setColor(); } //for actually dropping grabbedObject.transform.parent = null; //Destroy(grabbedObject.GetComponent<MeshCollider>()); if (grabbedObject.GetComponent <MeshCollider>() == null) { grabbedObject.GetComponent <Rigidbody>().isKinematic = false; } if (grabbedObject.GetComponent <Rigidbody>().isKinematic == true) { } grabbedObject.GetComponent <Rigidbody>().velocity = OVRInput.GetLocalControllerVelocity(controller); grabbedObject.GetComponent <Rigidbody>().angularVelocity = GetAngularVelocity(); grabbedObject.GetComponent <Rigidbody>().useGravity = true; grabbedObject.transform.SetParent(parent); grabbedObject = null; text.text = ""; holding = false; } else if (bothGrab && grabbedObject != null) { grabbedObject.transform.parent = null; holding = false; if (grabbedObject.GetComponent <resetColor>() != null) //should remove this { resetColor col = grabbedObject.GetComponent <resetColor>(); col.setColor(); } grabbedObject = null; } }
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(); } } }
// 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(); } }