// Adds connection to the vertex and generates the truncated hemisphere private GameObject truncate(GameObject newHemisphere, GameObject existingTruncation) { if (newHemisphere == null) { return(null); } if (connectionList.Count == 1) //this is the only connection, nothing to do { truncationExists = true; viability = false; return(newHemisphere); } float scaling = 1; if (domain.GetComponent <ResizeObject>().getMagnification() >= 1) { scaling = 10; } else { scaling = 20; } domain.transform.localScale = domain.transform.localScale * scaling; GameObject truncation = Hemisphere.GetIntersection(existingTruncation, newHemisphere, truncatedHemisphereMaterial, true); if (truncation == null) //means there was no ove rlapping region { viability = false; truncationExists = false; domain.transform.localScale = domain.transform.localScale / scaling; return(truncation); } else { viability = true; truncationExists = true; truncation.transform.parent = newHemisphere.transform.parent; } domain.transform.localScale = domain.transform.localScale / scaling; return(truncation); }
void Update() { if (Input.GetKeyDown("space")) { hemisphere1 = Hemisphere.CreateHemisphere(hemisphereMaterial1, pos.transform.position, target1.transform.position, false); //updatePos = true; } if (Input.GetKeyDown(KeyCode.A)) { hemisphere2 = Hemisphere.CreateHemisphere(hemisphereMaterial2, pos.transform.position, target2.transform.position, false); final1 = Hemisphere.GetIntersection(hemisphere1, hemisphere2, truncatedHemisphereMaterial, true); } if (Input.GetKeyDown(KeyCode.S)) { dottedLine = new VectorLine("dotted", new List <Vector3>(), texture, 16.0f); dottedLine.points3.Add(pos.transform.position); dottedLine.points3.Add(freedomTarget.transform.position); dottedLine.textureScale = 1.00f; dottedLine.Draw3DAuto(); lineObj = GameObject.Find("dotted"); plane = GameObject.CreatePrimitive(PrimitiveType.Cube); plane.transform.localScale = new Vector3(10, 10, 0.001F); plane.transform.rotation = Quaternion.LookRotation(origin.transform.position - plane.transform.position); plane.transform.position = pos.transform.position; plane.GetComponent <MeshRenderer>().sharedMaterial = mat; updatePos = true; } if (Input.GetKeyDown(KeyCode.B)) { ToggleView(); } if (updatePos) { hemisphere1.transform.rotation = Quaternion.LookRotation(target1.transform.position - hemisphere1.transform.position); hemisphere2.transform.rotation = Quaternion.LookRotation(target2.transform.position - hemisphere2.transform.position); Vector3 euler = hemisphere1.transform.rotation.eulerAngles; hemisphere1.transform.eulerAngles = new Vector3(euler.z, euler.y + 90F, euler.x); euler = hemisphere2.transform.rotation.eulerAngles; hemisphere2.transform.eulerAngles = new Vector3(euler.z, euler.y + 90F, euler.x); dottedLine.points3[0] = pos.transform.position; dottedLine.points3[1] = freedomTarget.transform.position; plane.transform.rotation = Quaternion.LookRotation(origin.transform.position - freedomTarget.transform.position); //freedomPos.transform.position = Physics.ClosestPoint(freedomTarget.transform.position, origin.GetComponent<Collider>(), origin.transform.position, origin.transform.rotation); //int layerMask = 1 << LayerMask.NameToLayer("hemisphere"); //Collider[] list = Physics.OverlapSphere(freedomPos.transform.position, freedomPos.transform.localScale.x, layerMask); //print(list.Length); //if (list.Length == 2) //{ // lineObj.SetActive(true); //} //else //{ // lineObj.SetActive(false); //} if (InTruncation(origin, freedomTarget)) { lineObj.SetActive(true); } else { lineObj.SetActive(false); } } demoLine.points3[0] = target1.transform.position; demoLine.points3[1] = pos.transform.position; demoLine.points3[2] = target2.transform.position; demoLine.points3[3] = pos.transform.position; }