コード例 #1
0
ファイル: PSMoveManager.cs プロジェクト: MHDante/OrbitVR
 public void ReleasePSMove(PSMoveDataContext DataContext)
 {
     if (DataContext.PSMoveID != -1)
     {
         DataContext.Clear();
     }
 }
コード例 #2
0
ファイル: PSMovePose.cs プロジェクト: MHDante/OrbitVR
        public void PoseUpdate(PSMoveDataContext DataContext, Transform ParentGameObjectTransform)
        {
            Matrix     TrackingSpaceToWorldSpacePosition = Matrix.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 =
                    Vector3.TransformCoordinate(PSMoveUtility.PSMoveCSToUnityCSPosition(PSMPosTrackingSpace),
                                                TrackingSpaceToWorldSpacePosition);

                // 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 =
                PSMoveUtility.PSMoveQuatToUnityQuat(PSMOriNative) * OrientationTransform;

            // Save the resulting pose, updating for internal zero yaw
            UncorrectedWorldOrientation = PSMOriWorld;
            WorldOrientation            = ZeroYaw * PSMOriWorld;
        }
コード例 #3
0
ファイル: PSMoveController.cs プロジェクト: MHDante/OrbitVR
        /// <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 PSMoveController(Vector3 Position)
        {
            transform        = new Transform();
            transform.parent = new Transform()
            {
                position = Position
            };
            if (PSMoveManager.GetManagerInstance() != null)
            {
                dataContext = PSMoveManager.GetManagerInstance().AcquirePSMove(this.PSMoveID);
            }
            model = OrbIt.Game.Content.Load <Model>("PSMove");

            BasicEffect.EnableDefaultLighting(model, true);
        }
コード例 #4
0
ファイル: PSMoveManager.cs プロジェクト: MHDante/OrbitVR
        // 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);
        }
コード例 #5
0
ファイル: PSMoveManager.cs プロジェクト: MHDante/OrbitVR
 public void ReleasePSMove(PSMoveDataContext DataContext)
 {
     PSMoveWorker.GetWorkerInstance().ReleasePSMove(DataContext);
 }