Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        GetComponent <Renderer>().material.color = Color.cyan;
        objMesh = GetComponent <MeshFilter>();

        int[] tri = new int[36];
        //맨 처음 Mesh의 각 triangular face를 구성하는 3개의 vertex(일련번호)를 지정해줍니다.
        tri[0] = 0;
        tri[1] = 1;
        tri[2] = 2;

        tri[3] = 0;
        tri[4] = 2;
        tri[5] = 3;


        tri[6] = 0;
        tri[7] = 3;
        tri[8] = 4;

        tri[9]  = 4;
        tri[10] = 3;
        tri[11] = 7;


        tri[12] = 5;
        tri[13] = 1;
        tri[14] = 0;

        tri[15] = 5;
        tri[16] = 0;
        tri[17] = 4;


        tri[18] = 6;
        tri[19] = 2;
        tri[20] = 1;

        tri[21] = 6;
        tri[22] = 1;
        tri[23] = 5;


        tri[24] = 7;
        tri[25] = 3;
        tri[26] = 2;

        tri[27] = 7;
        tri[28] = 2;
        tri[29] = 6;


        tri[30] = 4;
        tri[31] = 5;
        tri[32] = 6;

        tri[33] = 4;
        tri[34] = 7;
        tri[35] = 6;

        //지정한 face-vector 연동값을 mesh에 등록합니다.
        objMesh.mesh.triangles = tri;

        ObjLoader l = new ObjLoader("Hypercube", "Hypercube");

        l.LoadData();
        Debug.Log(l.vertices);
        Debug.Log(l.normals);
        Debug.Log(l.tris);
    }