Ejemplo n.º 1
0
        public void Intersect()
        {
            var stopWatch = new Stopwatch();
            stopWatch.Start();

            var csgA = new CSG.CSG();
            csgA.Construct(A.GetComponent<MeshFilter>().sharedMesh, A.transform, 0);

            var csgB = new CSG.CSG();
            csgB.Construct(B.GetComponent<MeshFilter>().sharedMesh, B.transform, 1);

            var substract = csgA.Intersect(csgB);
            var newMesh = substract.ToMesh();

            Result = new GameObject("Intersect");
            var defObj = Result.AddComponent<DefaultObject>();
            var meshFilter = Result.AddComponent<MeshFilter>();
            meshFilter.sharedMesh = newMesh;
            var renderer = Result.AddComponent<MeshRenderer>();
            renderer.sharedMaterials = new Material[] { A.GetComponent<MeshRenderer>().sharedMaterial, B.GetComponent<MeshRenderer>().sharedMaterial };

            if (DeleteOriginal)
            {
                Object.DestroyImmediate(A);
                Object.DestroyImmediate(B);
            }

            stopWatch.Stop();
            defObj.GenerationTimeMS = stopWatch.ElapsedMilliseconds;
        }
Ejemplo n.º 2
0
        // Token: 0x060041D4 RID: 16852 RVA: 0x0014E9D8 File Offset: 0x0014CDD8
        public void Intersect()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            CSG.CSG csg = new CSG.CSG();
            csg.Construct(this.A.GetComponent <MeshFilter>().sharedMesh, this.A.transform, 0);
            CSG.CSG csg2 = new CSG.CSG();
            csg2.Construct(this.B.GetComponent <MeshFilter>().sharedMesh, this.B.transform, 1);
            CSG.CSG csg3       = csg.Intersect(csg2);
            Mesh    sharedMesh = csg3.ToMesh();

            this.Result = new GameObject("Intersect");
            DefaultObject defaultObject = this.Result.AddComponent <DefaultObject>();
            MeshFilter    meshFilter    = this.Result.AddComponent <MeshFilter>();

            meshFilter.sharedMesh = sharedMesh;
            MeshRenderer meshRenderer = this.Result.AddComponent <MeshRenderer>();

            meshRenderer.sharedMaterials = new Material[]
            {
                this.A.GetComponent <MeshRenderer>().sharedMaterial,
                this.B.GetComponent <MeshRenderer>().sharedMaterial
            };
            if (this.DeleteOriginal)
            {
                UnityEngine.Object.DestroyImmediate(this.A);
                UnityEngine.Object.DestroyImmediate(this.B);
            }
            stopwatch.Stop();
            defaultObject.GenerationTimeMS = (float)stopwatch.ElapsedMilliseconds;
        }
Ejemplo n.º 3
0
        public void Intersect()
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var csgA = new CSG.CSG();

            csgA.Construct(A.GetComponent <MeshFilter>().sharedMesh, A.transform, 0);

            var csgB = new CSG.CSG();

            csgB.Construct(B.GetComponent <MeshFilter>().sharedMesh, B.transform, 1);

            var substract = csgA.Intersect(csgB);
            var newMesh   = substract.ToMesh();

            Result = new GameObject("Intersect");
            var defObj     = Result.AddComponent <DefaultObject>();
            var meshFilter = Result.AddComponent <MeshFilter>();

            meshFilter.sharedMesh = newMesh;
            var renderer = Result.AddComponent <MeshRenderer>();

            renderer.sharedMaterials = new Material[] { A.GetComponent <MeshRenderer>().sharedMaterial, B.GetComponent <MeshRenderer>().sharedMaterial };

            if (DeleteOriginal)
            {
                Object.DestroyImmediate(A);
                Object.DestroyImmediate(B);
            }

            stopWatch.Stop();
            defObj.GenerationTimeMS = stopWatch.ElapsedMilliseconds;
        }