Esempio n. 1
0
    static void Init()
    {
        window = GetWindow(typeof(ModelExporter)) as ModelExporter;
        //ModelExporter window = GetWindowWithRect(typeof(ModelExporter), new Rect(0, 0, 800, 600), true, "WindowExportModels") as ModelExporter;
        window.Show();

        //cameraPrefab = Camera.main;

        //if(cameraPrefab != null)
        //{
        //    cameraC = Instantiate<Camera>(cameraPrefab);
        //    RT = new RenderTexture(640, 360, 24);
        //    cameraC.targetTexture = RT;
        //}

        GameObject GO   = GameObject.Find("heliu_DiMian");
        Mesh       mesh = GO.GetComponent <MeshFilter>().sharedMesh;

        int[]     triangles = mesh.triangles;
        Vector3[] vertices  = mesh.vertices;
        Vector3[] normals   = mesh.normals;

        Debug.Log(triangles[0] + " " + triangles[1] + " " + triangles[2] + " " + triangles[3] + " " + triangles[4] + " " + triangles[5]);

        for (int i = 0; i < vertices.Length; ++i)
        {
            vertices[i].x = vertices[i].x * GO.transform.lossyScale.x;
            vertices[i].y = vertices[i].y * GO.transform.lossyScale.y;
            vertices[i].z = vertices[i].z * GO.transform.lossyScale.z;
        }

        Debug.Log(vertices[0] + " " + vertices[1] + " " + vertices[2] + " " + vertices[3]);

        for (int i = 0; i < normals.Length; ++i)
        {
        }

        Debug.Log(normals[0] + " " + normals[1] + " " + normals[2] + " " + normals[3]);
    }