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); } }
public static void StartWorkerThread(PSMoveWorkerSettings workerSettings) { if (WorkerInstance == null) { WorkerInstance = new PSMoveWorker(workerSettings); } WorkerInstance.Start(); }
public IntPtr PSMoveFusion; // PSMoveFusion* // Constructor public WorkerContext(PSMoveRawControllerData_TLS[] controllerDataArray, PSMoveWorkerSettings settings) { WorkerSettings = settings; WorkerControllerDataArray = controllerDataArray; // This timestamp is used to throttle how frequently we poll for controller count changes moveCountCheckTimer = new Stopwatch(); Reset(); }
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 void WorkerSetup(PSMoveWorkerSettings workerSettings) { #if LOAD_DLL_MANUALLY if (psmoveapiHandle == IntPtr.Zero) { #if UNITY_EDITOR_WIN if (IntPtr.Size == 8) { psmoveapiHandle = LoadLib(Application.dataPath + "/Plugins/x86_64/psmoveapi.dll"); } else { psmoveapiHandle = LoadLib(Application.dataPath + "/Plugins/x86/psmoveapi.dll"); } #elif UNITY_STANDALONE_WIN psmoveapiHandle = LoadLib(Application.dataPath + "/Plugins/psmoveapi.dll"); #endif } if (psmoveapiTrackerHandle == IntPtr.Zero) { #if UNITY_EDITOR_WIN if (IntPtr.Size == 8) { psmoveapiTrackerHandle = LoadLib(Application.dataPath + "/Plugins/x86_64/psmoveapi_tracker.dll"); } else { psmoveapiTrackerHandle = LoadLib(Application.dataPath + "/Plugins/x86/psmoveapi_tracker.dll"); } #elif UNITY_STANDALONE_WIN psmoveapiHandle = LoadLib(Application.dataPath + "/Plugins/psmoveapi_tracker.dll"); #endif } #endif // LOAD_DLL_MANUALLY if (!WorkerThread.IsAlive) { WorkerSettings = workerSettings; WorkerThread.Start(); } }
private PSMoveWorker() { WorkerSettings = new PSMoveWorkerSettings(); HaltThreadSignal = new ManualResetEvent(false); ThreadExitedSignal = new ManualResetEvent(false); WorkerThread = new Thread(() => { this.ThreadProc(); }); WorkerThread.Priority = System.Threading.ThreadPriority.AboveNormal; WorkerControllerDataArray_Concurrent = new PSMoveRawControllerData_Concurrent[MAX_CONTROLLERS]; WorkerControllerDataArray = new PSMoveRawControllerData_TLS[MAX_CONTROLLERS]; for (int i = 0; i < WorkerControllerDataArray_Concurrent.Length; i++) { WorkerControllerDataArray_Concurrent[i] = new PSMoveRawControllerData_Concurrent(); WorkerControllerDataArray[i] = new PSMoveRawControllerData_TLS(WorkerControllerDataArray_Concurrent[i]); } psmoveapiHandle = IntPtr.Zero; psmoveapiTrackerHandle = IntPtr.Zero; }
private PSMoveWorker(PSMoveWorkerSettings workerSettings) { WorkerInstance = this; this.WorkerSettings = workerSettings; if (workerSettings.Multithreaded) { StopSignal = new ManualResetEvent(false); ExitedSignal = new ManualResetEvent(false); WorkerThread = new Thread(() => { this.Run(); }); WorkerThread.Priority = System.Threading.ThreadPriority.AboveNormal; } WorkerControllerDataArray_Concurrent = new PSMoveRawControllerData_Concurrent[MAX_CONTROLLERS]; WorkerControllerDataArray = new PSMoveRawControllerData_TLS[MAX_CONTROLLERS]; for (int i = 0; i < WorkerControllerDataArray_Concurrent.Length; i++) { WorkerControllerDataArray_Concurrent[i] = new PSMoveRawControllerData_Concurrent(); WorkerControllerDataArray[i] = new PSMoveRawControllerData_TLS(WorkerControllerDataArray_Concurrent[i]); } }
private static bool WorkerContextSetupTracking( PSMoveWorkerSettings WorkerSettings, WorkerContext context) { bool success = true; // Clear out the tracking state // Reset the shared worker data context.Reset(); UnityEngine.Debug.Log("Setting up PSMove Tracking Context"); // Initialize and configure the psmove_tracker. { PSMoveAPI.PSMoveTrackerSettings settings = new PSMoveAPI.PSMoveTrackerSettings(); PSMoveAPI.psmove_tracker_settings_set_default(ref settings); settings.color_mapping_max_age = 0; // Don't used cached color mapping file if (WorkerSettings.UseManualExposure) { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_MANUAL; settings.camera_exposure = (int)(Math.Max(Math.Min(WorkerSettings.ManualExposureValue, 1.0f), 0.0f) * 65535.0f); } else { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_LOW; } settings.use_fitEllipse = 1; settings.camera_mirror = PSMove_Bool.PSMove_True; settings.color_list_start_ind = (int)WorkerSettings.InitialTrackingColor; context.PSMoveTracker = PSMoveAPI.psmove_tracker_new_with_settings(ref settings); } if (context.PSMoveTracker != IntPtr.Zero) { UnityEngine.Debug.Log("PSMove tracker initialized."); PSMoveAPI.PSMoveTrackerSmoothingSettings smoothing_settings = new PSMoveAPI.PSMoveTrackerSmoothingSettings(); PSMoveAPI.psmove_tracker_get_smoothing_settings(context.PSMoveTracker, ref smoothing_settings); smoothing_settings.filter_do_2d_r = 0; smoothing_settings.filter_do_2d_xy = 0; smoothing_settings.filter_3d_type = WorkerSettings.Filter3DType; PSMoveAPI.psmove_tracker_set_smoothing_settings(context.PSMoveTracker, ref smoothing_settings); PSMoveAPI.psmove_tracker_get_size(context.PSMoveTracker, ref context.TrackerWidth, ref context.TrackerHeight); UnityEngine.Debug.Log(string.Format("Camera Dimensions: {0} x {1}", context.TrackerWidth, context.TrackerHeight)); } else { PSMoveTracker_ErrorCode errorCode = PSMoveAPI.psmove_tracker_get_last_error(); UnityEngine.Debug.LogError(string.Format("PSMove tracker failed to initialize: {0}", errorCode.ToString())); success = false; } // Initialize fusion API if the tracker started if (success) { context.PSMoveFusion = PSMoveAPI.psmove_fusion_new(context.PSMoveTracker, 1.0f, 1000.0f); if (context.PSMoveFusion != IntPtr.Zero) { UnityEngine.Debug.Log("PSMove fusion initialized."); } else { UnityEngine.Debug.LogError("PSMove failed to initialize."); success = false; } } if (!success) { WorkerContextTeardown(context); } return(success); }
private PSMoveWorker(PSMoveWorkerSettings workerSettings) { WorkerInstance= this; this.WorkerSettings = workerSettings; if (workerSettings.Multithreaded) { StopSignal = new ManualResetEvent(false); ExitedSignal = new ManualResetEvent(false); WorkerThread = new Thread(() => { this.Run(); }); WorkerThread.Priority = System.Threading.ThreadPriority.AboveNormal; } WorkerControllerDataArray_Concurrent = new PSMoveRawControllerData_Concurrent[MAX_CONTROLLERS]; WorkerControllerDataArray = new PSMoveRawControllerData_TLS[MAX_CONTROLLERS]; for (int i= 0; i < WorkerControllerDataArray_Concurrent.Length; i++) { WorkerControllerDataArray_Concurrent[i] = new PSMoveRawControllerData_Concurrent(); WorkerControllerDataArray[i] = new PSMoveRawControllerData_TLS(WorkerControllerDataArray_Concurrent[i]); } }
private static bool WorkerContextSetupTracking( PSMoveWorkerSettings WorkerSettings, WorkerContext context) { bool success = true; // Clear out the tracking state // Reset the shared worker data context.Reset(); UnityEngine.Debug.Log("Setting up PSMove Tracking Context"); // Initialize and configure the psmove_tracker. { PSMoveAPI.PSMoveTrackerSettings settings = new PSMoveAPI.PSMoveTrackerSettings(); PSMoveAPI.psmove_tracker_settings_set_default(ref settings); settings.color_mapping_max_age = 0; // Don't used cached color mapping file if (WorkerSettings.bUseManualExposure) { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_MANUAL; settings.camera_exposure = (int)(Math.Max(Math.Min(WorkerSettings.ManualExposureValue, 1.0f), 0.0f) * 65535.0f); } else { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_LOW; } settings.use_fitEllipse = 1; settings.filter_do_2d_r = 0; settings.filter_do_2d_xy = 0; settings.camera_mirror = PSMove_Bool.PSMove_True; settings.color_list_start_ind = (int)WorkerSettings.InitialTrackingColor; context.TrackerCount = 0; for (int tracker_index = 0; tracker_index < WorkerContext.MAX_TRACKER_COUNT; ++tracker_index) { context.PSMoveTrackers[tracker_index] = PSMoveAPI.psmove_tracker_new_with_camera_and_settings(tracker_index, ref settings); if (context.PSMoveTrackers[tracker_index] != IntPtr.Zero) { UnityEngine.Debug.Log(string.Format("PSMove tracker({0}) initialized.", tracker_index)); ++context.TrackerCount; PSMoveAPI.psmove_tracker_get_size( context.PSMoveTrackers[tracker_index], ref context.TrackerWidth, ref context.TrackerHeight); UnityEngine.Debug.Log(string.Format("Camera Dimensions: {0} x {1}", context.TrackerWidth, context.TrackerHeight)); } else { PSMoveTracker_ErrorCode errorCode = PSMoveAPI.psmove_tracker_get_last_error(); UnityEngine.Debug.Log(string.Format("PSMove tracker({0}) not available: {1}", tracker_index, errorCode.ToString())); break; } } if (context.TrackerCount <= 0) { UnityEngine.Debug.LogError(string.Format("Failed to open any trackers")); success = false; } } // Initialize fusion API if the tracker started if (success) { for (int tracker_index = 0; tracker_index < context.TrackerCount; ++tracker_index) { context.PSMoveFusions[tracker_index] = PSMoveAPI.psmove_fusion_new(context.PSMoveTrackers[tracker_index], 1.0f, 1000.0f); if (context.PSMoveFusions[tracker_index] != IntPtr.Zero) { UnityEngine.Debug.Log(string.Format("PSMove fusion({0}) initialized.", tracker_index)); } else { UnityEngine.Debug.LogError(string.Format("PSMove fusion({0}) failed to initialize.", tracker_index)); success = false; break; } } } // Initialize a position filter to smooth out the tracking data if (success) { context.PSMovePositionFilter = PSMoveAPI.psmove_position_filter_new(); if (context.PSMovePositionFilter != IntPtr.Zero) { UnityEngine.Debug.Log("PSMove position filter initialized."); PSMoveAPI.PSMove_3AxisVector initial_position = new PSMoveAPI.PSMove_3AxisVector() { x = 0.0f, y = 0.0f, z = 0.0f, }; PSMoveAPI.PSMovePositionFilterSettings filter_settings = new PSMoveAPI.PSMovePositionFilterSettings(); PSMoveAPI.psmove_position_filter_get_default_settings(ref filter_settings); filter_settings.filter_type = WorkerSettings.FilterType; PSMoveAPI.psmove_position_filter_init(ref filter_settings, ref initial_position, context.PSMovePositionFilter); } else { UnityEngine.Debug.LogError(string.Format("Failed to allocate PSMove Position Filter")); success = false; } } if (!success) { WorkerContextTeardownTracking(context); } return success; }
private void WorkerSetup(PSMoveWorkerSettings workerSettings) { #if LOAD_DLL_MANUALLY if (psmoveapiSharedLibHandle == IntPtr.Zero) { #if UNITY_EDITOR_WIN if (IntPtr.Size == 8) { psmoveapiSharedLibHandle = LoadLib(Application.dataPath + "/Plugins/x86_64/psmoveapi.dll"); } else { psmoveapiSharedLibHandle = LoadLib(Application.dataPath + "/Plugins/x86/psmoveapi.dll"); } #elif UNITY_STANDALONE_WIN psmoveapiSharedLibHandle = LoadLib(Application.dataPath + "/Plugins/psmoveapi.dll"); #endif } if (psmoveapiTrackerSharedLibHandle == IntPtr.Zero) { #if UNITY_EDITOR_WIN if (IntPtr.Size == 8) { psmoveapiTrackerSharedLibHandle = LoadLib(Application.dataPath + "/Plugins/x86_64/psmoveapi_tracker.dll"); } else { psmoveapiTrackerSharedLibHandle = LoadLib(Application.dataPath + "/Plugins/x86/psmoveapi_tracker.dll"); } #elif UNITY_STANDALONE_WIN psmoveapiSharedLibHandle = LoadLib(Application.dataPath + "/Plugins/psmoveapi_tracker.dll"); #endif } #endif // LOAD_DLL_MANUALLY if (!WorkerThread.IsAlive) { WorkerSettings= workerSettings; WorkerThread.Start(); } }
public void OnGameStarted(PSMoveWorkerSettings workerSettings) { // Start the worker thread in case it's not already running WorkerSetup(workerSettings); }
private PSMoveWorker() { WorkerSettings = new PSMoveWorkerSettings(); HaltThreadSignal = new ManualResetEvent(false); ThreadExitedSignal = new ManualResetEvent(false); WorkerThread = new Thread(() => { this.ThreadProc(); }); WorkerThread.Priority = System.Threading.ThreadPriority.AboveNormal; WorkerControllerDataArray_Concurrent = new PSMoveRawControllerData_Concurrent[MAX_CONTROLLERS]; WorkerControllerDataArray = new PSMoveRawControllerData_TLS[MAX_CONTROLLERS]; for (int i = 0; i < WorkerControllerDataArray_Concurrent.Length; i++) { WorkerControllerDataArray_Concurrent[i] = new PSMoveRawControllerData_Concurrent(); WorkerControllerDataArray[i] = new PSMoveRawControllerData_TLS(WorkerControllerDataArray_Concurrent[i]); } psmoveapiSharedLibHandle = IntPtr.Zero; psmoveapiTrackerSharedLibHandle = IntPtr.Zero; }
public IntPtr PSMoveFusion; // PSMoveFusion* // Constructor public WorkerContext(PSMoveRawControllerData_TLS[] controllerDataArray, PSMoveWorkerSettings settings) { WorkerSettings= settings; WorkerControllerDataArray= controllerDataArray; // This timestamp is used to throttle how frequently we poll for controller count changes moveCountCheckTimer = new Stopwatch(); Reset(); }
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 bool WorkerContextSetupTracking( PSMoveWorkerSettings WorkerSettings, WorkerContext context) { bool success = true; // Clear out the tracking state // Reset the shared worker data context.Reset(); UnityEngine.Debug.Log("Setting up PSMove Tracking Context"); // Initialize and configure the psmove_tracker. { PSMoveAPI.PSMoveTrackerSettings settings = new PSMoveAPI.PSMoveTrackerSettings(); PSMoveAPI.psmove_tracker_settings_set_default(ref settings); settings.color_mapping_max_age = 0; // Don't used cached color mapping file if (WorkerSettings.UseManualExposure) { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_MANUAL; settings.camera_exposure = (int)(Math.Max(Math.Min(WorkerSettings.ManualExposureValue, 1.0f), 0.0f) * 65535.0f); } else { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_LOW; } settings.use_fitEllipse = 1; settings.camera_mirror = PSMove_Bool.PSMove_True; settings.camera_api = WorkerSettings.CameraAPI; settings.path_to_cleye_server_exe = WorkerSettings.ApplicationDataPath + "/Plugins/x86_64"; settings.color_list_start_ind = (int)WorkerSettings.InitialTrackingColor; context.PSMoveTracker = PSMoveAPI.psmove_tracker_new_with_settings(ref settings); } if (context.PSMoveTracker != IntPtr.Zero) { UnityEngine.Debug.Log("PSMove tracker initialized."); PSMoveAPI.PSMoveTrackerSmoothingSettings smoothing_settings = new PSMoveAPI.PSMoveTrackerSmoothingSettings(); PSMoveAPI.psmove_tracker_get_smoothing_settings(context.PSMoveTracker, ref smoothing_settings); smoothing_settings.filter_do_2d_r = 0; smoothing_settings.filter_do_2d_xy = 0; smoothing_settings.filter_3d_type = WorkerSettings.Filter3DType; PSMoveAPI.psmove_tracker_set_smoothing_settings(context.PSMoveTracker, ref smoothing_settings); PSMoveAPI.psmove_tracker_get_size(context.PSMoveTracker, ref context.TrackerWidth, ref context.TrackerHeight); UnityEngine.Debug.Log(string.Format("Camera Dimensions: {0} x {1}", context.TrackerWidth, context.TrackerHeight)); } else { PSMoveTracker_ErrorCode errorCode= PSMoveAPI.psmove_tracker_get_last_error(); UnityEngine.Debug.LogError(string.Format("PSMove tracker failed to initialize: {0}", errorCode.ToString())); success = false; } // Initialize fusion API if the tracker started if (success) { context.PSMoveFusion = PSMoveAPI.psmove_fusion_new(context.PSMoveTracker, 1.0f, 1000.0f); if (context.PSMoveFusion != IntPtr.Zero) { UnityEngine.Debug.Log("PSMove fusion initialized."); } else { UnityEngine.Debug.LogError("PSMove failed to initialize."); success = false; } } if (!success) { WorkerContextTeardown(context); } return success; }
private static bool WorkerContextSetupTracking( PSMoveWorkerSettings WorkerSettings, WorkerContext context) { bool success = true; // Clear out the tracking state // Reset the shared worker data context.Reset(); UnityEngine.Debug.Log("Setting up PSMove Tracking Context"); // Initialize and configure the psmove_tracker. { PSMoveAPI.PSMoveTrackerSettings settings = new PSMoveAPI.PSMoveTrackerSettings(); PSMoveAPI.psmove_tracker_settings_set_default(ref settings); settings.color_mapping_max_age = 0; // Don't used cached color mapping file if (WorkerSettings.bUseManualExposure) { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_MANUAL; settings.camera_exposure = (int)(Math.Max(Math.Min(WorkerSettings.ManualExposureValue, 1.0f), 0.0f) * 65535.0f); } else { settings.exposure_mode = PSMoveTracker_Exposure.Exposure_LOW; } settings.use_fitEllipse = 1; settings.filter_do_2d_r = 0; settings.filter_do_2d_xy = 0; settings.camera_mirror = PSMove_Bool.PSMove_True; settings.color_list_start_ind = (int)WorkerSettings.InitialTrackingColor; context.TrackerCount = 0; for (int tracker_index = 0; tracker_index < WorkerContext.MAX_TRACKER_COUNT; ++tracker_index) { context.PSMoveTrackers[tracker_index] = PSMoveAPI.psmove_tracker_new_with_camera_and_settings(tracker_index, ref settings); if (context.PSMoveTrackers[tracker_index] != IntPtr.Zero) { UnityEngine.Debug.Log(string.Format("PSMove tracker({0}) initialized.", tracker_index)); ++context.TrackerCount; PSMoveAPI.psmove_tracker_get_size( context.PSMoveTrackers[tracker_index], ref context.TrackerWidth, ref context.TrackerHeight); UnityEngine.Debug.Log(string.Format("Camera Dimensions: {0} x {1}", context.TrackerWidth, context.TrackerHeight)); } else { PSMoveTracker_ErrorCode errorCode = PSMoveAPI.psmove_tracker_get_last_error(); UnityEngine.Debug.Log(string.Format("PSMove tracker({0}) not available: {1}", tracker_index, errorCode.ToString())); break; } } if (context.TrackerCount <= 0) { UnityEngine.Debug.LogError(string.Format("Failed to open any trackers")); success = false; } } // Initialize fusion API if the tracker started if (success) { for (int tracker_index = 0; tracker_index < context.TrackerCount; ++tracker_index) { context.PSMoveFusions[tracker_index] = PSMoveAPI.psmove_fusion_new(context.PSMoveTrackers[tracker_index], 1.0f, 1000.0f); if (context.PSMoveFusions[tracker_index] != IntPtr.Zero) { UnityEngine.Debug.Log(string.Format("PSMove fusion({0}) initialized.", tracker_index)); } else { UnityEngine.Debug.LogError(string.Format("PSMove fusion({0}) failed to initialize.", tracker_index)); success = false; break; } } } // Initialize a position filter to smooth out the tracking data if (success) { context.PSMovePositionFilter = PSMoveAPI.psmove_position_filter_new(); if (context.PSMovePositionFilter != IntPtr.Zero) { UnityEngine.Debug.Log("PSMove position filter initialized."); PSMoveAPI.PSMove_3AxisVector initial_position = new PSMoveAPI.PSMove_3AxisVector() { x = 0.0f, y = 0.0f, z = 0.0f, }; PSMoveAPI.PSMovePositionFilterSettings filter_settings = new PSMoveAPI.PSMovePositionFilterSettings(); PSMoveAPI.psmove_position_filter_get_default_settings(ref filter_settings); filter_settings.filter_type = WorkerSettings.FilterType; PSMoveAPI.psmove_position_filter_init(ref filter_settings, ref initial_position, context.PSMovePositionFilter); } else { UnityEngine.Debug.LogError(string.Format("Failed to allocate PSMove Position Filter")); success = false; } } if (!success) { WorkerContextTeardownTracking(context); } return(success); }