Inheritance: MonoBehaviour
Beispiel #1
0
    void Start()
    {
        moveComponent     = gameObject.GetComponent <PSMoveController>();
        rendererComponent = gameObject.GetComponent <MeshRenderer>();

        // Button Pressed callbacks
        moveComponent.OnButtonTrianglePressed += move_OnButtonTrianglePressed;
        moveComponent.OnButtonCirclePressed   += move_OnButtonCirclePressed;
        moveComponent.OnButtonCrossPressed    += move_OnButtonCrossPressed;
        moveComponent.OnButtonSquarePressed   += move_OnButtonSquarePressed;
        moveComponent.OnButtonSelectPressed   += move_OnButtonSelectPressed;
        moveComponent.OnButtonStartPressed    += move_OnButtonStartPressed;
        moveComponent.OnButtonPSPressed       += move_OnButtonPSPressed;
        moveComponent.OnButtonMovePressed     += move_OnButtonMovePressed;

        // Button Release callbacks
        moveComponent.OnButtonTriangleReleased += move_OnButtonTriangleReleased;
        moveComponent.OnButtonCircleReleased   += move_OnButtonCircleReleased;
        moveComponent.OnButtonCrossReleased    += move_OnButtonCrossReleased;
        moveComponent.OnButtonSquareReleased   += move_OnButtonSquareReleased;
        moveComponent.OnButtonSelectReleased   += move_OnButtonSelectReleased;
        moveComponent.OnButtonStartReleased    += move_OnButtonStartReleased;
        moveComponent.OnButtonPSReleased       += move_OnButtonPSReleased;
        moveComponent.OnButtonMoveReleased     += move_OnButtonMoveReleased;

        // Don't show the controller model until we get tracking
        if (HideWhenUntracked && rendererComponent != null)
        {
            rendererComponent.enabled = false;
        }
    }
Beispiel #2
0
	void Start() 
	{
        moveComponent = gameObject.GetComponent<PSMoveController>();
        rendererComponent = gameObject.GetComponent<MeshRenderer>();

        // Button Pressed callbacks
        moveComponent.OnButtonTrianglePressed += move_OnButtonTrianglePressed;
        moveComponent.OnButtonCirclePressed += move_OnButtonCirclePressed;
        moveComponent.OnButtonCrossPressed += move_OnButtonCrossPressed;
        moveComponent.OnButtonSquarePressed += move_OnButtonSquarePressed;
        moveComponent.OnButtonSelectPressed += move_OnButtonSelectPressed;
        moveComponent.OnButtonStartPressed += move_OnButtonStartPressed;
        moveComponent.OnButtonPSPressed += move_OnButtonPSPressed;
        moveComponent.OnButtonMovePressed += move_OnButtonMovePressed;

        // Button Release callbacks
        moveComponent.OnButtonTriangleReleased += move_OnButtonTriangleReleased;
        moveComponent.OnButtonCircleReleased += move_OnButtonCircleReleased;
        moveComponent.OnButtonCrossReleased += move_OnButtonCrossReleased;
        moveComponent.OnButtonSquareReleased += move_OnButtonSquareReleased;
        moveComponent.OnButtonSelectReleased += move_OnButtonSelectReleased;
        moveComponent.OnButtonStartReleased += move_OnButtonStartReleased;
        moveComponent.OnButtonPSReleased += move_OnButtonPSReleased;
        moveComponent.OnButtonMoveReleased += move_OnButtonMoveReleased;

        // Don't show the controller model until we get tracking
        if (HideWhenUntracked && rendererComponent != null)
        {
            rendererComponent.enabled = false;
        }
    }
Beispiel #3
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;
        }
 void Start()
 {
     m_moveComponent = gameObject.GetComponent <PSMoveController>();
     m_bWasPressed   = false;
     m_bIsPressed    = false;
 }