public void setScript(functionBehaive script) { this.script = script; }
// look for keyboard shortcuts and clicking of objects bool checkKeys() { bool retval = true; if (menus.clicked != "") { return(true); } if (Input.GetMouseButtonDown(0) && !Input.GetKey(KeyCode.LeftAlt)) { // User clicked button (but not while naviaging via alt key //Debug.Log("clicked in checkKyes"); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { if (Input.GetKey(KeyCode.LeftShift)) { // user seeks information about an object functionBehaive funScript = (functionBehaive)hit.transform.gameObject.GetComponent(typeof(functionBehaive)); if (funScript != null) { funScript.showSummary(false, false); } else { Debug.Log("perhaps hit data? " + hit.transform.gameObject.name); dataBehaviorNew dataScript = (dataBehaviorNew)hit.transform.gameObject.GetComponent(typeof(dataBehaviorNew)); if (dataScript != null) { dataScript.showSummary(); addressLabel = "address: 0x" + dataScript.address.ToString("x"); } } } else { // if function is clicked, zoom to it. Debug.Log("HIT SOMETHING " + hit.transform.gameObject.name); functionBehaive funScript = (functionBehaive)hit.transform.gameObject.GetComponent(typeof(functionBehaive)); if (funScript != null) { cameraScript.setObject(funScript.function.getPosition()); } } } } else if (Input.GetMouseButtonUp(0)) { addressLabel = ""; } else if (Input.GetKeyDown("space")) { doUserPause(); //print("space key was pressed"); //}else if (Input.GetKeyDown("escape")){ // //print("escape key was pressed"); // helpString = null; // //cameraScript.restore(); // setCamera(); } else if (Input.GetKeyDown("w") && Input.GetKey(KeyCode.LeftShift)) { cameraScript.moveZ(1); } else if (Input.GetKeyDown("s") && Input.GetKey(KeyCode.LeftShift)) { cameraScript.moveZ(-1); } else if (Input.GetKeyDown("w")) { cameraScript.moveY(1); } else if (Input.GetKeyDown("s")) { cameraScript.moveY(-1); } else if (Input.GetKeyDown("a")) { cameraScript.moveX(1); } else if (Input.GetKeyDown("d")) { cameraScript.moveX(-1); // }else if (Input.GetKeyDown("r") && (Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift))){ } else if (Input.GetKeyDown("r") && (Input.GetKey(KeyCode.LeftShift))) { if (!justShowData) { justShowData = true; skipToData = true; pauseLabelString = "skipping"; } else { justShowData = false; } } else if (Input.GetKeyDown("f")) { manageControl.follow(!manageControl.following()); } else if (Input.GetKeyDown("r")) { if (isPlaying) { skipToData = true; pauseLabelString = "skipping"; //Debug.Log("Skip to data at clock "+currentClock); } } else if (Input.GetKeyDown("h")) { setCamera(); } else if (Input.GetKeyDown("i")) { if (!skipToNetwork) { justShowData = true; skipToData = true; pauseLabelString = "skipping"; } else { justShowData = false; skipToData = false; if (!userPause) { pauseLabelString = "play"; } } skipToNetwork = !skipToNetwork; } else if (Input.GetKeyDown("b")) { pause(true); userStackFrame = manageControl.callStack.Count - 1; functionDatabase.functionItem fi = manageControl.currentFunction; cameraScript.setObject(fi.getPosition()); if (functionLabels) { fi.script.showSummary(true, true); } } else if (Input.GetKeyDown("n") && (Input.GetKey(KeyCode.LeftShift))) { if (userStackFrame < manageControl.callStack.Count - 1) { functionDatabase.functionItem fi = manageControl.callStack[userStackFrame]; cameraScript.setObject(fi.getPosition()); userStackFrame++; if (functionLabels) { fi.script.showSummary(true, true); } } } else if (Input.GetKeyDown("n")) { if (userStackFrame >= 0) { functionDatabase.functionItem fi = manageControl.callStack[userStackFrame]; cameraScript.setObject(fi.getPosition()); if (userStackFrame > 0) { userStackFrame--; } if (functionLabels) { fi.script.showSummary(true, true); } } } else if (Input.GetKeyDown("m")) { pause(true); menus.clicked = "create bookmark"; //createBookmark(); } else if (Input.GetKeyDown("l")) { pause(true); menus.clicked = "goto bookmark"; } else { retval = false; } return(retval); }
// pick a shape based on quantity of vertices & # of basic blocks private static void assignObjects() { for (int i = 0; i < length(); i++) { uint address = getFunctionAddress(i); functionItem fi = getFunction(address); string polyType = "stellatedPrefab"; if (fi.num_blocks <= 5) { polyType = "pyramidPrefab"; } else if (fi.num_blocks <= 6) { polyType = "octoPrefab"; } else if (fi.num_blocks <= 8) { polyType = "cubePrefab"; } else if (fi.num_blocks <= 10) { polyType = "isoPrefab"; } else if (fi.num_blocks <= 20) { polyType = "decoPrefab"; } else if (fi.num_blocks <= 26) { polyType = "thirtysixPrefab"; fi.subtype = 1; fi.xOff = 0.3f; fi.yOff = -0.2f; fi.zOff = -0.3f; } else if (fi.num_blocks <= 60) { polyType = "soccerPrefab"; } else if (fi.num_blocks <= 70) { polyType = "buckyPrefab"; fi.xOff = -0.3f; fi.subtype = 1; //}else if (fi.num_blocks <= 74){ // polyType = "rhombicPrefab"; //}else if (fi.num_blocks <= 127){ // polyType = "ditriPrefab"; // fi.subtype = 1; } else if (fi.num_blocks <= 80) { polyType = "conjecturePrefab"; fi.subtype = 1; } else if (fi.num_blocks <= 90) { polyType = "pentakisPrefab"; fi.yOff = -0.32f; } else if (fi.num_blocks <= 110) { polyType = "romanPrefab"; fi.subtype = 1; } else if (fi.num_blocks <= 200) { polyType = "stellarPrefab"; fi.subtype = 1; fi.xOff = 0.6f; fi.yOff = 0.1f; fi.zOff = -0.073f; } else //stellatedPrefab { polyType = "stellatedPrefab"; fi.xOff = 0.2f; fi.yOff = 0.25f; fi.zOff = -0.17f; } fi.setType(polyType); GameObject go; //go = (GameObject) Instantiate(isoPrefab, pt, Quaternion.identity) as GameObject; go = (GameObject)Instantiate(Resources.Load(polyType)) as GameObject; functionBehaive fb = (functionBehaive)go.GetComponent(typeof(functionBehaive)); fb.setFunction(fi); SphereCollider sc = go.AddComponent <SphereCollider>(); Vector3 center = new Vector3(fi.xOff / go.transform.localScale.x, fi.yOff / go.transform.localScale.y, fi.zOff / go.transform.localScale.z); //sc.radius = 0.6f/go.transform.localScale.x; sc.radius = 0.6f / go.transform.localScale.x; if (polyType == "stellarPrefab") { //Debug.Log ("obect "+go.name+" radius is "+sc.radius+" sizex is "+sc.bounds.size.x+" "+sc.bounds.size.y+" "+sc.center.x+" "+sc.center.y); //sc.center = Vector3.zero; center.y -= 1.0f / go.transform.localScale.y; center.x -= 0.5f / go.transform.localScale.x; } sc.center = center; Vector3 pt = new Vector3(fi.x - fi.xOff, fi.y - fi.yOff, fi.z - fi.zOff); go.transform.position = pt; fi.go = go; fi.setShader(startup.shader2); fi.setColor(startup.color2); fi.setScript(fb); } }