/*
     * void OnEvent(params object[] args)
     * {
     *      WVR_Event_t _event = (WVR_Event_t)args[0];
     *      switch (_event.common.type)
     *      {
     *      case WVR_EventType.WVR_EventType_ButtonPressed:
     *              // Get system key
     *              if (_event.input.inputId == WVR_InputId.WVR_InputId_Alias1_System)
     *              {
     *                      PrintDebugLog (OnEvent() WVR_InputId_Alias1_System is pressed.);
     *              }
     *              break;
     *      case WVR_EventType.WVR_EventType_RecenterSuccess:
     *      case WVR_EventType.WVR_EventType_RecenterSuccess3DoF:
     *              PrintDebugLog (OnEvent() recentered.);
     *              break;
     *      }
     * }
     */
    private void SetupPoseSimulation()
    {
        if (WaveVR.Instance.Initialized)
        {
            if (!this.bSetupSimulation)
            {
                this.currSimulationOption = this.SimulationOption;
                if (this.currSimulationOption == WVR_SimulationOption.WhenNoPosition)
                {
                    WaveVR.Instance.SetPoseSimulation(WVR_SimulationType.WVR_SimulationType_Auto);
                }
                else if (this.currSimulationOption == WVR_SimulationOption.ForceSimulation)
                {
                    WaveVR.Instance.SetPoseSimulation(WVR_SimulationType.WVR_SimulationType_ForceOn);
                }
                else
                {
                    WaveVR.Instance.SetPoseSimulation(WVR_SimulationType.WVR_SimulationType_ForceOff);
                }

                this.bSetupSimulation = true;
                PrintDebugLog("SetupPoseSimulation() " + this.Type + ", simulation option: " + this.currSimulationOption);
            }
            if (!this.bSetupFollowHead)
            {
                this.currFollowHead = this.FollowHead;
                WaveVR.Instance.SetPoseSimulationFollowHead(this.currFollowHead);
                this.bSetupFollowHead = true;
                PrintDebugLog("SetupPoseSimulation() " + this.Type + ", follow head: " + this.currFollowHead);
            }
        }
    }
Beispiel #2
0
    void Awake()
    {
        if (TrackPosition == false)
        {
            SimulationOption = WVR_SimulationOption.NoSimulation;
            FollowHead       = false;
        }

        gameObject.SetActive(false);
        PrintDebugLog("Awake() " + this.Type
                      + ", TrackPosition: " + TrackPosition
                      + ", SimulationOption: " + SimulationOption
                      + ", FollowHead: " + FollowHead
                      + ", TrackRotation: " + TrackRotation
                      + ", TrackTiming: " + TrackTiming);

        WaveVR_PointerCameraTracker pcTracker = gameObject.GetComponent <WaveVR_PointerCameraTracker>();

        if (pcTracker == null)
        {
            if (this.Type == WaveVR_Controller.EDeviceType.Head)
            {
                PrintDebugLog("Awake() " + this.Type + ", load WaveVR_DevicePoseTracker.");
                devicePoseTracker = (WaveVR_DevicePoseTracker)gameObject.AddComponent <WaveVR_DevicePoseTracker> ();
                if (null != devicePoseTracker)
                {
                    devicePoseTracker.type            = Type;
                    devicePoseTracker.trackPosition   = TrackPosition;
                    devicePoseTracker.EnableNeckModel = this.EnableNeckModel;
                    devicePoseTracker.trackRotation   = TrackRotation;
                    devicePoseTracker.timing          = TrackTiming;
                }
            }
            else
            {
                PrintDebugLog("Awake() " + this.Type + ", load WaveVR_ControllerPoseTracker.");
                ctrlerPoseTracker = (WaveVR_ControllerPoseTracker)gameObject.AddComponent <WaveVR_ControllerPoseTracker> ();
                if (null != ctrlerPoseTracker)
                {
                    ctrlerPoseTracker.Type             = Type;
                    ctrlerPoseTracker.TrackPosition    = TrackPosition;
                    ctrlerPoseTracker.SimulationOption = SimulationOption;
                    ctrlerPoseTracker.FollowHead       = FollowHead;
                    ctrlerPoseTracker.TrackRotation    = TrackRotation;
                    ctrlerPoseTracker.TrackTiming      = TrackTiming;
                }
            }
        }
        gameObject.SetActive(true);
    }
    void Awake()
    {
        if (TrackPosition == false)
        {
            SimulationOption = WVR_SimulationOption.NoSimulation;
            FollowHead       = false;
        }

        gameObject.SetActive(false);
        PrintDebugLog("Awake() TrackPosition: " + TrackPosition + ", SimulationOption=" + SimulationOption +
                      ", FollowHead: " + FollowHead + ", TrackRotation: " + TrackRotation + ", TrackTiming=" + TrackTiming);

        WaveVR_PointerCameraTracker pcTracker = gameObject.GetComponent <WaveVR_PointerCameraTracker>();

        if (SimulationOption == WVR_SimulationOption.ForceSimulation || SimulationOption == WVR_SimulationOption.WhenNoPosition)
        {
            if (pcTracker == null)
            {
                PrintDebugLog("Awake() load WaveVR_ControllerPoseTracker.");
                WaveVR_ControllerPoseTracker _cpt = (WaveVR_ControllerPoseTracker)gameObject.AddComponent <WaveVR_ControllerPoseTracker> ();
                if (null != _cpt)
                {
                    _cpt.Type             = Type;
                    _cpt.TrackPosition    = TrackPosition;
                    _cpt.SimulationOption = SimulationOption;
                    _cpt.FollowHead       = FollowHead;
                    _cpt.TrackRotation    = TrackRotation;
                    _cpt.TrackTiming      = TrackTiming;
                }
            }
        }
        else
        {
            if (pcTracker == null)
            {
                PrintDebugLog("Awake() load WaveVR_DevicePoseTracker.");
                WaveVR_DevicePoseTracker _dpt = (WaveVR_DevicePoseTracker)gameObject.AddComponent <WaveVR_DevicePoseTracker> ();
                if (null != _dpt)
                {
                    _dpt.type          = Type;
                    _dpt.trackPosition = TrackPosition;
                    _dpt.trackRotation = TrackRotation;
                    _dpt.timing        = TrackTiming;
                }
            }
        }
        gameObject.SetActive(true);
    }
    private void SetupPoseSimulation()
    {
        #if UNITY_EDITOR
        if (Application.isEditor)
        {
        }
        else
        #endif
        {
            if (WaveVR.Instance != null)
            {
                if (!this.bSetupSimulation)
                {
                    this.currSimulationOption = this.SimulationOption;
                    if (this.currSimulationOption == WVR_SimulationOption.WhenNoPosition)
                    {
                        Interop.WVR_SetArmModel(WVR_SimulationType.WVR_SimulationType_Auto);
                    }
                    else if (this.currSimulationOption == WVR_SimulationOption.ForceSimulation)
                    {
                        Interop.WVR_SetArmModel(WVR_SimulationType.WVR_SimulationType_ForceOn);
                    }
                    else
                    {
                        Interop.WVR_SetArmModel(WVR_SimulationType.WVR_SimulationType_ForceOff);
                    }

                    this.bSetupSimulation = true;
                    PrintDebugLog("SetupPoseSimulation() simulation option: " + this.currSimulationOption);
                }
                if (!this.bSetupFollowHead)
                {
                    this.currFollowHead = this.FollowHead;
                    Interop.WVR_SetArmSticky(this.currFollowHead);
                    this.bSetupFollowHead = true;
                    PrintDebugLog("SetupPoseSimulation() follow head: " + this.currFollowHead);
                }
            }
        }
    }