Example #1
0
    void readFile(string fileName)
    {
        print(" <<< Load Face File >>> ");
        //List config files
        string[] lines = System.IO.File.ReadAllLines(@"Assets\" + fileName);// dirty because Assets is inside Assets....<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        // Display the file contents by using a foreach loop.
        foreach (string line in lines)
        {
            string[] values = line.Split('_');

            int   index = int.Parse(values[0]);
            float x     = float.Parse(values[1]);
            float y     = float.Parse(values[2]);
            float z     = float.Parse(values[3]);

            vertices[index] = new Vector3(x, y, z);
        }

        smr.sharedMesh.SetVertices(vertices);
        smr.sharedMesh.RecalculateBounds();
        smr.sharedMesh.RecalculateNormals();

        // WHEN WE READ A FACE FILE , WE SYNC THE MESH VERTICES TO THE FACE MODELLER

        SkinnedFaceModeller faceModeller = GetComponent <SkinnedFaceModeller>();

        faceModeller.syncVertices(vertices);
    }
Example #2
0
    //READ MESH file
    void readFile(string fileName)
    {
        //print("read mesh file");
        //List config files
        string[] lines = System.IO.File.ReadAllLines(@"Assets\" + fileName);// dirty because Assets is inside Assets....<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        print(lines.Length);

        print(fileName);


        //int nbLine = 0;
        //int nbResult = 0;

        //Mesh loadedMesh = new Mesh();
        List <Vector3> vertices = new List <Vector3>();

        //List<int> mtriangles = new List<int>();



        // Display the file contents by using a foreach loop.
        foreach (string line in lines)
        {
            string[] values = line.Split('_');
            //string input = values[1];// Index Value


            string elementType = values[0];


            if (elementType[0] == 'v')
            {
                float x = float.Parse(values[1]);
                float y = float.Parse(values[2]);
                float z = float.Parse(values[3]);

                vertices.Add(new Vector3(x, y, z));
            }
        }


        print("vertices Count " + vertices.Count);

        Mesh mh = smr.sharedMesh;

        mh.SetVertices(vertices);
        mh.RecalculateBounds();
        mh.RecalculateNormals();
        smr.sharedMesh = mh;

        Slider ys = yMouth.GetComponent <Slider>();
        Slider zs = zMouth.GetComponent <Slider>();

        ys.value = defaultYMouthValue;
        zs.value = defaultZMouthValue;

        // print("reload default mesh");

        // WHEN WE READ A MESH FILE , WE SYNC THE MESH VERTICES TO THE FACE MODELLER

        SkinnedFaceModeller faceModeller = GetComponent <SkinnedFaceModeller>();

        //skinnedAnimator.StartAnimation();
        //skinnedAnimator.setVerticesAfterLoadingFile();
        faceModeller.syncVertices(vertices);
    }