public void PoseUpdate(PSMoveDataContext DataContext, Transform ParentGameObjectTransform) { Matrix4x4 TrackingSpaceToWorldSpacePosition = Matrix4x4.identity; Quaternion OrientationTransform = Quaternion.identity; PSMoveUtility.ComputeTrackingToWorldTransforms( ParentGameObjectTransform, ref TrackingSpaceToWorldSpacePosition, ref OrientationTransform); if (DataContext.GetIsSeenByTracker()) { // The PSMove position is given in the space of the rift camera in centimeters Vector3 PSMPosTrackingSpace = DataContext.GetTrackingSpacePosition(); // Transform to world space Vector3 PSMPosWorldSpace = TrackingSpaceToWorldSpacePosition.MultiplyPoint3x4( PSMoveUtility.PSMoveCSToUnityCSPosition(PSMPosTrackingSpace)); // Save the resulting position, updating for internal offset UncorrectedWorldPosition = PSMPosWorldSpace; WorldPosition = PSMPosWorldSpace - ZeroPosition; } // The PSMove orientation is given in its native coordinate system Quaternion PSMOriNative = DataContext.GetTrackingSpaceOrientation(); // Apply controller orientation first, then apply orientation transform Quaternion PSMOriWorld = OrientationTransform * PSMoveUtility.PSMoveQuatToUnityQuat(PSMOriNative); // Save the resulting pose, updating for internal zero yaw UncorrectedWorldOrientation = PSMOriWorld; WorldOrientation = ZeroYaw * PSMOriWorld; }
/// <summary> /// NOTE! This function does NOT pair the controller by Bluetooth. /// If the controller is not already paired, it can only be connected by USB. /// See README for more information. /// </summary> public void Start() { if (PSMoveManager.GetManagerInstance() != null) { dataContext = PSMoveManager.GetManagerInstance().AcquirePSMove(this.PSMoveID); } }
public void PoseUpdate(PSMoveDataContext DataContext, Transform ParentGameObjectTransform) { Matrix4x4 TrackingSpaceToWorldSpacePosition = Matrix4x4.identity; Quaternion OrientationTransform= Quaternion.identity; PSMoveUtility.ComputeTrackingToWorldTransforms( ParentGameObjectTransform, ref TrackingSpaceToWorldSpacePosition, ref OrientationTransform); if (DataContext.GetIsSeenByTracker()) { // The PSMove position is given in the space of the rift camera in centimeters Vector3 PSMPosTrackingSpace = DataContext.GetTrackingSpacePosition(); // Transform to world space Vector3 PSMPosWorldSpace = TrackingSpaceToWorldSpacePosition.MultiplyPoint3x4( PSMoveUtility.PSMoveCSToUnityCSPosition(PSMPosTrackingSpace)); // Save the resulting position, updating for internal offset UncorrectedWorldPosition = PSMPosWorldSpace; WorldPosition = PSMPosWorldSpace - ZeroPosition; } // The PSMove orientation is given in its native coordinate system Quaternion PSMOriNative = DataContext.GetTrackingSpaceOrientation(); // Apply controller orientation first, then apply orientation transform Quaternion PSMOriWorld = OrientationTransform * PSMoveUtility.PSMoveQuatToUnityQuat(PSMOriNative); // Save the resulting pose, updating for internal zero yaw UncorrectedWorldOrientation = PSMOriWorld; WorldOrientation = ZeroYaw * PSMOriWorld; }
public void ReleasePSMove(PSMoveDataContext DataContext) { if (DataContext.PSMoveID != -1) { DataContext.Clear(); } }
public void ReleasePSMove(PSMoveDataContext DataContext) { if (DataContext.PSMoveID != -1) { DataContext.Clear(); lock (this) { // The worker thread will tear-down the tracker //assert(AcquiredContextCounter > 0); AcquiredContextCounter--; } } }
// Tell the PSMove Worker that we want to start listening to this controller. public PSMoveDataContext AcquirePSMove(int PSMoveID) { PSMoveDataContext DataContext = null; if (PSMoveID >= 0 && PSMoveID < MAX_CONTROLLERS) { // Bind the data context to the concurrent data for the requested controller // This doesn't mean that the controller is active, just that a component // is now watching this block of data. // Also this is thread safe because were not actually looking at the concurrent data // at this point, just assigning a pointer to the concurrent data. DataContext = new PSMoveDataContext( PSMoveID, WorkerInstance.WorkerControllerDataArray_Concurrent[PSMoveID]); } return(DataContext); }
public void ReleasePSMove(PSMoveDataContext DataContext) { PSMoveWorker.GetWorkerThreadInstance().ReleasePSMove(DataContext); }
public void ReleasePSMove(PSMoveDataContext DataContext) { if (DataContext.PSMoveID != -1) { DataContext.Clear(); lock(this) { // The worker thread will tear-down the tracker //assert(AcquiredContextCounter > 0); AcquiredContextCounter--; } } }
// Tell the PSMove Worker that we want to start listening to this controller. public PSMoveDataContext AcquirePSMove(int PSMoveID) { PSMoveDataContext DataContext= null; if (PSMoveID >= 0 && PSMoveID < MAX_CONTROLLERS) { // Bind the data context to the concurrent data for the requested controller // This doesn't mean that the controller is active, just that a component // is now watching this block of data. // Also this is thread safe because were not actually looking at the concurrent data // at this point, just assigning a pointer to the concurrent data. DataContext= new PSMoveDataContext( PSMoveID, WorkerInstance.WorkerControllerDataArray_Concurrent[PSMoveID]); // The worker thread will create a tracker if one isn't active at this moment lock(this) { AcquiredContextCounter++; } } return DataContext; }
/// <summary> /// NOTE! This function does NOT pair the controller by Bluetooth. /// If the controller is not already paired, it can only be connected by USB. /// See README for more information. /// </summary> public void Start() { if (PSMoveManager.GetManagerInstance() != null) { dataContext = PSMoveManager.GetManagerInstance().AcquirePSMove(this.PSMoveID); } }
public void ReleasePSMove(PSMoveDataContext DataContext) { PSMoveWorker.GetWorkerThreadInstance().ReleasePSMove(DataContext); }
public void ReleasePSMove(PSMoveDataContext DataContext) { if (DataContext.PSMoveID != -1) { DataContext.Clear(); } }