Esempio n. 1
0
    void Awake()
    {
        instance = this;
        zedReady = false;
        //If you want the ZEDRig not to be destroyed
        DontDestroyOnLoad(transform.root);

        //Init the first parameters
        initParameters                    = new sl.InitParameters();
        initParameters.resolution         = resolution;
        initParameters.depthMode          = depthMode;
        initParameters.depthStabilization = depthStabilizer;

        //Check if the AR is needed and if possible to add
        CheckStereoMode();

        //Init the other options
        isZEDTracked    = enableTracking;
        initialPosition = zedRigRoot.transform.localPosition;
        zedPosition     = initialPosition;
        zedOrientation  = initialRotation;


        //Create a camera and return an error message if the dependencies are not detected
        zedCamera      = sl.ZEDCamera.GetInstance();
        LastInitStatus = sl.ERROR_CODE.ERROR_CODE_LAST;

        zedSVOManager = GetComponent <ZEDSVOManager>();
        zedCamera.CreateCamera(wrapperVerbose);

        if (zedSVOManager != null)
        {
            //Create a camera
            if ((zedSVOManager.read || zedSVOManager.record) && zedSVOManager.videoFile.Length == 0)
            {
                zedSVOManager.record = false;
                zedSVOManager.read   = false;
            }
            if (zedSVOManager.read)
            {
                zedSVOManager.record              = false;
                initParameters.pathSVO            = zedSVOManager.videoFile;
                initParameters.svoRealTimeMode    = zedSVOManager.realtimePlayback;
                initParameters.depthStabilization = depthStabilizer;
            }
        }

        versionZED = "[SDK]: " + sl.ZEDCamera.GetSDKVersion().ToString() + " [Plugin]: " + sl.ZEDCamera.PluginVersion.ToString();


        //Set the ZED Tracking frame as Left eye
        if (isStereoRig)
        {
            //Creates a CameraRig (the 2 last cameras)
            GameObject o = CreateZEDRigDisplayer();
            o.hideFlags        = HideFlags.HideAndDontSave;
            o.transform.parent = transform;

            //Force some initParameters that are required for MR experience
            initParameters.enableRightSideMeasure = isStereoRig;
            initParameters.depthMinimumDistance   = 0.1f;
            initParameters.depthMode          = sl.DEPTH_MODE.PERFORMANCE;
            initParameters.depthStabilization = depthStabilizer;

            //Create the mirror, the texture from the firsts cameras is rendered to avoid a black border
            CreateMirror();
        }

        //Start the co routine to initialize the ZED and avoid to block the user
        LastInitStatus  = sl.ERROR_CODE.ERROR_CODE_LAST;
        openingLaunched = false;
        StartCoroutine("InitZED");

        OnCamBrightnessChange += CameraBrightnessChangeHandler;
    }