Ejemplo n.º 1
0
        public static Mesh ConvertCardboardMesh_LineStrip(CardboardMesh sourceMesh)
        {
            //https://github.com/googlevr/cardboard/blob/master/sdk/distortion_mesh.cc
            Mesh result = new Mesh();

            //vertices
            List <Vector3> vertList = new List <Vector3>();

            for (int i = 0; i < sourceMesh.vertices.Length; i += 2)
            {
                vertList.Add(new Vector3(sourceMesh.vertices[i], sourceMesh.vertices[i + 1], 0));
            }
            result.SetVertices(vertList);

            //indices
            result.SetIndices(sourceMesh.indices, MeshTopology.LineStrip, 0);

            //uv
            List <Vector2> uvList = new List <Vector2>();

            for (int i = 0; i < sourceMesh.uvs.Length; i += 2)
            {
                uvList.Add(new Vector2(sourceMesh.uvs[i], sourceMesh.uvs[i + 1]));
            }
            result.SetUVs(0, uvList);

            return(result);
        }
Ejemplo n.º 2
0
        public static CardboardMesh CreateMockupCardboardMesh(CardboardEye eye)
        {
            CardboardMesh result;

            if (eye == CardboardEye.kLeft)
            {
                result = new CardboardMesh()
                {
                    vertices   = new[] { -0.9f, -0.9f, -0.9f, 0.9f, -0.1f, -0.9f, -0.1f, 0.9f },
                    n_vertices = 4,
                    indices    = new[] { 0, 1, 2, 3 },
                    n_indices  = 4,
                    uvs        = new[] { 0f, 0f, 0f, 1f, 1f, 0f, 1f, 1f }
                };
            }
            else
            {
                result = new CardboardMesh()
                {
                    vertices   = new[] { 0.1f, -0.9f, 0.1f, 0.9f, 0.9f, -0.9f, 0.9f, 0.9f },
                    n_vertices = 4,
                    indices    = new[] { 0, 1, 2, 3 },
                    n_indices  = 4,
                    uvs        = new[] { 0f, 0f, 0f, 1f, 1f, 0f, 1f, 1f }
                };
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static Mesh ConvertCardboardMesh_Triangle(CardboardMesh sourceMesh)
        {
            //https://github.com/googlevr/cardboard/blob/master/sdk/distortion_mesh.cc
            Mesh result = new Mesh();

            //vertices
            List <Vector3> vertList = new List <Vector3>();

            for (int i = 0; i < sourceMesh.vertices.Length; i += 2)
            {
                vertList.Add(new Vector3(sourceMesh.vertices[i], sourceMesh.vertices[i + 1], 0));
            }
            result.SetVertices(vertList);

            //uv
            List <Vector2> uvList = new List <Vector2>();

            for (int i = 0; i < sourceMesh.uvs.Length; i += 2)
            {
                uvList.Add(new Vector2(sourceMesh.uvs[i], sourceMesh.uvs[i + 1]));
            }
            result.SetUVs(0, uvList);

            //indices
            List <int> newIndices = new List <int>();

            for (int i = 0; i < sourceMesh.indices.Length - 2; i++)
            {
                int indexA = sourceMesh.indices[i];
                int indexB = sourceMesh.indices[i + 1];
                int indexC = sourceMesh.indices[i + 2];

                if (indexA == indexB || indexB == indexC)
                {
                    continue;
                }

                if (i % 2 == 0)
                {
                    newIndices.Add(indexA);
                    newIndices.Add(indexB);
                    newIndices.Add(indexC);
                }
                else
                {
                    newIndices.Add(indexA);
                    newIndices.Add(indexC);
                    newIndices.Add(indexB);
                }
            }

            // result.triangles = newIndices.ToArray();
            result.SetIndices(newIndices.ToArray(), MeshTopology.Triangles, 0);

            return(result);
        }
 private static void CardboardLensDistortion_getDistortionMesh(
     IntPtr lens_Distortion, CardboardEye eye, ref CardboardMesh mesh)
 {
     mesh = CardboardUtility.CreateMockupCardboardMesh(eye);
 }
 private static extern void CardboardLensDistortion_getDistortionMesh(
     IntPtr lens_Distortion, CardboardEye eye, ref CardboardMesh mesh);
 public static void SetEyeMeshes(CardboardMesh leftMeshPtr, CardboardMesh rightMeshPtr)
 {
     CardboardDistortionRenderer_setMesh(_cardboardDistortionRenderer, ref leftMeshPtr, CardboardEye.kLeft);
     CardboardDistortionRenderer_setMesh(_cardboardDistortionRenderer, ref rightMeshPtr, CardboardEye.kRight);
 }
 private static void CardboardDistortionRenderer_setMesh(
     IntPtr renderer, ref CardboardMesh mesh, CardboardEye eye)
 {
 }