Inheritance: MonoBehaviour
Exemple #1
0
        protected sealed override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (UsePsMove)
            {
                PSMoveManager.GetManagerInstance().Update();
                PsMoveController.Update();
            }
            if (firstUpdate)
            {
                firstUpdate  = false;
                workerThread = new Thread(() =>
                {
                    while (IsRunning)
                    {
                        //Thread.Sleep(100);
                        UpdateAsync();
                        //Console.WriteLine("b" + Time.ElapsedGameTime.TotalSeconds);

                        //
                    }
                });

                workerThread.Start();
            }
        }
Exemple #2
0
 public void OnDestroy()
 {
     if (PSMoveManager.GetManagerInstance() != null)
     {
         PSMoveManager.GetManagerInstance().ReleasePSMove(dataContext);
     }
 }
Exemple #3
0
    // Private methods
    private void Setup()
    {
        if (ManagerInstance == null)
        {
#if LOAD_DLL_MANUALLY
            if (IntPtr.Size == 8)
            {
                psmoveapiHandle        = LoadLib("Assets/Plugins/x86_64/psmoveapi.dll");
                psmoveapiTrackerHandle = LoadLib("Assets/Plugins/x86_64/psmoveapi_tracker.dll");
            }
            else
            {
                psmoveapiHandle        = LoadLib("Assets/Plugins/x86/psmoveapi.dll");
                psmoveapiTrackerHandle = LoadLib("Assets/Plugins/x86/psmoveapi_tracker.dll");
            }
#endif

            ManagerInstance = this;
            PSMoveHitchWatchdog.EmitHitchLogging = this.EmitHitchLogging;
            PSMoveWorker.StartWorkerThread(
                new PSMoveWorkerSettings()
            {
                Multithreaded        = this.UseMultithreading,
                UseManualExposure    = this.UseManualExposure,
                ManualExposureValue  = this.ManualExposureValue,
                InitialTrackingColor = this.InitialTrackingColor,
                PSMoveOffset         = this.PSMoveOffset,
                Filter3DType         = this.Filter3DType,
                DisableTracking      = this.DisableTracking,
                ApplicationDataPath  = Application.dataPath
            });
        }
    }
Exemple #4
0
    private void Shutdown()
    {
        if (ManagerInstance != null)
        {
            PSMoveWorker.StopWorkerThread();

            //Free any manually loaded DLLs
            if (psmoveapiTrackerHandle != IntPtr.Zero)
            {
                FreeLibrary(psmoveapiTrackerHandle);
            }

            if (psmoveapiHandle != IntPtr.Zero)
            {
                FreeLibrary(psmoveapiHandle);
            }

            if (cleyeHandle != IntPtr.Zero)
            {
                FreeLibrary(cleyeHandle);
            }

            ManagerInstance = null;
        }
    }
Exemple #5
0
 /// <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);
     }
 }
Exemple #6
0
    // Private methods
    private void Setup()
    {
        if (ManagerInstance == null)
        {
#if LOAD_DLL_MANUALLY
            if (IntPtr.Size == 8)
            {
                cleyeHandle            = IntPtr.Zero;
                psmoveapiHandle        = LoadLib("Assets/Plugins/x86_64/psmoveapi.dll");
                psmoveapiTrackerHandle = LoadLib("Assets/Plugins/x86_64/psmoveapi_tracker.dll");
            }
            else
            {
                cleyeHandle            = LoadLib("c:/Windows/SysWOW64/CLEyeMulticam.dll");
                psmoveapiHandle        = LoadLib("Assets/Plugins/x86/psmoveapi.dll");
                psmoveapiTrackerHandle = LoadLib("Assets/Plugins/x86/psmoveapi_tracker.dll");
            }
#endif

            ManagerInstance = this;
            PSMoveHitchWatchdog.EmitHitchLogging = this.EmitHitchLogging;
            PSMoveWorker.StartWorkerThread(
                new PSMoveWorkerSettings()
            {
                CameraAPI            = this.CameraAPI,
                Multithreaded        = this.UseMultithreading,
                UseManualExposure    = this.UseManualExposure,
                ManualExposureValue  = this.ManualExposureValue,
                InitialTrackingColor = this.InitialTrackingColor,
                DisableTracking      = this.DisableTracking,
                ApplicationDataPath  = Application.dataPath
            });
        }
    }
    public void OnApplicationQuit()
    {
        if (ManagerInstance != null)
        {
            PSMoveWorker.GetWorkerInstance().OnGameEnded();

            ManagerInstance = null;
        }
    }
