Exemple #1
0
        public static Mesh BuildOneMesh(IShape shape, int maxVertices = 65535, bool shouldOptimize = true, bool shouldUpload = true, bool infiniteBounds = false)
        {
            ShapeCombiner combiner = new ShapeCombiner(maxVertices, shouldOptimize, shouldUpload, infiniteBounds);

            combiner.AddShape(shape);
            return(combiner.FinalizeCurrentMesh());
        }
Exemple #2
0
        public void GenerateMesh()
        {
            var filter = GetComponent <MeshFilter>();

            if (filter != null)
            {
#if UNITY_EDITOR
                Mesh mesh = ShapeCombiner.BuildOneMesh(this, shouldOptimize: false, shouldUpload: false);

                var p = new UnityEditor.UnwrapParam();
                p.angleError = 0.05f;
                p.areaError  = 0.05f;
                p.hardAngle  = 90;
                p.packMargin = 0.0f;
                UnityEditor.Unwrapping.GenerateSecondaryUVSet(mesh);

                //mesh.uv = mesh.uv2;

                filter.sharedMesh = mesh;
#endif
            }
        }
Exemple #3
0
 public static void CreateObjectsRealtime(ShapeCombiner combiner, Material mat, Transform root = null)
 {
     combiner.OnNewMesh += mesh => {
         CreateObject(mesh, mat, root);
     };
 }