private bool ReadMap(string fileName)
        {
            MapViewer.GetInstance().Deinitialize();
            if (!MapViewer.GetInstance().Initialize(fileName))
            {
                return(false);
            }

            IntPtr jsonPtr = MapViewer.GetInstance().GetJson();
            string json    = Marshal.PtrToStringAnsi(jsonPtr);

            if (json.Length < 1)
            {
                Debug.Log("Map is not opened");
                return(false);
            }

            Map3D map3D = JsonReader.Deserialize <Map3D>(json);

            int width  = map3D.width;
            int height = map3D.height;

            maxKeyframeCount = map3D.imageCount;

            vertices = new Vector3[map3D.vertexCount];
            for (int i = 0; i < map3D.vertexCount; i++)
            {
                vertices[i] = new Vector3(map3D.vertices[i].x, -map3D.vertices[i].y, map3D.vertices[i].z);
            }

            cameraMatrices = new Matrix4x4[maxKeyframeCount];
            for (int i = 0; i < maxKeyframeCount; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    cameraMatrices[i][j] = map3D.poseMatrices[i][j];
                }
                cameraMatrices[i] = cameraMatrices[i].inverse;
            }

            cameraRotations = new Quaternion[maxKeyframeCount];
            for (int i = 0; i < maxKeyframeCount; i++)
            {
                cameraRotations[i] = MatrixUtils.InvQuaternionFromMatrix(cameraMatrices[i]);
                Vector3 tempR = cameraRotations[i].eulerAngles;
                tempR.x            = -tempR.x;
                tempR.y            = -tempR.y;
                cameraRotations[i] = Quaternion.Euler(tempR);
            }

            Shader color = Shader.Find("Unlit/Texture");

            materials = new Material[maxKeyframeCount];
            for (int i = 0; i < maxKeyframeCount; i++)
            {
                materials[i]             = new Material(color);
                materials[i].mainTexture = GetCameraTexture(i, width, height);
            }

            return(true);
        }
        private bool ReadMap(string fileName)
        {
            MapViewer.GetInstance().Deinitialize();
            int length = MapViewer.GetInstance().Initialize(fileName);

            if (length == -1)
            {
                return(false);
            }

            byte[] jsonBuffer = new byte[length];
            MapViewer.GetInstance().GetJson(jsonBuffer, length);

            string json = Encoding.UTF8.GetString(jsonBuffer);

            if (json.Length < 1)
            {
                Debug.Log("Map is not opened");
                return(false);
            }

            Map3D map3D = JsonReader.Deserialize <Map3D>(json);

            int width  = map3D.width;
            int height = map3D.height;

            maxKeyframeCount = map3D.imageCount;

            vertices = new Vector3[map3D.vertexCount];
            for (int i = 0; i < map3D.vertexCount; i++)
            {
                vertices[i] = new Vector3(map3D.vertices[i].x, -map3D.vertices[i].y, map3D.vertices[i].z);
            }

            cameraMatrices = new Matrix4x4[maxKeyframeCount];
            for (int i = 0; i < maxKeyframeCount; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    cameraMatrices[i][j] = map3D.poseMatrices[i][j];
                }
                cameraMatrices[i] = cameraMatrices[i].inverse;
            }

            cameraRotations = new Quaternion[maxKeyframeCount];
            for (int i = 0; i < maxKeyframeCount; i++)
            {
                cameraRotations[i] = MatrixUtils.InvQuaternionFromMatrix(cameraMatrices[i]);
                Vector3 tempR = cameraRotations[i].eulerAngles;
                tempR.x            = -tempR.x;
                tempR.y            = -tempR.y;
                cameraRotations[i] = Quaternion.Euler(tempR);
            }

            Shader color = Shader.Find("Unlit/Texture");

            materials = new Material[maxKeyframeCount];
            for (int i = 0; i < maxKeyframeCount; i++)
            {
                materials[i]             = new Material(color);
                materials[i].mainTexture = GetCameraTexture(i, width, height);
            }

            if (map3D.tagAnchors != null)
            {
                TagAnchor[] anchors = map3D.tagAnchors;
                this.tagAnchors = anchors;
            }
            else
            {
                tagAnchors = null;
                Debug.Log("No Anchors");
            }
            return(true);
        }