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.IsSeenByTracker = curr_status == PSMoveTracker_Status.Tracker_TRACKING; // Update the position of the controller if (controllerData.IsSeenByTracker) { 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 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); } }