Exemple #1
0
    public static void saveSingleGrainsMesh(Rock rock, string saveFolder)
    {
        int grainCount = 0;
        int nBeds      = rock.rockObject.transform.childCount;

        GameObject[] singleGrain = new GameObject[1];

        for (int bedNumber = 0; bedNumber < nBeds; bedNumber++)
        {
            GameObject currentBed   = rock.rockObject.GetComponent <Transform>().GetChild(bedNumber).gameObject;
            int        nGrainGroups = rock.beds[bedNumber].nGrainGroups;

            for (int grainGroupNumber = 0; grainGroupNumber < nGrainGroups; grainGroupNumber++)
            {
                GameObject grainGroup = currentBed.GetComponent <Transform>().GetChild(grainGroupNumber).gameObject;
                int        nGrains    = grainGroup.transform.childCount;
                if (nGrains > 0)
                {
                    for (int grainNumber = 0; grainNumber < nGrains; grainNumber++)
                    {
                        grainCount    += 1;
                        singleGrain[0] = grainGroup.transform.GetChild(grainNumber).gameObject;
                        bool[] isLocationRotationScale = new bool[3];
                        isLocationRotationScale[0] = false;
                        isLocationRotationScale[1] = true;
                        isLocationRotationScale[2] = true;
                        string grainName = grainGroup.transform.GetChild(grainNumber).gameObject.GetComponent <GrainOperations>().name;
                        string filePath  = saveFolder + "/Grain " + grainCount + " - " + grainName + ".stl";
                        StlExporter.MeshToFile(singleGrain, new Vector3(), filePath, isLocationRotationScale);
                    }
                }
            }
        }
    }
Exemple #2
0
 public static void saveMeshData(Rock rock, string saveFolder)
 {
     GameObject[] grains = rock.GetGrainObjects();
     if (grains.Length > 0)
     {
         string filePath = saveFolder + "/MeshData" + ".stl";
         StlExporter.MeshToFile(grains, filePath);
         Debug.Log("Saved");
     }
 }