Beispiel #1
0
    void Start()
    {
        updateMeshFlag = true;
        verts          = new List <Vector4>();
        edges          = new List <Edge>();
        faces          = new List <Face>();
        cells          = new List <Cell>();

        //System.IO.StreamReader file = new System.IO.StreamReader(Path.Combine(Application.streamingAssetsPath, topeFile));
        TextAsset file = Resources.Load <TextAsset>("oriented600cell");

        string[] textSplit = file.text.Split('\n');
        //string line;
        string[] split;
        //while ((line = file.ReadLine()) != null)
        foreach (string line in textSplit)
        {
            split = line.Split(':');
            switch (split[0])
            {
            case "#":
                break;

            case "v":
                verts.Add(ParseCoords(split[1]));
                break;

            case "e":
                edges.Add(new Edge(ParseIndices(split[1]), ParseIndices(split[2])));
                break;

            case "f":
                faces.Add(new Face(ParseIndices(split[1]), ParseIndices(split[2])));
                break;

            case "c":
                cells.Add(new Cell(ParseIndices(split[1])));
                break;
            }
        }
        //file.Close();

        // populate centers
        foreach (Face f in faces)
        {
            f.center = Rot4.Center(Splice <Vector4>(verts, f.mverts).ToArray());
        }
        foreach (Cell c in cells)
        {
            c.center = Rot4.Center(Splice <Vector4>(verts, c.mverts).ToArray());
        }

        Generate();
    }