// Update is called once per frame
    void Update()
    {
        wandPosition = CAVE2Manager.GetWandPosition(wandID);
        wandRotation = CAVE2Manager.GetWandRotation(wandID);

        headPosition = CAVE2Manager.GetHeadPosition(headID);
        headRotation = CAVE2Manager.GetHeadRotation(headID).eulerAngles;

        if (headPosition.y == 0)
        {
            Debug.LogWarning("OmicronPlayerController: Head is at height (Y) 0.0 - This should never happen! Check your tracking system or enable mocap emulation in CAVE2Manager.");
        }

        if (!freezeMovement)
        {
            forward  = CAVE2Manager.GetAxis(wandID, forwardAxis);
            forward *= movementScale;

            strafe  = CAVE2Manager.GetAxis(wandID, strafeAxis);
            strafe *= movementScale;

            lookAround.x  = CAVE2Manager.GetAxis(wandID, lookUDAxis);
            lookAround.x *= movementScale;
            lookAround.y  = CAVE2Manager.GetAxis(wandID, lookLRAxis);
            lookAround.y *= movementScale;

            vertical  = CAVE2Manager.GetAxis(wandID, verticalAxis);
            vertical *= movementScale;
        }

        freeflyButtonDown = CAVE2Manager.GetButton(wandID, freeFlyButton);

        if (CAVE2Manager.GetButtonDown(wandID, freeFlyToggleButton))
        {
            navMode++;
            if ((int)navMode > 2)
            {
                navMode = 0;
            }

            SetNavigationMode((int)navMode);
        }

        if (CAVE2Manager.GetButtonDown(wandID, autoLevelButton))
        {
            transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0);
        }

        if (CAVEFloor && !CAVEFloor.activeSelf)
        {
            CAVEFloor.SetActive(true);
        }

        if (CAVEFloor && showCAVEFloorOnlyOnMaster && CAVEFloor.activeSelf && !CAVE2Manager.IsMaster())
        {
            CAVEFloor.SetActive(false);
        }
        else if (CAVEFloor && !showCAVEFloorOnlyOnMaster && !CAVEFloor.activeSelf)
        {
            CAVEFloor.SetActive(true);
        }
    }
Esempio n. 2
0
 public static float GetAxis(int wandID, CAVE2.Axis axis)
 {
     return(CAVE2Manager.GetAxis(wandID, axis));
 }
    // Update is called once per frame
    void Update()
    {
        leftAnalogStick  = new Vector2(CAVE2Manager.GetAxis(wandID, CAVE2Manager.Axis.LeftAnalogStickLR), CAVE2Manager.GetAxis(wandID, CAVE2Manager.Axis.LeftAnalogStickUD));
        rightAnalogStick = new Vector2(CAVE2Manager.GetAxis(wandID, CAVE2Manager.Axis.RightAnalogStickLR), CAVE2Manager.GetAxis(wandID, CAVE2Manager.Axis.RightAnalogStickUD));
        analogTriggers   = new Vector2(CAVE2Manager.GetAxis(wandID, CAVE2Manager.Axis.AnalogTriggerL), CAVE2Manager.GetAxis(wandID, CAVE2Manager.Axis.AnalogTriggerR));

        if (buttonL3)
        {
            buttonL3.transform.localEulerAngles = new Vector3(leftAnalogStick.y, 0, -leftAnalogStick.x) * 30;
        }
        if (buttonR3)
        {
            buttonR3.transform.localEulerAngles = new Vector3(rightAnalogStick.y, 0, -rightAnalogStick.x) * 30;
        }

        if (buttonL2)
        {
            buttonL2.transform.localEulerAngles = new Vector3(0, 90, analogTriggers.x * 20);
        }
        if (buttonR2)
        {
            buttonR2.transform.localEulerAngles = new Vector3(0, 90, analogTriggers.y * 20);
        }

        // Tests if hold state is working properly (public state varibles should change)
        cross    = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button3);
        circle   = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button2);
        triangle = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button1);
        square   = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button4);

        up    = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.ButtonUp);
        down  = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.ButtonDown);
        left  = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.ButtonLeft);
        right = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.ButtonRight);

        L1 = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button5);
        L2 = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button7);
        L3 = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button6);

        R1 = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button8);
        //R2 = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button9);
        R3 = CAVE2Manager.GetButtonState(wandID, CAVE2Manager.Button.Button9);

        // Tests if up/down is working (visual buttons should change)
        CheckButtonState((int)CAVE2Manager.Button.Button3, cross);
        CheckButtonState((int)CAVE2Manager.Button.Button2, circle);
        CheckButtonState((int)CAVE2Manager.Button.Button1, triangle);
        CheckButtonState((int)CAVE2Manager.Button.Button4, square);

        CheckButtonState((int)CAVE2Manager.Button.ButtonUp, up);
        CheckButtonState((int)CAVE2Manager.Button.ButtonDown, down);
        CheckButtonState((int)CAVE2Manager.Button.ButtonLeft, left);
        CheckButtonState((int)CAVE2Manager.Button.ButtonRight, right);

        CheckButtonState((int)CAVE2Manager.Button.Button5, L1);
        CheckButtonState((int)CAVE2Manager.Button.Button7, L2);
        CheckButtonState((int)CAVE2Manager.Button.Button6, L3);

        CheckButtonState((int)CAVE2Manager.Button.Button8, R1);
        //CheckButtonState((int)CAVE2Manager.Button.Button9, R2);
        CheckButtonState((int)CAVE2Manager.Button.Button9, R3);
    }