private static void ControllerUpdatePositions( PSMoveWorkerSettings WorkerSettings, IntPtr psmove_tracker, // PSMoveTracker* IntPtr psmove_fusion, // PSMoveFusion* IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { // Find the sphere position in the camera PSMoveAPI.psmove_tracker_update(psmove_tracker, psmove); PSMoveTracker_Status curr_status = PSMoveAPI.psmove_tracker_get_status(psmove_tracker, psmove); // Can we actually see the controller this frame? controllerData.IsTracking = curr_status == PSMoveTracker_Status.Tracker_TRACKING; // Update the position of the controller if (controllerData.IsTracking) { float xcm = 0.0f, ycm = 0.0f, zcm = 0.0f; PSMoveAPI.psmove_fusion_get_transformed_location(psmove_fusion, psmove, ref xcm, ref ycm, ref zcm); // [Store the controller position] // Remember the position the ps move controller in either its native space // or in a transformed space if a transform file existed. controllerData.PSMovePosition = new Vector3( xcm + WorkerSettings.PSMoveOffset.x, ycm + WorkerSettings.PSMoveOffset.y, zcm + WorkerSettings.PSMoveOffset.z); } }
private static void ControllerUpdateButtonState( IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { // Get the controller button state controllerData.Buttons = PSMoveAPI.psmove_get_buttons(psmove); // Bitwise; tells if each button is down. // Get the controller trigger value (uint8; 0-255) controllerData.TriggerValue = (byte)PSMoveAPI.psmove_get_trigger(psmove); }
private static void ControllerUpdateOrientations( IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { float oriw = 1.0f, orix = 0.0f, oriy = 0.0f, oriz = 0.0f; // Get the controller orientation (uses IMU). PSMoveAPI.psmove_get_orientation(psmove, ref oriw, ref orix, ref oriy, ref oriz); //NOTE: This orientation is in the PSMoveApi coordinate system controllerData.PSMoveOrientation = new Quaternion(orix, oriy, oriz, oriw); }
private static void ControllerUpdateSensors( IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { float acc_x = 0.0f, acc_y = 0.0f, acc_z = 0.0f; float gyro_x = 0.0f, gyro_y = 0.0f, gyro_z = 0.0f; float mag_x = 0.0f, mag_y = 0.0f, mag_z = 0.0f; PSMoveAPI.psmove_get_accelerometer_frame(psmove, PSMove_Frame.Frame_SecondHalf, ref acc_x, ref acc_y, ref acc_z); PSMoveAPI.psmove_get_gyroscope_frame(psmove, PSMove_Frame.Frame_SecondHalf, ref gyro_x, ref gyro_y, ref gyro_z); PSMoveAPI.psmove_get_magnetometer_vector(psmove, ref mag_x, ref mag_y, ref mag_z); controllerData.Accelerometer = new Vector3(acc_x, acc_y, acc_z); controllerData.Gyroscope = new Vector3(gyro_x, gyro_y, gyro_z); controllerData.Magnetometer = new Vector3(mag_x, mag_y, mag_z); }
private static void ControllerUpdatePositions( PSMoveWorkerSettings WorkerSettings, IntPtr[] psmove_trackers, // PSMoveTracker* IntPtr[] psmove_fusions, // PSMoveFusion* int tracker_count, IntPtr position_filter, IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { // Update the tracked position of the psmove for each tracker for (int tracker_index = 0; tracker_index < tracker_count; ++tracker_index) { PSMoveAPI.psmove_tracker_update(psmove_trackers[tracker_index], psmove); } // Compute the triangulated camera position PSMoveAPI.PSMove_3AxisVector measured_position = new PSMoveAPI.PSMove_3AxisVector(); controllerData.IsSeenByTracker = PSMoveAPI.psmove_fusion_get_multicam_tracking_space_location( psmove_fusions, tracker_count, psmove, ref measured_position.x, ref measured_position.y, ref measured_position.z) == PSMove_Bool.PSMove_True; // Update the position of the controller if (controllerData.IsSeenByTracker) { // Update the filtered position PSMoveAPI.psmove_position_filter_update( ref measured_position, controllerData.IsSeenByTracker ? PSMove_Bool.PSMove_True : PSMove_Bool.PSMove_False, position_filter); // Get the filtered position PSMoveAPI.PSMove_3AxisVector filtered_position = PSMoveAPI.psmove_position_filter_get_position(position_filter); // [Store the controller position] // Remember the position the ps move controller in either its native space // or in a transformed space if a transform file existed. controllerData.PSMovePosition = new Vector3( filtered_position.x + WorkerSettings.PSMoveOffset.x, filtered_position.y + WorkerSettings.PSMoveOffset.y, filtered_position.z + WorkerSettings.PSMoveOffset.z); } }
private static void ControllerUpdateButtonState( IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { // Get the controller button state controllerData.Buttons = PSMoveAPI.psmove_get_buttons(psmove); // Bitwise; tells if each button is down. // Get the controller trigger value (uint8; 0-255) controllerData.TriggerValue = (byte)PSMoveAPI.psmove_get_trigger(psmove); }
private static void ControllerUpdateOrientations( IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { float oriw = 1.0f, orix = 0.0f, oriy = 0.0f, oriz = 0.0f; // Get the controller orientation (uses IMU). PSMoveAPI.psmove_get_orientation(psmove, ref oriw, ref orix, ref oriy, ref oriz); //NOTE: This orientation is in the PSMoveApi coordinate system controllerData.PSMoveOrientation = new Quaternion(orix, oriy, oriz, oriw); }
private static void ControllerUpdatePositions( IntPtr psmove_tracker, // PSMoveTracker* IntPtr psmove_fusion, // PSMoveFusion* IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { // Find the sphere position in the camera PSMoveAPI.psmove_tracker_update(psmove_tracker, psmove); PSMoveTracker_Status curr_status = PSMoveAPI.psmove_tracker_get_status(psmove_tracker, psmove); // Can we actually see the controller this frame? controllerData.IsTracking = curr_status == PSMoveTracker_Status.Tracker_TRACKING; // Update the position of the controller if (controllerData.IsTracking) { float xcm= 0.0f, ycm = 0.0f, zcm = 0.0f; PSMoveAPI.psmove_fusion_get_transformed_location(psmove_fusion, psmove, ref xcm, ref ycm, ref zcm); // [Store the controller position] // Remember the position the ps move controller in either its native space // or in a transformed space if a transform file existed. controllerData.PSMovePosition = new Vector3(xcm, ycm, zcm); } }
private static void ControllerUpdateSensors( IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { float acc_x = 0.0f, acc_y = 0.0f, acc_z = 0.0f; float gyro_x = 0.0f, gyro_y = 0.0f, gyro_z = 0.0f; float mag_x = 0.0f, mag_y = 0.0f, mag_z = 0.0f; PSMoveAPI.psmove_get_accelerometer_frame(psmove, PSMove_Frame.Frame_SecondHalf, ref acc_x, ref acc_y, ref acc_z); PSMoveAPI.psmove_get_gyroscope_frame(psmove, PSMove_Frame.Frame_SecondHalf, ref gyro_x, ref gyro_y, ref gyro_z); PSMoveAPI.psmove_get_magnetometer_vector(psmove, ref mag_x, ref mag_y, ref mag_z); controllerData.Accelerometer = new Vector3(acc_x, acc_y, acc_z); controllerData.Gyroscope = new Vector3(gyro_x, gyro_y, gyro_z); controllerData.Magnetometer = new Vector3(mag_x, mag_y, mag_z); }
private static void ControllerUpdatePositions( PSMoveWorkerSettings WorkerSettings, IntPtr[] psmove_trackers, // PSMoveTracker* IntPtr[] psmove_fusions, // PSMoveFusion* int tracker_count, IntPtr position_filter, IntPtr psmove, // PSMove* PSMoveRawControllerData_Base controllerData) { // Update the tracked position of the psmove for each tracker for (int tracker_index = 0; tracker_index < tracker_count; ++tracker_index) { PSMoveAPI.psmove_tracker_update(psmove_trackers[tracker_index], psmove); } // Compute the triangulated camera position PSMoveAPI.PSMove_3AxisVector measured_position = new PSMoveAPI.PSMove_3AxisVector(); controllerData.IsSeenByTracker = PSMoveAPI.psmove_fusion_get_multicam_tracking_space_location( psmove_fusions, tracker_count, psmove, ref measured_position.x, ref measured_position.y, ref measured_position.z) == PSMove_Bool.PSMove_True; // Update the position of the controller if (controllerData.IsSeenByTracker) { // Update the filtered position PSMoveAPI.psmove_position_filter_update( ref measured_position, controllerData.IsSeenByTracker ? PSMove_Bool.PSMove_True : PSMove_Bool.PSMove_False, position_filter); // Get the filtered position PSMoveAPI.PSMove_3AxisVector filtered_position = PSMoveAPI.psmove_position_filter_get_position(position_filter); // [Store the controller position] // Remember the position the ps move controller in either its native space // or in a transformed space if a transform file existed. controllerData.PSMovePosition = new Vector3( filtered_position.x + WorkerSettings.PSMoveOffset.x, filtered_position.y + WorkerSettings.PSMoveOffset.y, filtered_position.z + WorkerSettings.PSMoveOffset.z); } }