void Update() { if (cochlea == null) { cochlea = StatsManager.instance.GetActiveCochlea(); } if (PluginImport.GetButtonState(1, 2)) { if (!hasStarted) // user hasn't pressed start { DetachCochlea(); hasStarted = true; } } if (PluginImport.GetButtonState(1, 1) & !hasEnded) { hasEnded = true; StatsManager.instance.SetFullReset(false); simMonitor.IncrementReset(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } /***************************************************************/ //Update Workspace as function of camera /***************************************************************/ //PluginImport.UpdateWorkspace(myHapticCamera.transform.rotation.eulerAngles.y);//To be deprecated //Update the Workspace as function of camera for (int i = 0; i < workspaceUpdateValue.Length; i++) { workspaceUpdateValue[i] = myHapticCamera.transform.rotation.eulerAngles.y; } PluginImport.UpdateHapticWorkspace(ConverterClass.ConvertFloatArrayToIntPtr(workspaceUpdateValue)); /***************************************************************/ //Update cube workspace /***************************************************************/ myGenericFunctionsClassScript.UpdateGraphicalWorkspace(); /***************************************************************/ //Haptic Rendering Loop /***************************************************************/ PluginImport.RenderHaptic(); //Associate the cursor object with the haptic proxy value myGenericFunctionsClassScript.GetProxyValues(isKinematic); }
void ActivatingGrabbedObjectPropperties() { GameObject grabbedObject; string myObjStringName; if (!previousButtonState && PluginImport.GetButtonState(1, 1)) { //If the object is grabbed, the gravity is deactivated and kinematic is enabled //myObjStringName = ConverterClass.ConvertIntPtrToByteToString(PluginImport.GetTouchedObjectName());//GetTouchedObjectName() - To be deprecated myObjStringName = ConverterClass.ConvertIntPtrToByteToString(PluginImport.GetTouchedObjName(1)); if (!myObjStringName.Equals("null")) { grabbedObject = GameObject.Find(myObjStringName); //If there is a rigid body if (grabbedObject.GetComponent <Rigidbody>() != null) { grabbedObject.GetComponent <Rigidbody>().isKinematic = true; grabbedObject.GetComponent <Rigidbody>().useGravity = false; } grabbedObjectName = myObjStringName; } previousButtonState = true; } else if (previousButtonState && !PluginImport.GetButtonState(1, 1)) { //If the object is dropped, the grabity is enabled again and kinematic is deactivated if (!grabbedObjectName.Equals("")) { grabbedObject = GameObject.Find(grabbedObjectName); //If there is a rigid body if (grabbedObject.GetComponent <Rigidbody>() != null) { grabbedObject.GetComponent <Rigidbody>().isKinematic = false; grabbedObject.GetComponent <Rigidbody>().useGravity = true; } grabbedObjectName = ""; } previousButtonState = false; } }
void Update() { if (PluginImport.GetButtonState(1, 2)) { DetachCochlea(); } if (PluginImport.GetButtonState(1, 1) & !hasEnded) { hasEnded = true; simMonitor.End(); } /***************************************************************/ //Update Workspace as function of camera /***************************************************************/ //PluginImport.UpdateWorkspace(myHapticCamera.transform.rotation.eulerAngles.y);//To be deprecated //Update the Workspace as function of camera for (int i = 0; i < workspaceUpdateValue.Length; i++) { workspaceUpdateValue[i] = myHapticCamera.transform.rotation.eulerAngles.y; } PluginImport.UpdateHapticWorkspace(ConverterClass.ConvertFloatArrayToIntPtr(workspaceUpdateValue)); /***************************************************************/ //Update cube workspace /***************************************************************/ myGenericFunctionsClassScript.UpdateGraphicalWorkspace(); /***************************************************************/ //Haptic Rendering Loop /***************************************************************/ PluginImport.RenderHaptic(); //Associate the cursor object with the haptic proxy value myGenericFunctionsClassScript.GetProxyValues(isKinematic); }
void Update() { /***************************************************************/ //Update Workspace as function of camera /***************************************************************/ //PluginImport.UpdateWorkspace(myHapticCamera.transform.rotation.eulerAngles.y);//To be deprecated //Update the Workspace as function of camera for (int i = 0; i < workspaceUpdateValue.Length; i++) { workspaceUpdateValue[i] = myHapticCamera.transform.rotation.eulerAngles.y; } PluginImport.UpdateHapticWorkspace(ConverterClass.ConvertFloatArrayToIntPtr(workspaceUpdateValue)); /***************************************************************/ //Update cube workspace /***************************************************************/ myGenericFunctionsClassScript.UpdateGraphicalWorkspace(); /***************************************************************/ //Haptic Rendering Loop /***************************************************************/ PluginImport.RenderHaptic(); //Associate the cursor object with the haptic proxy value myGenericFunctionsClassScript.GetProxyValues(); myGenericFunctionsClassScript.GetTouchedObject(); //Debug.Log ("Button 1: " + PluginImport.GetButton1State()); // To be deprecated //Debug.Log ("Button 2: " + PluginImport.GetButton2State()); // To be deprecated Debug.Log("원래 되던 디바이스의 위 1: " + PluginImport.GetButtonState(0, 1)); Debug.Log("원래 되던 디바이스의 아래 2: " + PluginImport.GetButtonState(0, 2)); Debug.Log("안되던 디바이스의 위 1: " + PluginImport.GetButtonState(1, 1)); Debug.Log("안되던 디바이스의 아래 2: " + PluginImport.GetButtonState(1, 2)); }
void Update() { /***************************************************************/ //Act on the rigid body of the Manipulated object // if Mode = Manipulation Mode /***************************************************************/ if (PluginImport.GetMode() == 1) { ActivatingGrabbedObjectPropperties(); } /***************************************************************/ //Update Workspace as function of camera /***************************************************************/ //PluginImport.UpdateWorkspace(myHapticCamera.transform.rotation.eulerAngles.y); //To be deprecated //Update the Workspace as function of camera for (int i = 0; i < workspaceUpdateValue.Length; i++) { workspaceUpdateValue[i] = myHapticCamera.transform.rotation.eulerAngles.y; } PluginImport.UpdateHapticWorkspace(ConverterClass.ConvertFloatArrayToIntPtr(workspaceUpdateValue)); /***************************************************************/ //Update cube workspace /***************************************************************/ myGenericFunctionsClassScript.UpdateGraphicalWorkspace(); /***************************************************************/ //Haptic Rendering Loop /***************************************************************/ PluginImport.RenderHaptic(); //Associate the cursor object with the haptic proxy value myGenericFunctionsClassScript.GetProxyValues(); myGenericFunctionsClassScript.GetTouchedObject(); Debug.Log("Button 1: " + PluginImport.GetButton1State()); // To be deprecated Debug.Log("Button 2: " + PluginImport.GetButton2State()); // To be deprecated Debug.Log("Device 1: Button 1: " + PluginImport.GetButtonState(1, 1)); Debug.Log("Device 1: Button 2: " + PluginImport.GetButtonState(1, 2)); // if (PluginImport.GetButtonState(1, 2)) //{ // makeJengaBlocks(); //} if (PluginImport.GetButtonState(1, 1)) { Debug.Log("Device 1 : Button Up Pressed"); } else if (PluginImport.GetButtonState(1, 2)) { Debug.Log("Device 1 : Button Down Pressed"); } if (PluginImport.GetButtonState(2, 1)) { Debug.Log("Device 2 : Button Up Pressed"); } else if (PluginImport.GetButtonState(2, 2)) { Debug.Log("Device 2 : Button Down Pressed"); } const float rotSpeed = 1.0f; if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { myHapticCamera.transform.RotateAround(Vector3.zero, new Vector3(0.0f, 1.0f, 0.0f), rotSpeed); } if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { myHapticCamera.transform.RotateAround(Vector3.zero, new Vector3(0.0f, 1.0f, 0.0f), -rotSpeed); } }
void Update() { /*if (PluginImport.GetButtonState(1, 1) && isKinematic) * { * Debug.Log("Inside button press"); * isKinematic = !isKinematic; * * GameObject[] capsules = GameObject.FindGameObjectsWithTag("ElectrodeCapsule"); * * foreach (GameObject go in capsules) * { * Rigidbody goRB = go.GetComponent<Rigidbody>(); * goRB.isKinematic = false; * } * }*/ if (PluginImport.GetButtonState(1, 2)) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } /*if (PluginImport.GetButtonState(1, 1)) * { * isKinematic = !isKinematic; * * GameObject[] capsules = GameObject.FindGameObjectsWithTag("ElectrodeCapsule"); * * foreach (GameObject go in capsules) * { * Rigidbody goRB = go.GetComponent<Rigidbody>(); * goRB.isKinematic = false; * } * }*/ /***************************************************************/ //Update Workspace as function of camera /***************************************************************/ //PluginImport.UpdateWorkspace(myHapticCamera.transform.rotation.eulerAngles.y);//To be deprecated //Update the Workspace as function of camera //for (int i = 0; i < workspaceUpdateValue.Length; i++) //workspaceUpdateValue[i] = myHapticCamera.transform.rotation.eulerAngles.y; //PluginImport.UpdateHapticWorkspace(ConverterClass.ConvertFloatArrayToIntPtr(workspaceUpdateValue)); /***************************************************************/ //Update cube workspace /***************************************************************/ myGenericFunctionsClassScript.UpdateGraphicalWorkspace(); /***************************************************************/ //Haptic Rendering Loop /***************************************************************/ PluginImport.RenderHaptic(); //Associate the cursor object with the haptic proxy value myGenericFunctionsClassScript.GetProxyValues(isKinematic); //myGenericFunctionsClassScript.GetProxyValues(); /*if (isKinematic) * { * GameObject[] capsules = GameObject.FindGameObjectsWithTag("ElectrodeCapsule"); * * foreach (GameObject go in capsules) * { * Rigidbody goRB = go.GetComponent<Rigidbody>(); * goRB.constraints = RigidbodyConstraints.None; * } * isKinematic = false; * }*/ //Vector3 pos = ConverterClass.ConvertDouble3ToVector3(ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyPosition())); //Vector3 movement = (rb.position - pos).normalized; //rb.MovePosition(rb.position + movement * Time.deltaTime); //hapticCursor.transform.position = pos; //myGenericFunctionsClassScript.GetTouchedObject(); //Reset the writing on the board //if(ConverterClass.ConvertIntPtrToByteToString( PluginImport.GetTouchedObjectName()) == "reset") // GetTouchedObjectName - To be deprecated //if (ConverterClass.ConvertIntPtrToByteToString(PluginImport.GetTouchedObjName(1)) == "reset") //{ //myWritingScript.cleanBoard(); //Change the Color of the button material //myResetButton.GetComponent<Renderer>().material.color = buttonResetColors[1]; //} //else //myResetButton.GetComponent<Renderer>().material.color = buttonResetColors[0]; }
void Update() { ThreadFollowPoint.transform.position = NeedleThreadPoint.transform.position; if (CollisionHappend) { Debug.Log("Collision Occured" + this.gameObject.name); } else { //Debug.Log("No Collision"); } if (PluginImport.GetButton1State() == true) { Debug.Log("Button1 Pressed"); isButtonClicked = true; } else { isButtonClicked = false; } //if(PluginImport.GetButtonState(1,2)) //{ // Debug.Log("Button1 Pressed"); // isButtonClicked = true; //} //else //{ // isButtonClicked = false; //} if (PluginImport.GetButtonState(1, 1)) { Debug.Log("Button2Pressed"); //GameObject NeedleObject = Instantiate(NeedleStopPoint, NeedDleStopTransform.position, Quaternion.identity, NeedleParent); //NeedleObject.name = NeedleParent.transform.childCount.ToString(); } if (Input.GetKeyDown(KeyCode.Space)) { //isButtonClicked = true; } if (Input.GetKeyUp(KeyCode.Space)) { //isButtonClicked = false; } if (isButtonClicked) { if (CollisionHappend) { if (CollidedObject.name == "forcepNeedlePoint") { transform.position = ForcepPoint.transform.position; this.transform.SetParent(ForcepPoint.transform); } } } else { this.transform.SetParent(GameObject.Find("ButtonResetPoint").transform); } }
// Update is called once per frame void Update() { //Get Pixels - Needed if two Haptic Devices boardPixels = boardTexture.GetPixels(); bool button1State = PluginImport.GetButtonState(deviceNb, 1); if (button1State && !previousButton1State) { penColorNum = (penColorNum + 1) % penColors.Length; } previousButton1State = button1State; //if (PluginImport.GetButtonState(deviceNb,2)) cleanBoard(); bool eraseState = PluginImport.GetButtonState(deviceNb, 2); if (eraseState) { changePenColor(new Color(0.25f, 0.25f, 0.25f)); } else { changePenColor(penColorNum); } //updated the new interface for Dual Haptic Devices bool shouldDraw = PluginImport.GetHapticContact(deviceNb) && (myCounter > 0); if (shouldDraw) { //double[] pos = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyPosition()); double[] pos = ConverterClass.SelectHalfdouble6toDouble3(ConverterClass.ConvertIntPtrToDouble6(PluginImport.GetProxyPosition()), deviceNb); //double[] dir = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyDirection()); double[] dir = ConverterClass.SelectHalfdouble6toDouble3(ConverterClass.ConvertIntPtrToDouble6(PluginImport.GetProxyDirection()), deviceNb); Vector3 position = new Vector3((float)pos[0], (float)pos[1], (float)pos[2]); Vector3 direction = new Vector3((float)dir[0], (float)dir[1], (float)dir[2]); //double[] realPos = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetDevicePosition()); double[] realPos = ConverterClass.SelectHalfdouble6toDouble3(ConverterClass.ConvertIntPtrToDouble6(PluginImport.GetDevicePosition()), deviceNb); Vector3 realPosition = new Vector3((float)realPos[0], (float)realPos[1], (float)realPos[2]); float force = (realPosition - position).magnitude; if (force > 1.0f) { force = 1.0f; } RaycastHit hitInfo = new RaycastHit(); bool hasHit = Physics.Raycast(position, direction, out hitInfo); if (previousShouldDraw) { drawBlobLine(previousCoord, hitInfo.textureCoord, blobRadius, penColors[penColorNum], force, blobSteps, eraseState); } else { drawBlob(hitInfo.textureCoord, blobRadius, penColors[penColorNum], force, eraseState); } previousCoord = hitInfo.textureCoord; boardTexture.SetPixels(boardPixels); boardTexture.Apply(); } previousShouldDraw = shouldDraw; myCounter++; }