Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (updateScreenOrientation())
        {
            // also update size/orientation of metaio SDK and camera projection
            // matrix
            MetaioSDKUnity.resizeRenderer(Screen.width, Screen.height);
            MetaioSDKUnity.updateScreenOrientation(screenOrientation);
            metaioCamera.updateCameraProjectionMatrix();
        }

        // Try to create the texture (must call every frame in case required size changes)
        textureCreated = createTexture(0);

        if (textureCreated)
        {
            updateCameraPlaneScale();
        }

        // TODO: GL.IssuePluginEvent should be used on all platforms,
        // but in Unity 3.5.x, the callbacks in the native plugin are
        // never called. Check if they work in Unity 4.x.
#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR
        GL.IssuePluginEvent(textureID);
#elif UNITY_ANDROID || UNITY_IPHONE
        MetaioSDKUnity.UnityRenderEvent(textureID);
#endif
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (updateScreenOrientation())
        {
            // also update size/orientation of metaio SDK and camera projection
            // matrix
            MetaioSDKUnity.resizeRenderer(Screen.width, Screen.height);
            MetaioSDKUnity.updateScreenOrientation(screenOrientation);
            metaioCamera.updateCameraProjectionMatrix();
        }

        // Try to create the texture (must call every frame in case required size changes)
        textureCreated = createTexture(0);

        if (textureCreated)
        {
            updateCameraPlaneScale();
        }
    }
Esempio n. 3
0
    void Start()
    {
        int result = MetaioSDKUnity.createMetaioSDKUnity(parseApplicationSignature());

        if (result == 0)
        {
            Debug.Log("metaio SDK created successfully");
        }
        else
        {
            Debug.LogError("Failed to create metaio SDK!");
        }

        bool mustRestoreAutoRotation = false;

        if (Screen.orientation == ScreenOrientation.Unknown)
        {
            // In this case we know that auto-rotation was active, because else Unity would immediately set a certain
            // default orientation (as defined in player settings).
            mustRestoreAutoRotation = true;

            Debug.Log("Fixing unknown orientation problem");

            switch (Input.deviceOrientation)
            {
            case DeviceOrientation.PortraitUpsideDown:
                Screen.orientation = ScreenOrientation.PortraitUpsideDown;
                break;

            case DeviceOrientation.LandscapeLeft:
                Screen.orientation = ScreenOrientation.LandscapeLeft;
                break;

            case DeviceOrientation.LandscapeRight:
                Screen.orientation = ScreenOrientation.LandscapeRight;
                break;

            case DeviceOrientation.FaceDown:
            case DeviceOrientation.FaceUp:
            case DeviceOrientation.Portrait:
            case DeviceOrientation.Unknown:
            default:
                Screen.orientation = ScreenOrientation.Portrait;
                break;
            }
        }

        MetaioSDKUnity.updateScreenOrientation(Screen.orientation);

        if (mustRestoreAutoRotation)
        {
            Screen.orientation = ScreenOrientation.AutoRotation;
        }

        MetaioCamera camera = new MetaioCamera();

        camera.index        = cameraIndex;
        camera.resolution.x = cameraWidth;
        camera.resolution.y = cameraHeight;
        camera.downsample   = (uint)cameraDownsample;
        camera.flip         = (uint)cameraFlip;
        MetaioSDKUnity.startCamera(camera);

        // Load tracking configuration
        if (String.IsNullOrEmpty(trackingConfiguration))
        {
            Debug.Log("No tracking configuration specified");

            result = MetaioSDKUnity.setTrackingConfiguration("", 0);
        }
        else
        {
            result = MetaioSDKUnity.setTrackingConfigurationFromAssets(trackingConfiguration);

            if (result == 0)
            {
                Debug.LogError("Start: failed to load tracking configuration: " + trackingConfiguration);
            }
            else
            {
                Debug.Log("Loaded tracking configuration: " + trackingConfiguration);
            }
        }

        // Set LLA objects' rendering limits
        MetaioSDKUnity.setLLAObjectRenderingLimits(10, 1000);

        // Set renderer clipping plane limits
        MetaioSDKUnity.setRendererClippingPlaneLimits(nearClippingPlaneLimit, farClippingPlaneLimit);

        // Apply initial settings for mono/stereo and (non-)see-through mode
        stereoRenderingEnabled = _stereoRenderingEnabled;
        seeThroughEnabled      = _seeThroughEnabled;
    }
Esempio n. 4
0
    void Start()
    {
        int result = MetaioSDKUnity.createMetaioSDKUnity(parseApplicationSignature());

        if (result == 0)
        {
            Debug.Log("metaio SDK created successfully");
        }
        else
        {
            Debug.LogError("Failed to create metaio SDK!");
        }

        bool mustRestoreAutoRotation = false;

        if (Screen.orientation == ScreenOrientation.Unknown)
        {
            // In this case we know that auto-rotation was active, because else Unity would immediately set a certain
            // default orientation (as defined in player settings).
            mustRestoreAutoRotation = true;

            Debug.Log("Fixing unknown orientation problem");

            switch (Input.deviceOrientation)
            {
            case DeviceOrientation.PortraitUpsideDown:
                Screen.orientation = ScreenOrientation.PortraitUpsideDown;
                break;

            case DeviceOrientation.LandscapeLeft:
                Screen.orientation = ScreenOrientation.LandscapeLeft;
                break;

            case DeviceOrientation.LandscapeRight:
                Screen.orientation = ScreenOrientation.LandscapeRight;
                break;

            case DeviceOrientation.FaceDown:
            case DeviceOrientation.FaceUp:
            case DeviceOrientation.Portrait:
            case DeviceOrientation.Unknown:
            default:
                Screen.orientation = ScreenOrientation.Portrait;
                break;
            }
        }

        MetaioSDKUnity.updateScreenOrientation(Screen.orientation);

        if (mustRestoreAutoRotation)
        {
            Screen.orientation = ScreenOrientation.AutoRotation;
        }

        System.Collections.Generic.List <MetaioCamera> cameras = MetaioSDKUnity.getCameraList();

        /*Debug.Log("Listing the cameras");
         *
         * for (int i = 0; i < cameras.Count; i++)
         * {
         *  Debug.Log("Camera " + (i+1) + " : " + cameras[i].friendlyName);
         * }*/

        //Debug.Log("Starting the default camera with facing: " + cameraFacing);

        //cameras [1].flip = MetaioCamera.FLIP_HORIZONTAL;
        //Debug.Log("###WOPA####" + (int) cameras[1].flip);

        MetaioSDKUnity.startCamera(cameras[0]);

        // Load tracking configuration
        if (String.IsNullOrEmpty(trackingConfiguration))
        {
            Debug.Log("No tracking configuration specified");

            result = MetaioSDKUnity.setTrackingConfiguration("", 0);
        }
        else
        {
            result = MetaioSDKUnity.setTrackingConfigurationFromAssets(trackingConfiguration);

            if (result == 0)
            {
                Debug.LogError("Start: failed to load tracking configuration: " + trackingConfiguration);
            }
            else
            {
                Debug.Log("Loaded tracking configuration: " + trackingConfiguration);
            }
        }

        // Set LLA objects' rendering limits
        MetaioSDKUnity.setLLAObjectRenderingLimits(10, 1000);

        // Set renderer clipping plane limits
        MetaioSDKUnity.setRendererClippingPlaneLimits(nearClippingPlaneLimit, farClippingPlaneLimit);

        // Apply initial settings for mono/stereo and (non-)see-through mode
        stereoRenderingEnabled = _stereoRenderingEnabled;
        seeThroughEnabled      = _seeThroughEnabled;
    }