// 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++; }