Ejemplo n.º 1
0
    IEnumerator Start()
    {
        targetTransform   = new GameObject().transform;
        aerowandTransform = new GameObject().transform;
        device            = GetComponent <AerowandDeviceWrapper>() as AerowandDeviceWrapper;
        if (device.getConnectionType == AerowandDeviceWrapper.ConnectionType.AEROWAND_USBHOST)
        {
            // Wait until Aerowand has returned non-zero transform data to set reference centers
            while (device.position == Vector3.zero)
            {
                yield return(null);
            }
            hmdSet = true;
            sceneReferencePosition       = defaultPosition;
            sceneReferenceOrientation    = defaultOrientation;
            aerowandReferencePosition    = device.position;
            aerowandReferenceOrientation = device.orientation;

            // reset the scene which has been messed up by having changed the gameobject's position and orientation changed by the VR headset
            UpdateTransform();
            transform.position = defaultPosition;
            transform.rotation = defaultOrientation;
        }
        else
        {
            // Wait until Aerowand has returned non-zero transform data indicating it is receiving data
            while (device.position == Vector3.zero)
            {
                yield return(null);
            }
            // If no Aerowand HMD or other BT device has yet claimed to be the reference frame for the scene, use this device
            // This will be overruled by the HMD once it claims the scene.
            if (sceneReferencePosition == Vector3.zero)
            {
                sceneReferencePosition       = defaultPosition;
                sceneReferenceOrientation    = defaultOrientation;
                aerowandReferencePosition    = device.position;
                aerowandReferenceOrientation = device.orientation;
            }
        }
        Camera.onPreCull += LastPossibleUpdateTransform;

        while (true)
        {
            UpdateTransform();
            yield return(new WaitForFixedUpdate());
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     textObject   = GetComponent <Text> () as Text;
     aerowandHead = GameObject.FindGameObjectWithTag("Aerowand Head").GetComponent <AerowandDeviceWrapper> () as AerowandDeviceWrapper;
     aerowandHand = GameObject.FindGameObjectWithTag("Aerowand Hand").GetComponent <AerowandDeviceWrapper> () as AerowandDeviceWrapper;
 }