private void ButtonEvent(object sender, _3DxMouse._3DxMouse.ButtonEventArgs e) { //// Change the device? // Show the buttons that are pressed string gripper = ""; switch(e.ButtonMask.Pressed.ToString("X")){ case "1": gripper = "grip"; break; case "2": case "3": gripper = "release"; break; } if (gripper.Length > 0) { TCPSendMotionCoordinates(gripper); this.ButtonLabel.Text = gripper; } //ResetCube(); }
private void MotionEvent(object sender, _3DxMouse._3DxMouse.MotionEventArgs e) { Vector3D tv = new Vector3D(); Vector3D rv = new Vector3D(); // Change the device? _puckTimerDelay++; // Currently Translations and Rotations arrive separately (T first, then R) // but there is a firmware version that will deliver both together // Translation Vector? if (_puckTimerDelay>_puckTimerDeaySize && (e.TranslationVector != null || e.RotationVector != null)) { double X = 0, Y = 0, Z = 0, rX = 0, rY = 0, rZ = 0; if (e.TranslationVector != null) { X = e.TranslationVector.Y; Y = -e.TranslationVector.X; Z = e.TranslationVector.Z; } if (e.RotationVector != null) { rX = -e.RotationVector.X; rY = -e.RotationVector.X; rZ = -e.RotationVector.Z; } lblX.Text = X.ToString(); lblY.Text = Y.ToString(); lblZ.Text = Z.ToString(); // Swap axes from HID orientation to a right handed coordinate system that matches WPF model space //tv.X = e.TranslationVector.X; //tv.Y = -e.TranslationVector.Z; //tv.Z = e.TranslationVector.Y; TCPSendMotionCoordinates(String.Format("{0:0.00} {1:0.00} {2:0.00} {3:0.00} {4:0.00} {5:0.00}{6}", X * puckOutputScalingFactor, Y * puckOutputScalingFactor, Z * puckOutputScalingFactor, rX * puckOutputScalingFactor, rY * puckOutputScalingFactor, rZ * puckOutputScalingFactor, System.Environment.NewLine)); _puckTimerDelay = 0; } // Rotation Vector? if (e.RotationVector != null) { //lblX.Text = e.RotationVector.X.ToString(); //lblY.Text = e.RotationVector.Y.ToString(); //lblZ.Text = e.RotationVector.Z.ToString(); //Swap axes from HID orientation to a right handed coordinate system that matches WPF model space //TCPSendMotionCoordinates(String.Format("0 0 0 {0:0.00} {1:0.00} {2:0.00}{3}", X * puckOutputScalingFactor, Y * puckOutputScalingFactor, Z * puckOutputScalingFactor, System.Environment.NewLine)); } //UpdateCube(tv, rv); }