Пример #1
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;
    }
Пример #2
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;
    }