Net3dBool.BooleanModeller.getUnion C# (CSharp) Method

getUnion() public method

public getUnion ( ) : Solid
return Solid
        public Solid getUnion()
        {
            return composeSolid(Face.OUTSIDE, Face.SAME, Face.OUTSIDE);
        }

Usage Example

Example #1
0
    public override bool Calculate()
    {
        if (!allInputsReady ()) {
            return false;
        }

        if (Inputs [0].connection != null) {
            Input1Val = Inputs [0].connection.GetValue<GameObject> ();

            CSGObject csg = Input1Val.GetComponent<CSGObject>();
            if(csg == null)
                csg = Input1Val.AddComponent<CSGObject>();
            csg.GenerateSolid();
        }
        if (Inputs [1].connection != null) {

            Input2Val = Inputs [1].connection.GetValue<GameObject> ();
            CSGObject csg = Input2Val.GetComponent<CSGObject> ();
            if (csg == null)
                csg = Input2Val.AddComponent<CSGObject> ();
            csg.GenerateSolid ();
        }

        if ((Input1Val != null) && (Input2Val != null)) {

            solid1 = Input1Val.GetComponent<CSGObject> ().GetSolid ();
            solid2 = Input2Val.GetComponent<CSGObject> ().GetSolid ();

            modeller = new BooleanModeller (solid1, solid2);
            output = null;

            switch (type) {
            case CalcType.Union:
                output = modeller.getUnion ();
                break;
            case CalcType.Intersection:
                output = modeller.getIntersection ();
                break;
            case CalcType.Difference:
                output = modeller.getDifference ();
                break;
            }

            if (output != null) {
                string goname = string.Format ("CSGOut_{0}", (int)this.GetHashCode ());
                GameObject gout = GameObject.Find (goname);
                if (gout == null)
                    gout = new GameObject (goname);
                CSGObject csg = gout.GetComponent<CSGObject>();
                if(csg == null) csg = gout.AddComponent<CSGObject>();
                csg.AssignSolid(output);
                CSGGameObject.GenerateMesh (gout, objectMaterial, output);

                Outputs [0].SetValue<GameObject> (gout);
            }
        } else
            return false;

        return true;
    }