예제 #1
0
        // GENERATE EXTRUDE
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool renderToOutputParameter)
        {
            //Debug.Log ("===> [" + parametricObject.Name + "] EXTRUDE generate ... MAKE_GAME_OBJECTS="+makeGameObjects);

            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }

            // RESULTING MESHES
            ax_meshes = new List <AXMesh>();


            //Debug.Log(" ******** A ");

            preGenerate();


            // PLAN -
            // The plan may have multiple paths. Each may generate a separate GO.
            if (P_Plan == null || planSrc_p == null || !planSrc_p.parametricObject.isActive)
            {
                return(null);
            }


            //Debug.Log(" ******** B " + planSrc_p.parametricObject.Name + "." + planSrc_p.Name);



            // Offset is bevel and !bevelOut
            float originalOffset = P_Plan.offset;

            // set back by the max bevel - later consider taper and lip....



            if (!bevelOut)
            {
                /*
                 * float bevelMax = (bevelTop > bevelBottom) ? bevelTop : bevelBottom;
                 *
                 * if (bevelMax > 0 )
                 * {
                 *      offsetModified -= bevelMax;
                 *      //P_Plan.joinType = JoinType.jtMiter;
                 * }
                 */

                P_Plan.offset -= (bevelBottom > bevelTop) ? bevelBottom : bevelTop;
            }



            // Splitting concave shapes?
            // THis is a pecial case. An ssumption is mad of no holes
            // so that we can deal only with paths.

            if (parametricObject.splitConcaveShapes)            //P_Plan.offset != 0)
            {
                // SPLIT INTO CONCAVES ** ** ** ** ** ** if no holes, and makeConcave,
                Paths       paths;
                AXParameter tmpSrc = (!renderToOutputParameter && P_Plan.Dependents != null) ? P_Plan : planSrc_p;

                if (tmpSrc.polyTree != null)
                {
                    paths = Clipper.PolyTreeToPaths(tmpSrc.polyTree);
                }
                else
                {
                    paths = tmpSrc.paths;
                }

                //Pather.printPaths(P_Plan.paths);

                if (paths != null)
                {
                    P_Plan.paths = new Paths();

                    foreach (Path path in paths)
                    {
                        Paths splitPaths = Pather.splitIntoConvexPaths(path);
                        splitPaths = Pather.offset(splitPaths, P_Plan.offset);
                        P_Plan.paths.AddRange(splitPaths);
                    }
                }
                P_Plan.polyTree = null;

                // SPLIT INTO CONCAVES ** ** ** ** ** ** ** ** if no holes, and makeConcave,
            }
            else
            {
                //Debug.Log("A: "+planSrc_p.paths[0].Count);
                P_Plan.polyTree = null;

                //			Debug.Log("EXTRUED " + parametricObject.Name);
                //			Pather.printPaths(P_Plan.paths);

                if (!renderToOutputParameter && P_Plan.Dependents != null)
                {
                    // Some Replicant has set the paths of this Plan_P manually
                    AXShape.thickenAndOffset(ref P_Plan, P_Plan);
                }
                else
                {
                    AXShape.thickenAndOffset(ref P_Plan, planSrc_p);
                }
            }

            P_Plan.offset = originalOffset;



            //Debug.Log("B: " +P_Plan.paths[0].Count);



            // DEFAULT SECTION -- USING BI_CHAMFER_SIDEflipX



            Path sectionPath = new Path();

            sectionPath = AXTurtle.BiChamferSide(extrude, bevelTop, bevelBottom, bevelSegs, true, taper, lipTop, lipBottom, lipEdge, lipEdgeBottom, segs);

            AXParameter sec_p = new AXParameter();

            sec_p.Parent           = parametricObject;
            sec_p.parametricObject = parametricObject;
            sec_p.Type             = AXParameter.DataType.Shape;
            sec_p.shapeState       = ShapeState.Open;
            sec_p.paths            = new Paths();
            sec_p.paths.Add(sectionPath);

            if (parametricObject.boolValue("Bevel Hard Edge"))
            {
                sec_p.breakGeom = 0;
                sec_p.breakNorm = 0;
            }



            //StopWatch sw = new StopWatch();
            //Debug.Log("Extrude ===================== ");
            GameObject retGO = generateFirstPass(initiator_po, makeGameObjects, P_Plan, sec_p, Matrix4x4.identity, renderToOutputParameter);

            //Debug.Log("Extrude Done ===================== " + sw.duration());


            // FINISH AX_MESHES

            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, true);            //renderToOutputParameter);



            // FINISH BOUNDING

            setBoundaryFromAXMeshes(ax_meshes);

            //Debug.Log("Extrude: "+ parametricObject.bounds);

            return(retGO);
        }