Exemple #8
0
        protected override void Initialize()
        {
            base.Initialize();

            if (UsePsMove)
            {
                var manager = new PSMoveManager();
                manager.Initialize();
                ToDispose(manager);
                PsMoveController = new PSMoveController(Vector3.Zero);
                ToDispose(PsMoveController);
                PsMoveController.OnButtonSelectPressed += (sender, args) => PsMoveController.ResetYaw();
                PsMoveController.OnButtonStartPressed  += (sender, args) => PsMoveController.ResetYaw();
            }
            eyeTexture[0] = hmd.CreateSwapTexture(GraphicsDevice, Format.B8G8R8A8_UNorm,
                                                  hmd.GetFovTextureSize(EyeType.Left, hmd.DefaultEyeFov[0]), true);
            eyeTexture[1] = hmd.CreateSwapTexture(GraphicsDevice, Format.B8G8R8A8_UNorm,
                                                  hmd.GetFovTextureSize(EyeType.Right, hmd.DefaultEyeFov[1]), true);
            ToDispose(eyeTexture[0]);
            ToDispose(eyeTexture[1]);

            // Create our layer
            layerEyeFov = new LayerEyeFov
            {
                Header            = new LayerHeader(LayerType.EyeFov, LayerFlags.None),
                ColorTextureLeft  = eyeTexture[0].TextureSet,
                ColorTextureRight = eyeTexture[1].TextureSet,
                ViewportLeft      = new Rect(0, 0, eyeTexture[0].Size.Width, eyeTexture[0].Size.Height),
                ViewportRight     = new Rect(0, 0, eyeTexture[1].Size.Width, eyeTexture[1].Size.Height),
                FovLeft           = hmd.DefaultEyeFov[0],
                FovRight          = hmd.DefaultEyeFov[1],
            };

            // Keep eye view offsets
            eyeRenderDesc[0]      = hmd.GetRenderDesc(EyeType.Left, hmd.DefaultEyeFov[0]);
            eyeRenderDesc[1]      = hmd.GetRenderDesc(EyeType.Right, hmd.DefaultEyeFov[1]);
            hmdToEyeViewOffset[0] = eyeRenderDesc[0].HmdToEyeViewOffset;
            hmdToEyeViewOffset[1] = eyeRenderDesc[1].HmdToEyeViewOffset;

            // Create a mirror texture
            mirrorTexture = hmd.CreateMirrorTexture(GraphicsDevice, GraphicsDevice.BackBuffer.Description);

            // Set presentation interval to immediate as SubmitFrame will be taking care of VSync
            GraphicsDevice.Presenter.PresentInterval = PresentInterval.Immediate;

            // Configure tracking
            hmd.ConfigureTracking(
                TrackingCapabilities.Orientation | TrackingCapabilities.Position |
                TrackingCapabilities.MagYawCorrection,
                TrackingCapabilities.None);

            // Set enabled capabilities
            hmd.EnabledCaps = HMDCapabilities.LowPersistence | HMDCapabilities.DynamicPrediction;
        }
 // Unity Callbacks
 public void Awake()
 {
     if (ManagerInstance == null)
     {
         ManagerInstance = this;
         PSMoveHitchWatchdog.EmitHitchLogging = this.EmitHitchLogging;
         PSMoveWorker.GetWorkerInstance().OnGameStarted(
             new PSMoveWorkerSettings()
         {
             bUseManualExposure   = this.UseManualExposure,
             ManualExposureValue  = this.ManualExposureValue,
             InitialTrackingColor = this.InitialTrackingColor,
             PSMoveOffset         = this.PSMoveOffset,
             Filter3DType         = this.Filter3DType,
             bTrackerEnabled      = this.TrackerEnabled,
             ApplicationDataPath  = Application.dataPath
         });
     }
 }
 void move_OnButtonPSPressed(object sender, EventArgs e)
 {
     Debug.Log("PS button pressed");
     PSMoveManager.GetManagerInstance().AlignToCenterEye(transform, Camera.main.transform);
 }
    private void Shutdown()
    {
        if (ManagerInstance != null)
        {
            PSMoveWorker.StopWorkerThread();

            //Free any manually loaded DLLs
            if (psmoveapiTrackerHandle != IntPtr.Zero)
            {
                FreeLibrary(psmoveapiTrackerHandle);
            }

            if (psmoveapiHandle != IntPtr.Zero)
            {
                FreeLibrary(psmoveapiHandle);
            }

            if (cleyeHandle != IntPtr.Zero)
            {
                FreeLibrary(cleyeHandle);
            }

            ManagerInstance = null;
        }
    }
    // Private methods
    private void Setup()
    {
        if (ManagerInstance == null)
        {
#if LOAD_DLL_MANUALLY
            if (IntPtr.Size == 8)
            {
                cleyeHandle = IntPtr.Zero;
                psmoveapiHandle = LoadLib("Assets/Plugins/x86_64/psmoveapi.dll");
                psmoveapiTrackerHandle = LoadLib("Assets/Plugins/x86_64/psmoveapi_tracker.dll");
            }
            else
            {
                cleyeHandle = LoadLib("c:/Windows/SysWOW64/CLEyeMulticam.dll");
                psmoveapiHandle = LoadLib("Assets/Plugins/x86/psmoveapi.dll");
                psmoveapiTrackerHandle = LoadLib("Assets/Plugins/x86/psmoveapi_tracker.dll");
            }
#endif

            ManagerInstance = this;
            PSMoveHitchWatchdog.EmitHitchLogging = this.EmitHitchLogging;
            PSMoveWorker.StartWorkerThread(
                new PSMoveWorkerSettings()
                {
                    CameraAPI= this.CameraAPI,
                    Multithreaded= this.UseMultithreading,
                    UseManualExposure = this.UseManualExposure,
                    ManualExposureValue = this.ManualExposureValue,
                    InitialTrackingColor = this.InitialTrackingColor,
                    Filter3DType= this.Filter3DType,
                    DisableTracking = this.DisableTracking,
                    ApplicationDataPath = Application.dataPath
                });
        }
    }
    public void OnApplicationQuit()
    {
        if (ManagerInstance != null)
        {
            PSMoveWorker.GetWorkerInstance().OnGameEnded();

            ManagerInstance = null;
        }
    }
 // Unity Callbacks
 public void Awake()
 {
     if (ManagerInstance == null)
     {
         ManagerInstance = this;
         PSMoveHitchWatchdog.EmitHitchLogging = this.EmitHitchLogging;
         PSMoveWorker.GetWorkerInstance().OnGameStarted(
             new PSMoveWorkerSettings()
             {
                 bUseManualExposure = this.UseManualExposure,
                 ManualExposureValue = this.ManualExposureValue,
                 InitialTrackingColor = this.InitialTrackingColor,
                 PSMoveOffset = this.PSMoveOffset,
                 FilterType = this.FilterType,
                 bTrackerEnabled = this.TrackerEnabled,
                 ApplicationDataPath = Application.dataPath
             });
     }
 }