/** * ReadSphere * * @param infile * @param ObjID * @return int */ private int ReadSphere(int ObjID) { String temp; double[] input = new double[3]; int i; double radius; Point max = new Point(MaxX, MaxY, MaxZ); Point min = new Point(MinX, MinY, MinZ); temp = readString(); temp = readString(); Material theMaterial = ReadMaterial(); temp = readString(); temp = temp.Substring(9); for (i = 0; i < 2; i++) { input[i] = (double)Double.Parse(temp.Substring(0, temp.IndexOf(' '))); temp = temp.Substring(temp.IndexOf(' ') + 1); } input[2] = (double)Double.Parse(temp); Point origin = new Point(input[0], input[1], input[2]); temp = readString(); temp = temp.Substring(9); radius = (double)Double.Parse(temp); for (i = 0; i < 7; i++) { temp = readString(); } SphereObj newsphere = new SphereObj(theMaterial, ++ObjID, origin, radius, max, min); ObjNode newnode = new ObjNode(newsphere, objects); objects = newnode; MaxX = max.GetX(); MaxY = max.GetY(); MaxZ = max.GetZ(); MinX = min.GetX(); MinY = min.GetY(); MinZ = min.GetZ(); return(1); }
void Update() { mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (sphereQuadTree.m_bounds.Contains(mousePos)) { Debug.Log("mouse in bounds"); if (Input.GetMouseButtonDown(0)) { Instantiate(sphereGO, mousePos + transform.forward * 5, Quaternion.identity); SphereObj sphereObj = new SphereObj(mousePos); sphereQuadTree.Insert(sphereObj); } } else { Debug.Log("mouse is not in the bounds of the QT"); } if (Input.GetMouseButtonDown(1)) { sphereQuadTree.Clear(); } }
/** * ReadSphere * * @param infile * @param ObjID * @return int */ private int ReadSphere (int ObjID) { String temp; double[] input = new double[3]; int i; double radius; Point max = new Point (MaxX, MaxY, MaxZ); Point min = new Point (MinX, MinY, MinZ); temp = readString (); temp = readString (); Material theMaterial = ReadMaterial (); temp = readString (); temp = temp.Substring (9); for (i = 0; i < 2; i++) { input [i] = (double)Double.Parse (temp.Substring (0, temp.IndexOf (' '))); temp = temp.Substring (temp.IndexOf (' ') + 1); } input [2] = (double)Double.Parse (temp); Point origin = new Point (input [0], input [1], input [2]); temp = readString (); temp = temp.Substring (9); radius = (double)Double.Parse (temp); for (i = 0; i < 7; i++) { temp = readString (); } SphereObj newsphere = new SphereObj (theMaterial, ++ObjID, origin, radius, max, min); ObjNode newnode = new ObjNode (newsphere, objects); objects = newnode; MaxX = max.GetX (); MaxY = max.GetY (); MaxZ = max.GetZ (); MinX = min.GetX (); MinY = min.GetY (); MinZ = min.GetZ (); return (1); }