public void EnableTracking(MotionControllerModel mc) { if (mc.Design) { return; } if (_camera.Handle == IntPtr.Zero) { StartTracker(PSMoveTrackerExposure.Low); } ConsoleService.Write(string.Format("[Tracker, {0}] Calibrating Motion Controller ({1}).", _camera.GUID, mc.Serial)); byte r = (byte)((mc.Color.r * 255) + 0.5f); byte g = (byte)((mc.Color.g * 255) + 0.5f); byte b = (byte)((mc.Color.b * 255) + 0.5f); mc.TrackerStatus[_camera] = PsMoveApi.psmove_tracker_enable_with_color(_camera.Handle, mc.Handle, r, g, b); if (mc.TrackerStatus[_camera] == PSMoveTrackerStatus.Tracking || mc.TrackerStatus[_camera] == PSMoveTrackerStatus.Calibrated) { PsMoveApi.psmove_tracker_update_image(_camera.Handle); PsMoveApi.psmove_tracker_update(_camera.Handle, mc.Handle); mc.TrackerStatus[_camera] = PsMoveApi.psmove_tracker_get_status(_camera.Handle, mc.Handle); PsMoveApi.psmove_enable_orientation(mc.Handle, PSMoveBool.True); PsMoveApi.psmove_reset_orientation(mc.Handle); } //Matrix4x4 proj = new Matrix4x4(); //for (int row = 0; row < 4; row++) //{ // for (int col = 0; col < 4; col++) // { // proj[row, col] = PsMoveApi.PSMoveMatrix4x4_at(PsMoveApi.psmove_fusion_get_projection_matrix(_camera.Fusion), row * 4 + col); // } //} //mc.ProjectionMatrix[_camera] = proj; ConsoleService.Write(string.Format("[Tracker, {0}] Tracker Status of {1} = {2}", _camera.GUID, mc.Name, Enum.GetName(typeof(PSMoveTrackerStatus), mc.TrackerStatus[_camera]))); }
public bool Orient(PSMoveBool enable) { bool oriented = false; PsMoveApi.psmove_enable_orientation(_motionController.Handle, enable); if (enable == PSMoveBool.True) { PsMoveApi.psmove_reset_orientation(_motionController.Handle); oriented = PsMoveApi.psmove_has_orientation(_motionController.Handle) == PSMoveBool.True; if (oriented) { float qw = 0.0f, qx = 0.0f, qy = 0.0f, qz = 0.0f; PsMoveApi.psmove_get_orientation(_motionController.Handle, out qw, out qx, out qy, out qz); m_orientationFix = new Quaternion(-qx, -qy, -qz, qw); } } return(oriented); }