Beispiel #1
0
    private void OnGetInitPoseCallback(string errorJson, string resultJson)
    {
        if (errorJson != null)
        {
            Debug.LogWarning("[vlUnitySDK] OnGetInitPoseCallback: Failed to get init pose");
            return;
        }

        VLModelTrackerCommands.GetInitPoseResult result =
            VLJsonUtility.FromJson <VLModelTrackerCommands.GetInitPoseResult>(
                resultJson);

        Vector3    position;
        Quaternion orientation;

        VLUnityCameraHelper.VLPoseToCamera(
            new Vector3(result.t[0], result.t[1], result.t[2]),
            new Quaternion(result.q[0], result.q[1], result.q[2], result.q[3]),
            out position, out orientation,
            this.workerBehaviour.flipCoordinateSystemHandedness);

        if (this.initCamera != null)
        {
            this.initCamera.transform.position = position;
            this.initCamera.transform.rotation = orientation;
            this.originalPosition    = position;
            this.originalOrientation = orientation;
            this.ready = true;
        }
        else
        {
            Debug.LogWarning("[vlUnitySDK] OnGetInitPoseCallback: initCamera is null");
        }
    }
    private void OnGetInitPoseCallback(string errorJson, string resultJson)
    {
        if (errorJson != null)
        {
            Debug.LogWarning("[vlUnitySDK] OnGetInitPoseCallback: Failed to get init pose");
            return;
        }

        VLModelTrackerCommands.GetInitPoseResult result =
            VLJsonUtility.FromJson <VLModelTrackerCommands.GetInitPoseResult>(
                resultJson);

        Vector3    position;
        Quaternion orientation;

        VLUnityCameraHelper.VLPoseToCamera(
            new Vector3(result.t[0], result.t[1], result.t[2]),
            new Quaternion(result.q[0], result.q[1], result.q[2], result.q[3]),
            out position, out orientation);

        this.originalPosition    = position;
        this.originalOrientation = orientation;
        this.initPoseReady       = true;
        this.reset = true; // This will set the new pose during the next Update
                           // call
    }