Example #1
0
    void FixedUpdate()
    {
        // Runtime check in case of reset (i.e. update in editor)
        if (!CAVE2.IsWandRegistered(wandID, gameObject))
        {
            Debug.LogWarning("CAVE2WandMocapUpdater: Re-registering ID " + wandID);
            CAVE2.RegisterWandObject(wandID, gameObject);
        }

        if (virtualWand && virtualWand.GetComponent <Rigidbody>())
        {
            transform.localPosition = CAVE2Manager.GetWandPosition(wandID);
            transform.localRotation = CAVE2Manager.GetWandRotation(wandID);
            float timeSinceLastUpdate = CAVE2Manager.GetWandTimeSinceUpdate(wandID);

            // If position and rotation are zero, wand is not tracking, disable drawing and physics
            if (timeSinceLastUpdate > 0.5f && virtualWand.gameObject.activeSelf)
            {
                virtualWand.gameObject.SetActive(false);
            }
            else if (timeSinceLastUpdate < 0.5f && !virtualWand.gameObject.activeSelf)
            {
                virtualWand.gameObject.SetActive(true);
            }
        }
    }
 void FixedUpdate()
 {
     if (virtualWand && virtualWand.GetComponent <Rigidbody>())
     {
         transform.localPosition = CAVE2Manager.GetWandPosition(wandID);
         transform.localRotation = CAVE2Manager.GetWandRotation(wandID);
     }
 }
    void FixedUpdate()
    {
        if (virtualWand && virtualWand.GetComponent <Rigidbody>())
        {
            transform.localPosition = CAVE2Manager.GetWandPosition(wandID);
            transform.localRotation = CAVE2Manager.GetWandRotation(wandID);

            // If position and rotation are zero, wand is not tracking, disable drawing and physics
            if (transform.localPosition == Vector3.zero && transform.localRotation == Quaternion.identity && virtualWand.gameObject.activeSelf)
            {
                virtualWand.gameObject.SetActive(false);
            }
            else if (transform.localPosition != Vector3.zero && transform.localRotation != Quaternion.identity && !virtualWand.gameObject.activeSelf)
            {
                virtualWand.gameObject.SetActive(true);
            }
        }
    }
Example #4
0
 public static Quaternion GetWandRotation(int ID)
 {
     return(CAVE2Manager.GetWandRotation(ID));
 }
    // 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);
        }
    }
Example #6
0
// Update is called once per frame
    void Update()
    {
        if (!cave2Manager.wandMousePointerEmulation)
        {
            if (GetComponent <Rigidbody>())
            {
                GetComponent <Rigidbody>().MovePosition(CAVE2Manager.GetWandPosition(wandID));
                GetComponent <Rigidbody>().MoveRotation(CAVE2Manager.GetWandRotation(wandID));
            }
            else
            {
                transform.localPosition = CAVE2Manager.GetWandPosition(wandID);
                transform.localRotation = CAVE2Manager.GetWandRotation(wandID);
            }
        }
        else if (cave2Manager.wandEmulationMode == CAVE2Manager.TrackerEmulationMode.Pointer) // Mouse pointer mode
        {
            if (GetComponent <Rigidbody>())
            {
                GetComponent <Rigidbody>().MovePosition(CAVE2Manager.GetWandPosition(wandID));
            }
            else
            {
                transform.localPosition = CAVE2Manager.GetWandPosition(wandID);
            }

            // Mouse pointer ray controls rotation
            Vector2 position = new Vector3(Input.mousePosition.x, Input.mousePosition.y);

            // Ray extending from main camera into screen from touch point
            Ray        ray = Camera.main.ScreenPointToRay(position);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 100))
            {
                //transform.LookAt( hit.point );
            }
            else
            {
                //transform.LookAt( ray.GetPoint(1000) );
            }
            transform.LookAt(ray.GetPoint(1000));
            // Update the wandState rotation (opposite of normal since this object is determining the rotation)
            cave2Manager.wandEmulatedRotation = transform.eulerAngles;
        }
        else if (cave2Manager.wandEmulationMode == CAVE2Manager.TrackerEmulationMode.TranslateVertical) // Mouse pointer mode
        {
            // Translate wand based on mouse position
            Vector3 mouseDeltaPos = cave2Manager.mouseDeltaPos * Time.deltaTime * 0.05f;
            transform.localPosition          += mouseDeltaPos;
            cave2Manager.wandEmulatedPosition = transform.localPosition;
        }
        else if (cave2Manager.wandEmulationMode == CAVE2Manager.TrackerEmulationMode.TranslateForward) // Wand mouse mode
        {
            // Translate wand based on mouse position
            Vector3 mouseDeltaPos = cave2Manager.mouseDeltaPos * Time.deltaTime * 0.05f;
            float   mouseScroll   = Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * 2.0f;
            transform.localPosition          += new Vector3(mouseDeltaPos.x, mouseScroll, mouseDeltaPos.y);
            cave2Manager.wandEmulatedPosition = transform.localPosition;
        }
        else if (cave2Manager.wandEmulationMode == CAVE2Manager.TrackerEmulationMode.RotatePitchYaw) // Wand mouse mode
        {
            // Translate wand based on mouse position
            Vector3 mouseDeltaPos = cave2Manager.mouseDeltaPos;
            transform.Rotate(new Vector3(-mouseDeltaPos.y, mouseDeltaPos.x, 0));
            cave2Manager.wandEmulatedRotation = transform.eulerAngles;
        }
        else if (cave2Manager.wandEmulationMode == CAVE2Manager.TrackerEmulationMode.RotateRoll) // Wand mouse mode
        {
            // Translate wand based on mouse position
            Vector3 mouseDeltaPos = cave2Manager.mouseDeltaPos;
            transform.Rotate(new Vector3(0, 0, -mouseDeltaPos.x));
            cave2Manager.wandEmulatedRotation = transform.eulerAngles;
        }
    }