Beispiel #1
0
    public static string DoExport(Transform Selection)
    {
        string meshName = Selection.gameObject.name;
        string fileName = meshName + ".obj";

        LocalObjExporterScript.Start();

        StringBuilder meshString = new StringBuilder();

        meshString.Append("#" + meshName + ".obj"
                          + "\n#" + System.DateTime.Now.ToLongDateString()
                          + "\n#" + System.DateTime.Now.ToLongTimeString()
                          + "\n#-------"
                          + "\n\n");

        Transform t = Selection.gameObject.transform;

        Vector3 originalPosition = t.position;

        t.position = Vector3.zero;

        Quaternion originalRotation = t.rotation;

        t.rotation = Quaternion.identity;

        meshString.Append(processTransform(t));

        t.position = originalPosition;
        t.rotation = originalRotation;

        LocalObjExporterScript.End();
        Debug.Log("Exported Mesh: " + fileName);

        return(meshString.ToString());
    }
Beispiel #2
0
    private static string processTransform(Transform t)
    {
        StringBuilder meshString = new StringBuilder();

        meshString.Append("#" + t.name
                          + "\n#-------"
                          + "\n");


        meshString.Append("g ").Append(t.name).Append("\n");


        MeshFilter mf = t.GetComponent <MeshFilter>();

        if (mf)
        {
            meshString.Append(LocalObjExporterScript.MeshToString(mf, t));
        }

        for (int i = 0; i < t.childCount; i++)
        {
            meshString.Append(processTransform(t.GetChild(i)));
        }

        return(meshString.ToString());
    }