示例#1
0
        public async Task <DataJobStatusDetail> GetJobStatus(string messageId)
        {
            DataJobStatusDetail jobStatusDetail = null;

            /// get status
            UriBuilder statusUri  = new UriBuilder(ClientConfiguration.Default.ActiveDirectoryResource);
            string     activityId = ClientConfiguration.Default.CustomerImportActivityId;


            statusUri.Path = string.Format(@"api/connector/jobstatus/{0}", activityId);

            string statusQuery = string.Format("jobid={0}", messageId.Replace(@"""", ""));

            statusUri.Query = statusQuery;


            //send a request to get the message status
            AXUtilities axUtil = new AXUtilities();


            var response = await axUtil.GetRequestAsync(statusUri.Uri);

            if (response.IsSuccessStatusCode)
            {
                // Deserialize response to the DataJobStatusDetail object
                jobStatusDetail = JsonConvert.DeserializeObject <DataJobStatusDetail>(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
            }

            return(jobStatusDetail);
        }
示例#2
0
        public async Task <string> Import([FromBody] DIXFEntity entity)
        {
            HttpResponseMessage responseMsg = Request.CreateResponse(HttpStatusCode.OK);

            //string relativeUri = string.Format(@"{0}", executionId);
            //responseMsg.Headers.Location = new Uri(Request.RequestUri, relativeUri);

            if (entity == null)
            {
                return(string.Empty);
            }

            /*uri = new Uri("https://dev-matt-3devaos.cloudax.dynamics.com/data");
             *
             * var context = new Resources(uri);
             * context.SendingRequest2 += new EventHandler<SendingRequest2EventArgs>(delegate (object sender, SendingRequest2EventArgs e)
             * {
             *  e.RequestMessage.SetHeader("Authorization", AXUtilities.AuthorizationHeader);
             * });
             *
             * var myendpoint = from EndPoint in context.IntegrationDataProjectEndpoints
             *               where EndPoint.LegacySourceEndpointId == entity.SourceEndpointId
             *               select EndPoint;
             */

            string entityName = "Customer groups";// myendpoint.First().EntityName;

            AXUtilities axUtil = new AXUtilities();

            UriBuilder enqueueUri = new UriBuilder(ClientConfiguration.Default.ActiveDirectoryResource);
            string     activityId = "bd2578ac-9690-4b93-908e-ccfb3b786f42";//myendpoint.First().ActivityId.ToString();


            enqueueUri.Path = string.Format(@"api/connector/enqueue/{0}", activityId);

            string enqueueQuery = string.Format("entity={0}", entityName);

            string company = "wcf";//myendpoint.First().Company

            if (!string.IsNullOrEmpty(company))
            {
                enqueueQuery += "&company=" + company;
            }


            enqueueUri.Query = enqueueQuery;

            HttpResponseMessage response = null;

            using (Stream bodyStream = GenerateStreamFromString(entity.FileContent))
            {
                response = axUtil.SendPostRequest(enqueueUri.Uri, AXUtilities.AuthorizationHeader, bodyStream, null, null);
            }
            var messageId = await response.Content.ReadAsStringAsync();


            return(messageId);
        }
示例#3
0
        public async Task <string> Import([FromBody] DIXFEntity entity)
        {
            HttpResponseMessage responseMsg = Request.CreateResponse(HttpStatusCode.OK);

            //string relativeUri = string.Format(@"{0}", executionId);
            //responseMsg.Headers.Location = new Uri(Request.RequestUri, relativeUri);

            if (entity == null)
            {
                return(string.Empty);
            }

            string[] folderSegments = entity.Name.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);

            if (folderSegments.Length < 1)
            {
                return(string.Empty);
            }

            string entityName = folderSegments[folderSegments.Length - 2];

            AXUtilities axUtil = new AXUtilities();

            UriBuilder enqueueUri = new UriBuilder(ClientConfiguration.Default.ActiveDirectoryResource);
            string     activityId = string.Empty;

            switch (entityName)
            {
            case "Fleet Management Customers":
                activityId = ClientConfiguration.Default.CustomerImportActivityId;
                break;

            case "Fleet Management Rentals":
                activityId = ClientConfiguration.Default.RentalImportActivityId;
                break;
            }

            enqueueUri.Path = string.Format(@"api/connector/enqueue/{0}", activityId);

            string enqueueQuery = string.Format("entity={0}", entityName);

            enqueueUri.Query = enqueueQuery;


            HttpResponseMessage response = null;

            using (Stream bodyStream = GenerateStreamFromString(entity.FileContent))
            {
                response = axUtil.SendPostRequest(enqueueUri.Uri, AXUtilities.AuthorizationHeader, bodyStream, null, null);
            }
            var messageId = await response.Content.ReadAsStringAsync();


            return(messageId);
        }
示例#4
0
        public async Task <HttpResponseMessage> WaitForJob(string messageId)
        {
            DataJobStatusDetail jobStatusDetail = null;
            HttpResponseMessage responseMsg     = Request.CreateResponse(HttpStatusCode.Accepted);
            string relativeUri = string.Empty;


            /// get status
            UriBuilder statusUri  = new UriBuilder(ClientConfiguration.Default.ActiveDirectoryResource);
            string     activityId = ClientConfiguration.Default.CustomerImportActivityId;


            statusUri.Path = string.Format(@"api/connector/jobstatus/{0}", activityId);

            string statusQuery = string.Format("jobid={0}", messageId.Replace(@"""", ""));

            statusUri.Query = statusQuery;


            //send a request to get the message status
            AXUtilities axUtil = new AXUtilities();


            var response = await axUtil.GetRequestAsync(statusUri.Uri);

            if (response.IsSuccessStatusCode)
            {
                // Deserialize response to the DataJobStatusDetail object
                jobStatusDetail = JsonConvert.DeserializeObject <DataJobStatusDetail>(response.Content.ReadAsStringAsync().Result);

                if (jobStatusDetail != null)
                {
                    if (jobStatusDetail.DataJobStatus.DataJobState == DataJobState.Processed || jobStatusDetail.DataJobStatus.DataJobState == DataJobState.ProcessedWithErrors)
                    {
                        responseMsg.StatusCode = HttpStatusCode.OK;
                    }
                    else
                    {
                        responseMsg.StatusCode       = HttpStatusCode.Accepted;
                        relativeUri                  = string.Format("{0}", messageId);
                        responseMsg.Headers.Location = new Uri(Request.RequestUri, relativeUri);
                    }
                }
            }
            else
            {
            }


            return(responseMsg);
        }
示例#5
0
        // GENERATE PLANE_TOOL
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            AXParameter output = parametricObject.getParameter("Output Plane");

            Vector3 a = new Vector3(parametricObject.getParameter("PointA_X").val, parametricObject.getParameter("PointA_Y").val, parametricObject.getParameter("PointA_Z").val);
            Vector3 b = new Vector3(parametricObject.getParameter("PointB_X").val, parametricObject.getParameter("PointB_Y").val, parametricObject.getParameter("PointB_Z").val);
            Vector3 c = new Vector3(parametricObject.getParameter("PointC_X").val, parametricObject.getParameter("PointC_Y").val, parametricObject.getParameter("PointC_Z").val);

            output.plane = new Plane(a, b, c);

            matrix = AXUtilities.Plane2Matrix(output.plane, a);

            /*
             * Debug.Log ("a="+a);
             * Debug.Log ("b="+b);
             * Debug.Log ("c="+c);
             *
             * Debug.Log ("output.plane "+output.plane.normal);
             */

            return(null);
        }
        // GENERATE INSTANCE
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }

            if (P_Input == null || P_Input.DependsOn == null || P_Input.DependsOn.meshes == null || P_Input.DependsOn.meshes.Count == 0)
            {
                return(null);
            }

            if (inputSrc_po == null)
            {
                inputSrc_po = P_Input.DependsOn.parametricObject;
            }
            preGenerate();

            GameObject go = null;


            if (makeGameObjects)
            {
                go = inputSrc_po.generator.generate(true, initiator_po, isReplica);
                if (go == null)
                {
                    return(null);
                }

                go.name = go.name + " (Inst)";
                AXGameObject axgo = go.GetComponent <AXGameObject>();
                if (axgo != null)
                {
                    axgo.makerPO_GUID = parametricObject.Guid;
                }
            }

            List <AXMesh> ax_meshes = new List <AXMesh>();

            Matrix4x4 srcLocalM = inputSrc_po.getLocalMatrix().inverse;

            // just pass it through, but use grandparent's transform!

            // Instance does not inhereit and build on the transform of its source object.
            // It only uses its mesh, textures, etc.
            for (int mi = 0; mi < P_Input.DependsOn.meshes.Count; mi++)
            {
                AXMesh amesh = P_Input.DependsOn.meshes [mi];
                ax_meshes.Add(amesh.Clone(srcLocalM * amesh.transMatrix));
            }

            parametricObject.bounds     = inputSrc_po.bounds;
            parametricObject.boundsMesh = inputSrc_po.boundsMesh;

            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);

            // Turn ax_meshes into GameObjects
            if (makeGameObjects)
            {
                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                go.transform.localScale = AXUtilities.GetScale(tmx);                         //
                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);

                return(go);
            }
            return(null);
        }
    public static void processEventCommand(Event e, AXModel model)
    {
        if (e.type == EventType.ValidateCommand)
        {
            e.Use();
        }

        //Debug.Log("-> processEventCommand 1: PROCESS COMMAND "+e.commandName);


        var view = SceneView.lastActiveSceneView;

        string focusedControlName = GUI.GetNameOfFocusedControl();

        if (model != null)
        {
            // intercept this command and use for po's
            switch (e.commandName)
            {
            case "UndoRedoPerformed":
                //Debug.Log ("UndoRedoPerformed");
                model.cleanGraph();
                model.autobuild();

                for (int i = 0; i < model.selectedPOs.Count; i++)
                {
                    model.selectedPOs[i].generator.adjustWorldMatrices();
                }

                // SCENEVIEW
                if (SceneView.lastActiveSceneView != null)
                {
                    SceneView.lastActiveSceneView.Repaint();
                }


                //model.setRenderMode( AXModel.RenderMode.GameObjects );
                model.cacheThumbnails("AXGeometryTools.Utilities::processEventCommand::UndoRedoPerformed");


                if (e.type != EventType.Repaint && e.type != EventType.Layout)
                {
                    e.Use();
                }
                break;


            case "SelectAll":

                Debug.Log("SelectAll");
                model.selectAll();


                e.Use();
                break;

            case "Copy":
                //Debug.Log ("COPY ..."+ GUI.GetNameOfFocusedControl());

                //Debug.Log ("buf: " + EditorGUIUtility.systemCopyBuffer);

                //Debug.Log("-"+focusedControlName+"-");
                //Debug.Log((string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_")));
                if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))
                {
                    if (model.selectedPOs.Count > 0)
                    {
                        EditorGUIUtility.systemCopyBuffer = LibraryEditor.poWithSubNodes_2_JSON(model.selectedPOs[0], true);
                    }
                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }

                break;

            case "Paste":
                //Debug.Log ("PASTE");
                //Debug.Log(GUI.GetNameOfFocusedControl());

                //if (string.IsNullOrEmpty(GUI.GetNameOfFocusedControl()))
                //{
                Undo.RegisterCompleteObjectUndo(model, "Paste");
                string focusedControlNameBeforePaste = GUI.GetNameOfFocusedControl();
                if (string.IsNullOrEmpty(focusedControlNameBeforePaste) || !focusedControlNameBeforePaste.Contains("_Text_"))
                {
                    //model.deselectAll();

                    Library.pasteParametricObjectFromString(EditorGUIUtility.systemCopyBuffer);
                    model.autobuild();

                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }
                model.autobuild();

                break;

            case "Duplicate":
                Undo.RegisterCompleteObjectUndo(model, "Duplicate");

                //Debug.Log ("Duplicate Command");
                if (model.selectedPOs.Count > 0)
                {
                    AXParametricObject selectedPO = model.selectedPOs[0];

                    instancePO(selectedPO);
                }

                model.autobuild();

                if (e.type != EventType.Repaint && e.type != EventType.Layout)
                {
                    e.Use();
                }
                break;

            case "Cut":
                Undo.RegisterCompleteObjectUndo(model, "Cut");
                //EditorGUIUtility.systemCopyBuffer = JSONSerializersAX.allSelectedPOsAsJson(model);


                if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))
                {
                    if (model.selectedPOs.Count > 0)
                    {
                        EditorGUIUtility.systemCopyBuffer = LibraryEditor.poWithSubNodes_2_JSON(model.selectedPOs[0], true);
                    }


                    if (e.shift)
                    {
                        model.deleteSelectedPOsAndInputs();
                    }
                    else
                    {
                        model.deleteSelectedPOs();
                    }

                    model.autobuild();
                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }



                break;

            case "SoftDelete":
            case "Delete":

                //Debug.Log("DELETE");
                // see if it is a selected point on a curve
                //if (ArchimatixEngine

                /*
                 * FreeCurve selectedFreeCurve = null;
                 *
                 * if ( model.selectedPOs != null && model.selectedPOs.Count == 1 &&  model.selectedPOs[0] != null && model.selectedPOs[0].generator != null &&  model.selectedPOs[0].generator is FreeCurve)
                 * {
                 *      selectedFreeCurve = (FreeCurve) model.selectedPOs[0].generator;
                 * }
                 *
                 * if (selectedFreeCurve != null && selectedFreeCurve.selectedIndices != null  &&  selectedFreeCurve.selectedIndices.Count > 0)
                 * {
                 *      // delete points
                 *      selectedFreeCurve.deleteSelected();
                 * }
                 */

                // SELECTED POINTS TO DELETE?
                //Debug.Log("focusedControlName="+focusedControlName);
                if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))
                {
                    bool foundSelectedPoints = false;

                    if (model.activeFreeCurves.Count > 0)
                    {
                        for (int i = 0; i < model.activeFreeCurves.Count; i++)
                        {
                            FreeCurve gener = (FreeCurve)model.activeFreeCurves[i].generator;


                            //Debug.Log("gener.hasSelectedPoints()="+gener.hasSelectedPoints());
                            if (gener.hasSelectedPoints())
                            {
                                foundSelectedPoints = true;
                                gener.deleteSelected();
                            }
                        }
                    }
                    //Debug.Log("foundSelectedPoints="+foundSelectedPoints);

                    if (foundSelectedPoints)
                    {
                        ArchimatixEngine.mouseIsDownOnHandle = false;
                    }
                    else if (e.shift)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Nodes");
                        model.deleteSelectedPOsAndInputs();
                    }
                    // [S.Darkwell: changed else to this else if to fix bug: "Fix pressing Delete key without Node selected still registers undo event" https://archimatixbeta.slack.com/files/s.darkwell/F1DJRQ3LL/fix_pressing_delete_key_without_node_selected_still_registers_undo_event.cs  - 2016.06.02]
                    else if (model.selectedPOs.Count > 0)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Node");
                        model.deleteSelectedPOs();
                    }
                    else if (model.selectedParameterInputRelation != null)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Dependancy");
                        model.selectedParameterInputRelation.makeIndependent();
                        model.selectedParameterInputRelation = null;
                    }
                    else if (model.selectedRelationInGraph != null)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Relation");
                        model.unrelate(model.selectedRelationInGraph);
                        model.selectedRelationInGraph = null;
                    }

                    //Debug.Log("*********************************** DELETE");
                    model.remapMaterialTools();

                    model.autobuild();

                    //Debug.Log("caching here G");
                    model.cacheThumbnails();
                    e.Use();
                }



                break;



            case "FrameSelected":

                if (view != null)
                {
                    float framePadding = 400;


                    if (model.selectedPOs == null || model.selectedPOs.Count == 0)
                    {
                        //model.selectAll();
                        model.selectAllVisibleInGroup(model.currentWorkingGroupPO);


                        Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs);
                        allRect.x      -= framePadding;
                        allRect.y      -= framePadding;
                        allRect.width  += framePadding * 2;
                        allRect.height += framePadding * 2;

                        AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                        model.deselectAll();
                    }
                    else if (model.selectedPOs.Count > 1)
                    {
                        Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs);
                        allRect.x      -= framePadding;
                        allRect.y      -= framePadding;
                        allRect.width  += framePadding * 2;
                        allRect.height += framePadding * 2;

                        AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                    }
                    else
                    {
                        //frame first po
                        AXParametricObject currPO = model.cycleSelectedPO;                        // model.selectedPOs[0];

                        if (currPO == null)
                        {
                            currPO = model.mostRecentlySelectedPO;
                        }

                        if (currPO == null && model.selectedPOs != null && model.selectedPOs.Count > 0)
                        {
                            currPO = model.selectedPOs[0];
                        }

                        if (currPO == null)
                        {
                            currPO = model.selectFirstHeadPO();
                        }

                        if (currPO != null)
                        {
                            Matrix4x4 m = model.transform.localToWorldMatrix * currPO.worldDisplayMatrix;                            // * currPO.getLocalMatrix();

                            if (m.isIdentity)
                            {
                                m = currPO.generator.localMatrix;
                            }

                            Vector3 position = m.MultiplyPoint(currPO.bounds.center);


                            if (currPO.bounds.size.magnitude > .005 && currPO.bounds.size.magnitude < 10000)
                            {
                                view.LookAt(position, view.camera.transform.rotation, currPO.bounds.size.magnitude * 1.01f);
                            }
                            else
                            {
                                //Debug.Log("FrameSelected - select ParametricObjectObject bounds not good: "+currPO.bounds.size.magnitude);
                            }

                            //if (currPO.grouper != null )
                            //{
                            AXNodeGraphEditorWindow.displayGroupIfOpen(currPO.grouper);
                            //}
                            //model.beginPanningToPoint(currPO.rect.center);
                            AXNodeGraphEditorWindow.zoomToRectIfOpen(currPO.rect);
                        }
                    }
                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }

                break;
            }
        }

        // EDITOR WINDOW

        ArchimatixEngine.repaintGraphEditorIfExistsAndOpen();

        // SCENEVIEW
        if (view != null)
        {
            view.Repaint();
        }


        lastCommand = e.commandName;
    }
 public static float getHandlesMatrixScaleAdjuster()
 {
     return(1.442f / AXUtilities.GetScale(Handles.matrix).magnitude);
 }
示例#9
0
        // GENERATE PLAN_REPEATER
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool renderToOutputParameter)
        {
            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }
            //Debug.Log("yo ******* makeGameObjects="+makeGameObjects);


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

            paths_SubsplineIndices = new List <SubsplineIndices[]>();

            preGenerate();



            planSrc_p  = P_Plan.DependsOn;                         // getUpstreamSourceParameter(P_Plan);
            planSrc_po = (planSrc_p != null)                                                           ? planSrc_p.parametricObject    : null;

            //Debug.Log("planSrc_po = " + planSrc_po.Name+"."+planSrc_p.Name + " ... " + planSrc_p.DependsOn.PType + " ..... " + planSrc_p.getPaths());

            P_Plan.polyTree = null;
            AXShape.thickenAndOffset(ref P_Plan, planSrc_p);
            if (P_Plan.reverse)
            {
                P_Plan.doReverse();
            }


            planPaths = P_Plan.getPaths();

            if (planPaths == null || planPaths.Count == 0)
            {
                return(null);
            }



            // ** CREATE PLAN_SPLINES **

            if (planPaths != null && planPaths.Count > 0)
            {
                planSplines = new Spline[planPaths.Count];


                if (planSplines != null)
                {
                    for (int i = 0; i < planSplines.Length; i++)
                    {
                        planSplines[i] = new Spline(planPaths[i], (P_Plan.shapeState == ShapeState.Closed) ? true : false);
                    }
                }
            }



            //Debug.Log("controlVertices="+ planSplines[0].controlVertices.Count);



            // CORNER_MESH
            GameObject cornerPlugGO = null;

            if (cornerSrc_p != null)
            {
                cornerSrc_po = cornerSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    cornerPlugGO = cornerSrc_po.generator.generate(true, initiator_po, renderToOutputParameter);
                }
            }



            // NODE_MESH

            GameObject nodePlugGO = null;

            if (nodeSrc_p != null)
            {
                nodeSrc_po = nodeSrc_p.parametricObject;
                //Debug.Log("yo makeGameObjects="+makeGameObjects+", parametricObject.combineMeshes="+parametricObject.combineMeshes);
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, renderToOutputParameter);
                }
            }



            // CELL_MESH

            GameObject cellPlugGO = null;

            if (cellSrc_p != null)
            {
                cellSrc_po = cellSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, renderToOutputParameter);
                }
            }



            // Plan
            // This is the main spline used for the iteration



            //AXParameter plan_p = ip.DependsOn;



            // The section spline is used to provide the connective tissue around corners

            // SECTION

            // The plan may have multiple paths. Each may generate a separate GO.

            sectionSrc_p  = P_Section.DependsOn;              //getUpstreamSourceParameter(P_Section);
            sectionSrc_po = (sectionSrc_p != null) ? sectionSrc_p.parametricObject : null;

            if (sectionSrc_po != null)
            {
                P_Section.polyTree = null;
                AXShape.thickenAndOffset(ref P_Section, sectionSrc_p);
                if (P_Section.reverse)
                {
                    P_Section.doReverse();
                }
            }



            float bay_U = parametricObject.floatValue("bay_U");
            float bay_V = parametricObject.floatValue("bay_V");

            if (bay_U == 0)
            {
                bay_U = .1f;
            }
            if (bay_V == 0)
            {
                bay_V = 10f;
            }

            float margin_U = parametricObject.floatValue("margin_U");



            Vector2 prevV = new Vector2();

            //Vector3 scaler1   = Vector3.one;


            //float margin = 2.5f;

            Vector2 firstPM = new Vector2();
            Vector2 prevVM  = new Vector2();



            AXSpline secSpline = null;
            AXSplineExtrudeGenerator tmpEXSP = null;

            if (sectionSrc_p != null && sectionSrc_p.spline != null && sectionSrc_p.spline.vertCount > 0)
            {
                secSpline = sectionSrc_p.spline;
            }



            tmpEXSP = new AXSplineExtrudeGenerator();

            Material tmp_mat = parametricObject.axMat.mat;

            if (parametricObject.axTex != null)
            {
                tmpEXSP.uScale = parametricObject.axTex.scale.x;
                tmpEXSP.vScale = parametricObject.axTex.scale.y;
                tmpEXSP.uShift = -parametricObject.axTex.shift.x;
                tmpEXSP.vShift = parametricObject.axTex.shift.y;
            }



            float runningU = 0;



            //ip.spline.getAnglesArray();

            //Spline sectionSpline = null;
            //	= new Spline(sectionPath, sectionIsClosed,  sec_p.breakGeom, sec_p.breakNorm);



            GameObject go     = null;
            GameObject planGO = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }



            // BOUNDING

            List <AXMesh> boundingMeshes = new List <AXMesh>();



            // FOR EACH PATH
            for (int path_i = 0; path_i < planPaths.Count; path_i++)
            {
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    planGO = ArchimatixUtils.createAXGameObject(parametricObject.Name + "_" + path_i, parametricObject);
                }



                // **** PREPARE EACH SPLINE *** //

                Spline planSpline = planSplines[path_i];

                planSpline.breakAngleCorners = cornerBreakAngle;
                planSpline.shapeState        = P_Plan.shapeState;



                // Create subsplines between each break point
                planSpline.getSmoothSubsplineIndicies(0, maxSegmentLength);


                // ....... DEBUG
                //Pather.printPaths(planPaths);


                planSpline.groupNearBreakAngleVertices(inset * 2);

                if (planSpline.groupedCornerNodes == null || planSpline.groupedCornerNodes.Count == 0)
                {
                    inset = 0;
                }



                // **** PREPARE EACH SPLINE *** //



                Matrix4x4 localPlacement_mx = Matrix4x4.identity;



                //  INSET PLANSWEEPS
                GameObject plansweepGO = null;

                if (sectionSrc_p != null && inset > 0 && planSpline.insetSplines != null)
                {
                    // convert planSpline.insetSplines to Paths
                    Paths insetPaths = AXGeometryTools.Utilities.Splines2Paths(planSpline.insetSplines);

                    AXParameter tmpPlanP = new AXParameter();
                    tmpPlanP.parametricObject = parametricObject;
                    tmpPlanP.paths            = insetPaths;
                    tmpPlanP.Type             = AXParameter.DataType.Shape;
                    tmpPlanP.shapeState       = ShapeState.Open;
                    tmpPlanP.breakGeom        = 0;

                    if (planSpline.insetSplines.Count == 1)
                    {
                        tmpPlanP.shapeState = planSpline.insetSplines[0].shapeState;
                    }

                    topCap = false;
                    botCap = false;

                    plansweepGO = generateFirstPass(initiator_po, makeGameObjects, tmpPlanP, P_Section, Matrix4x4.identity, renderToOutputParameter, false);



                    if (makeGameObjects && !parametricObject.combineMeshes && plansweepGO != null)
                    {
                        plansweepGO.transform.parent = go.transform;
                    }
                }



                AXMesh tmpMesh = null;



                if (planSpline.insetSpanSplines != null && planSpline.insetSpanSplines.Count > 0)
                {
                    //Debug.Log(".....????>> spanSpline.subsplines.Count="+ planSpline.insetSpanSplines.Count + " --- " + planSpline.subsplines.Count );
                    for (int si = 0; si < planSpline.insetSpanSplines.Count; si++)
                    {
                        planSpline.insetSpanSplines[si].setRepeaterTransforms(si, inset, bay);
                    }


                    // SPAN NODES - MESHES ALONG SUBSPLINES
                    if (nodeSrc_p != null && nodeSrc_p.meshes != null)
                    {
                        //int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ?  planSpline.subsplines.Count-1 : planSpline.subsplines.Count;
                        int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ?  planSpline.insetSpanSplines.Count - 1 : planSpline.insetSpanSplines.Count;

                        for (int i = 0; i < endCount; i++)
                        {
                            //SubsplineIndices rsi = planSpline.subsplines[i];
                            Spline spanSpline = planSpline.insetSpanSplines[i];


                            //Debug.Log(i + "||||||||||> " + spanSpline.toString());

                            List <Matrix4x4> nodeMatrices = spanSpline.repeaterNodeTransforms;


                            // on each of these nodes, place a nodePlug instance.
                            bool spanNodesAtBreakCorners = true;

                            int starter = (inset > 0 || spanNodesAtBreakCorners) ? 0 : 1;
                            //Debug.Log("starter="+starter);

                            int ender = (inset > 0 || spanSpline.shapeState == ShapeState.Open || planSpline.subsplines.Count == 1) ? nodeMatrices.Count : nodeMatrices.Count - 1;


                            //Debug.Log("starter="+starter +", ender="+ender + ", nodeMatrices.Count=" + nodeMatrices.Count);

                            //Debug.Log("(inset > 0 && spanNodesAtBreakCorners)="+(inset > 0 && spanNodesAtBreakCorners)+", nodeMatrices.Length="+nodeMatrices.Length+", starter="+starter+", ender="+ender);

                            string this_address = "";

                            if (nodeMatrices != null)
                            {
                                for (int ii = starter; ii < ender; ii++)
                                {
                                    this_address = "node_" + path_i + "_" + i + "_" + ii;

                                    //Debug.Log("this_address="+this_address);
                                    // LOCAL_PLACEMENT

                                    localPlacement_mx = localMatrixFromAddress(RepeaterItem.Node, path_i, i, ii);


                                    // AX_MESHES

                                    for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++)
                                    {
                                        AXMesh dep_amesh = nodeSrc_p.meshes [mi];
                                        tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                                        tmpMesh.subItemAddress = this_address;
                                        ax_meshes.Add(tmpMesh);
                                    }



                                    // BOUNDING
                                    boundingMeshes.Add(new AXMesh(nodeSrc_po.boundsMesh, localPlacement_mx * nodeSrc_po.generator.localMatrix));

                                    //Debug.Log("boundingMeshes: " + boundingMeshes.Count);

                                    // GAME_OBJECTS

                                    if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                                    {
                                        Matrix4x4  mx     = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                                        GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));


                                        Vector3 newJitterScale = jitterScale + Vector3.one;
                                        copyGO.transform.localScale  = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z);
                                        copyGO.transform.localScale += jitterScale;

                                        AXGameObject axgo = copyGO.GetComponent <AXGameObject>();


                                        if (axgo != null)
                                        {
                                            axgo.consumerAddress = this_address;
                                            //Debug.Log("ADD ADDRESS: " + this_address);
                                        }
                                        copyGO.name = copyGO.name + "_" + this_address;

                                        //Debug.Log("copyGO.name = "+copyGO.name);

                                        copyGO.transform.parent = planGO.transform;
                                    }
                                }
                            }
                        }
                    }                     // \NODE MESHES



                    // CELL NODES - MESHES ALONG SUBSPLINES
                    if (cellSrc_p != null && cellSrc_p.meshes != null)
                    {
                        //int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ?  planSpline.subsplines.Count-1 : planSpline.subsplines.Count;
                        int endCount = (P_Plan != null && P_Plan.shapeState == ShapeState.Open) ?  planSpline.insetSpanSplines.Count - 1 : planSpline.insetSpanSplines.Count;

                        for (int i = 0; i < endCount; i++)
                        {
                            //SubsplineIndices rsi = planSpline.subsplines[i];
                            Spline spanSpline = planSpline.insetSpanSplines[i];

                            spanSpline.setRepeaterTransforms(i, inset, bay);


                            List <Matrix4x4> cellMatrices = spanSpline.repeaterCellTransforms;



                            // on each of these cell, place a nodePlug instance.
                            //bool spanNodesAtBreakCorners = true;

                            int starter = 0;                            //spanNodesAtBreakCorners ? 0 : 1;


                            //int ender     = (inset > 0 || spanNodesAtBreakCorners) ? cellMatrices.Count : cellMatrices.Count-1;
                            int ender = cellMatrices.Count;

                            //Debug.Log("(inset > 0 && spanNodesAtBreakCorners)="+(inset > 0 && spanNodesAtBreakCorners)+", nodeMatrices.Length="+nodeMatrices.Length+", starter="+starter+", ender="+ender);

                            string this_address = "";

                            if (cellMatrices != null)
                            {
                                for (int ii = starter; ii < ender; ii++)
                                {
                                    // ADDRESS

                                    this_address = "cell_" + path_i + "_" + i + "_" + ii;


                                    // LOCAL_PLACEMENT

                                    localPlacement_mx = localMatrixFromAddress(RepeaterItem.Cell, path_i, i, ii);



                                    // AX_MESHES

                                    for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++)
                                    {
                                        AXMesh dep_amesh = cellSrc_p.meshes [mi];
                                        tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                                        tmpMesh.subItemAddress = this_address;
                                        ax_meshes.Add(tmpMesh);
                                    }



                                    // BOUNDING
                                    boundingMeshes.Add(new AXMesh(cellSrc_po.boundsMesh, localPlacement_mx * cellSrc_po.generator.localMatrix));


                                    // GAME_OBJECTS

                                    if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                                    {
                                        Matrix4x4  mx     = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                                        GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));


                                        Vector3 newJitterScale = jitterScale + Vector3.one;
                                        copyGO.transform.localScale  = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z);
                                        copyGO.transform.localScale += jitterScale;

                                        AXGameObject axgo = copyGO.GetComponent <AXGameObject>();


                                        if (axgo != null)
                                        {
                                            axgo.consumerAddress = this_address;
                                            //Debug.Log("ADD ADDRESS: " + this_address);
                                        }
                                        copyGO.name = copyGO.name + "_";                                      // + this_address;

                                        //Debug.Log("copyGO.name = "+copyGO.name);

                                        copyGO.transform.parent = planGO.transform;
                                    }
                                }
                            }
                        }
                    }             // \CELL MESHES
                }                 // \each spanSpline



                // BREAK CORNER MESHES

                if (cornerSrc_p != null && cornerSrc_p.meshes != null)
                {
                    for (int bi = 0; bi < planSpline.breakIndices.Count; bi++)
                    {
                        // ADDRESS

                        string this_address = "corner_" + path_i + "_" + planSpline.breakIndices[bi];

                        // LOCAL_PLACEMENT

                        localPlacement_mx = localMatrixFromAddress(RepeaterItem.Corner, path_i, planSpline.breakIndices[bi]);


                        // AX_MESHES

                        for (int mi = 0; mi < cornerSrc_p.meshes.Count; mi++)
                        {
                            AXMesh dep_amesh = cornerSrc_p.meshes [mi];
                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }



                        // BOUNDING
                        boundingMeshes.Add(new AXMesh(cornerSrc_po.boundsMesh, localPlacement_mx * cornerSrc_po.generator.localMatrix));



                        // GAME_OBJECTS

                        if (cornerPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            Matrix4x4  mx     = localPlacement_mx * cornerSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            GameObject copyGO = (GameObject)GameObject.Instantiate(cornerPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));


                            Vector3 newJitterScale = jitterScale + Vector3.one;
                            copyGO.transform.localScale  = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z);
                            copyGO.transform.localScale += jitterScale;

                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = planGO.transform;
                        }
                    }
                }



                /*
                 * int cells = Mathf.CeilToInt( md/bay_U );
                 * int nby = Mathf.CeilToInt( height/bay_V );
                 *
                 * //Debug.Log ("d="+d+", md="+md);
                 *
                 * float actual_bayx = md/cells;
                 * float actual_bayy = height/nby;
                 *
                 * // CREATE VERSIONS OF INPUT BAY_CENTER MESH(ES) USING BOUNDING BOX
                 * // ******************************************************************************
                 * // someting similar shoud be added to griditerator, stepiterator, and where else?
                 *
                 * // instead of prev, would be better to create a dictionary of bounds and AXMeshes?
                 * if (bay_span_p != null && (prevActuralBayx != actual_bayx || prevActuralBayx != actual_bayy))
                 * {
                 *      // regnerate the input meshes using actual_bayx
                 *      bay_span_p.Parent.setParameterValueByName("uScale", parametricObject.floatValue("uScale"));
                 *      bay_span_p.Parent.setParameterValueByName("vScale", parametricObject.floatValue("vScale"));
                 *      bay_span_p.Parent.setParameterValueByName("uShift", parametricObject.floatValue("uShift"));
                 *      bay_span_p.Parent.setParameterValueByName("vShift", parametricObject.floatValue("vShift"));
                 *
                 *      //bay_span_p.Parent.generateOutputNow (makeGameObjects, parametricObject, true);//, new Vector3(actual_bayx, actual_bayy, margin_th));
                 *
                 * }
                 * // ******************************************************************************
                 *
                 *
                 * // CREATE VERSIONS OF INPUT BAY_CENTER MESH(ES) USING BOUNDING BOX
                 * // ******************************************************************************
                 * // someting similar shoud be added to griditerator, stepiterator, and where else?
                 *
                 * // instead of prev, would be better to create a dictionary of bounds and AXMeshes?
                 * if (node_p != null && (prevActuralBayx != actual_bayx || prevActuralBayx != actual_bayy))
                 * {
                 *      // regnerate the input meshes using actual_bayx
                 *      node_p.Parent.setParameterValueByName("uScale", parametricObject.floatValue("uScale"));
                 *      node_p.Parent.setParameterValueByName("vScale", parametricObject.floatValue("vScale"));
                 *      node_p.Parent.setParameterValueByName("uShift", parametricObject.floatValue("uShift"));
                 *      node_p.Parent.setParameterValueByName("vShift", parametricObject.floatValue("vShift"));
                 *
                 *      //node_p.Parent.generateOutputNow (makeGameObjects, parametricObject, true);//, new Vector3(actual_bayx, actual_bayy, margin_th));
                 *
                 * }
                 * // ******************************************************************************
                 */



                //margin_U = .5f;
                if (margin_U > 0 && planSpline.isClosed)
                {
                    AXSpline connSpline2 = new AXSpline();
                    connSpline2.Push(prevVM);
                    connSpline2.Push(prevV);
                    connSpline2.Push(firstPM);
                    connSpline2.isClosed = false;

                    tmpEXSP.uShift = parametricObject.floatValue("uShift") + (runningU) / tmpEXSP.uScale;

                    Mesh mesh = tmpEXSP.generate(connSpline2, secSpline);
                    ax_meshes.Add(new AXMesh(mesh, Matrix4x4.identity, tmp_mat));
                }


                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    planGO.transform.parent = go.transform;
                }
            }            // end paths



            //GameObject.DestroyImmediate(bay_spanPlugGO);
            GameObject.DestroyImmediate(cornerPlugGO);
            GameObject.DestroyImmediate(nodePlugGO);
            GameObject.DestroyImmediate(cellPlugGO);



            // FINISH AX_MESHES
            //Debug.Log("finish " + ax_meshes.Count);
            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, renderToOutputParameter);


            // FINISH BOUNDS

            CombineInstance[] boundsCombinator = new CombineInstance[boundingMeshes.Count];
            for (int bb = 0; bb < boundsCombinator.Length; bb++)
            {
                boundsCombinator[bb].mesh      = boundingMeshes[bb].mesh;
                boundsCombinator[bb].transform = boundingMeshes[bb].transMatrix;
            }
            setBoundsWithCombinator(boundsCombinator);



            // FINISH GAME_OBJECTS

            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true);
                }

                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScaleAxisRotated();                        //AXUtilities.GetScale(tmx);

                if (P_Plan.reverse)
                {
                    P_Plan.doReverse();
                }

                if (P_Section != null && P_Section.reverse)
                {
                    P_Section.doReverse();
                }

                return(go);
            }
            else
            {
                // Submit AXMeshes for realtime rendering
                //parametricObject.finishMultiAXMeshAndOutput(ax_meshes, renderToOutputParameter);
                //setBoundaryFromMeshes(ax_meshes);
            }



            if (P_Plan.reverse)
            {
                P_Plan.doReverse();
            }

            if (P_Section != null && P_Section.reverse)
            {
                P_Section.doReverse();
            }

            return(null);
        }
示例#10
0
        // GENERATE GRID_REPEATER
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            //Debug.Log(parametricObject.Name + " Generate");
            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }

            if (repeaterToolU == null || repeaterToolV == null)
            {
                return(null);
            }

            preGenerate();


            // NODE_MESH
            AXParametricObject nodeSrc_po = null;
            GameObject         nodePlugGO = null;

            if (nodeSrc_p != null)
            {
                nodeSrc_po = nodeSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }


            // CELL_MESH
            AXParametricObject cellSrc_po = null;
            GameObject         cellPlugGO = null;

            if (cellSrc_p != null)
            {
                cellSrc_po = cellSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }

            // BAY_SPAN_U
            AXParametricObject spanUSrc_po = null;
            GameObject         spanUPlugGO = null;

            if (spanUSrc_p != null)
            {
                spanUSrc_po = spanUSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    spanUPlugGO = spanUSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }

            // BAY_SPAN_V
            AXParametricObject spanVSrc_po = null;
            GameObject         spanVPlugGO = null;

            if (spanVSrc_p != null)
            {
                spanVSrc_po = spanVSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    spanVPlugGO = spanVSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }



            if (nodeSrc_po == null && cellSrc_po == null && spanUSrc_po == null && spanVSrc_po == null)
            {
                AXParameter output_p = getPreferredOutputParameter();
                if (output_p != null)
                {
                    output_p.meshes = null;
                }

                return(null);
            }


            GameObject go = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }



            // BOUNDING_SHAPE

            Paths boundingSolids = null;
            Paths boundingHoles  = null;


            if (P_BoundingShape != null && P_BoundingShape.DependsOn != null)
            {
                AXParameter bounding_src_p = null;
                if (P_BoundingShape != null)
                {
                    bounding_src_p = P_BoundingShape.DependsOn;                               // USING SINGLE SPLINE INPUT
                }
                boundingShapeSrc_po = bounding_src_p.parametricObject;

                AXShape.thickenAndOffset(ref P_BoundingShape, bounding_src_p);
                // now boundin_p has offset and thickened polytree or paths.

                boundingSolids = P_BoundingShape.getTransformedSubjPaths();
                boundingHoles  = P_BoundingShape.getTransformedHolePaths();
            }



            List <AXMesh> ax_meshes = new List <AXMesh>();

            Matrix4x4 localPlacement_mx = Matrix4x4.identity;

            // -----------------------------------

            int max_reps = 150;

            int   cellsU     = Mathf.Clamp(repeaterToolU.cells, 1, max_reps);
            float actualBayU = repeaterToolU.actualBay;

            int   cellsV     = Mathf.Clamp(repeaterToolV.cells, 1, max_reps);
            float actualBayV = repeaterToolV.actualBay;

            shiftU = -cellsU * actualBayU / 2;
            shiftV = -cellsV * actualBayV / 2;


            // BAY SPAN
            // Spanners are meshers that get replicated and sized to fit the bay...

            // prepare mesh to iterate in each direction

            //List<AXMesh>  ax_meshes_X         = new List<AXMesh>();
            //List<AXMesh>  ax_meshes_Z         = new List<AXMesh>();



            AXMesh tmpMesh;

            if (spanUSrc_p != null)
            {
                //ax_meshes_X = spanUSrc_p.meshes;
                //ax_meshes_Z = spanUSrc_p.meshes;
            }

            /* NEED TO INTEGRATE THIS BACK IN IN THE FUTRE...
             * if (bay_span_source != null)
             * {
             *
             *      // 1. cache source object
             *      bay_span_source.cacheParameterValues();
             *
             *
             *      // Y_AXIS
             *
             *      AXParameter p_bayv = parametricObject.getParameter("actual_bay_V");
             *      AXParameter p_bayv_client = null;
             *      if (p_bayv != null)
             *      {
             *              foreach (AXRelation rel in p_bayv.relations)
             *              {
             *                      p_bayv_client = rel.getRelatedTo(p_bayv);
             *                      p_bayv_client.intiateRipple_setFloatValueFromGUIChange(abayy);
             *              }
             *      }
             *
             *
             *      AXParameter p_bayu = parametricObject.getParameter("actual_bay_U");
             *      AXParameter p_bayu_client = null;
             *
             *      // X-AXIS
             *      // For now, only set the boundaries.
             *      // Perhaps later, may want to set other like controls as in Replicant
             *
             *      // If there is a relation to actual_bay_U, propogate it
             *      if (p_bayu != null)
             *      {
             *              foreach (AXRelation rel in p_bayu.relations)
             *              {
             *                      p_bayu_client = rel.getRelatedTo(p_bayu);
             *                      p_bayu_client.intiateRipple_setFloatValueFromGUIChange(abayx);
             *              }
             *      }
             *
             *      //bay_span_source.propagateParameterByBinding(1, bayx);
             *      //bay_span_source.propagateParameterByBinding(2, bayy);
             *
             *      // 2. re_generate with temporary values set by this Replicant
             *      bay_span_source.generateOutputNow (makeGameObjects, parametricObject);
             *
             *      // 3. Now that the bay_span_source has been regergrab the meshes from the input sources and add them here
             *      AXParameter output_p = bay_span_source.getParameter("Output Mesh");
             *      foreach (AXMesh amesh in output_p.meshes)
             *              ax_meshes_X.Add (amesh.Clone(amesh.transMatrix));
             *
             *
             *
             *      // Z-AXIS
             *      // Use the bayz now to generate x
             *
             *      if (p_bayu != null)
             *      {
             *              foreach (AXRelation rel in p_bayu.relations)
             *              {
             *                      p_bayu_client = rel.getRelatedTo(p_bayu);
             *                      p_bayu_client.intiateRipple_setFloatValueFromGUIChange(abayz);
             *              }
             *      }
             *
             *      //bay_span_source.propagateParameterByBinding(1, bayz);
             *
             *
             *      // 2. re_generate with temporary values set by this Replicant
             *      bay_span_source.generateOutputNow (makeGameObjects, parametricObject);
             *
             *      // 3. Now that the bay_span_source has been regergrab the meshes from the input sources and add them here
             *      foreach (AXMesh amesh in output_p.meshes)
             *              ax_meshes_Z.Add (amesh.Clone(amesh.transMatrix));
             *
             *
             *      // 4. restore source object; as though we were never here!
             *      bay_span_source.revertParametersFromCache();
             *
             *      //Debug.Log ("HAVE BAY SPAN -- " + output_p.meshes.Count);
             *
             *
             * }
             */


            /* NEED TO INTEGRATE THIS BACK IN IN THE FUTRE...
             * if (cell_center_source != null)
             * {
             *      // Y-AXIS
             *      // For now, only set the boundaries.
             *      // Perhaps later, may want to set other like controls as in Replicant
             *      // 1. cache source object
             *      cell_center_source.cacheParameterValues();
             *
             *
             *
             *      //bay_center_source.propagateParameterByBinding(1, bayx);
             *      //bay_center_source.propagateParameterByBinding(3, bayz);
             *
             *      // 2. re_generate with temporary values set by this Replicant
             *      cell_center_source.generateOutputNow (makeGameObjects, parametricObject);
             *
             *      // 3. Now that the bay_span_source has been regenerted,  grab the meshes from the input sources and add them here
             *      AXParameter bc_output_p = cell_center_source.getParameter("Output Mesh");
             *      foreach (AXMesh amesh in bc_output_p.meshes)
             *              ax_meshes_Y.Add (amesh.Clone(amesh.transMatrix));
             *
             *      // 4. restore source object; as though we were never here!
             *      cell_center_source.revertParametersFromCache();
             *
             * }
             */



            // BOUNDING

            List <AXMesh> boundingMeshes = new List <AXMesh>();



            for (int i = 0; i <= cellsU; i++)
            {
                for (int k = 0; k <= cellsV; k++)
                {
                    bool exclude = false;

                    IntPoint ip = new IntPoint((i * actualBayU + shiftU) * AXGeometryTools.Utilities.IntPointPrecision, (k * actualBayV + shiftV) * AXGeometryTools.Utilities.IntPointPrecision);

                    if (boundingSolids != null)
                    {
                        exclude = true;

                        if (boundingSolids != null)
                        {
                            foreach (Path path in boundingSolids)
                            {
                                if (Clipper.PointInPolygon(ip, path) == 1 && Clipper.Orientation(path))
                                {
                                    exclude = false;
                                    break;
                                }
                            }
                        }

                        if (boundingHoles != null)
                        {
                            foreach (Path hole in boundingHoles)
                            {
                                if (Clipper.PointInPolygon(ip, hole) == 1)
                                {
                                    exclude = true;
                                    break;
                                }
                            }
                        }
                    }


                    exclude = (boundingIsVoid) ? !exclude : exclude;

                    if (exclude)
                    {
                        continue;
                    }


                    // NODES
                    if (nodeSrc_po != null && nodeSrc_p.meshes != null && ((i <= repeaterToolU.edgeCount || i >= cellsU - repeaterToolU.edgeCount) || (k <= repeaterToolV.edgeCount || k >= cellsV - repeaterToolV.edgeCount)))
                    {
                        string this_address = "node_" + i + "_" + k;

                        // LOCAL PLACEMENT NODE
                        localPlacement_mx = localNodeMatrixFromAddress(i, k);


                        // AX_MESHES

                        for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++)
                        {
                            AXMesh dep_amesh = nodeSrc_p.meshes [mi];
                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }



                        // BOUNDING
                        boundingMeshes.Add(new AXMesh(nodeSrc_po.boundsMesh, localPlacement_mx * nodeSrc_po.generator.localMatrix));


                        // GAME_OBJECTS

                        if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            Matrix4x4  mx     = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                            copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);

                                                        #if UNITY_EDITOR
                            //if (parametricObject.model.isSelected(nodeSrc_po) && nodeSrc_po.selectedConsumerAddress == this_address)
                            //	Selection.activeGameObject = copyGO;
                                                        #endif

                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = go.transform;
                        }
                    }                     // \NODES



                    // CELL CENTERS
                    if (cellSrc_po != null && cellSrc_p.meshes != null && i < cellsU && k < cellsV && ((i < repeaterToolU.edgeCount || i > cellsU - repeaterToolU.edgeCount - 1) || (k < repeaterToolV.edgeCount || k > cellsV - repeaterToolV.edgeCount - 1)))
                    {
                        string this_address = "cell_" + i + "_" + k;

                        // LOCAL PLACEMENT

                        localPlacement_mx = localCellMatrixFromAddress(i, k);


                        // AX_MESHES

                        for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++)
                        {
                            AXMesh dep_amesh = cellSrc_p.meshes [mi];
                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }


                        // BOUNDING
                        boundingMeshes.Add(new AXMesh(cellSrc_po.boundsMesh, localPlacement_mx * cellSrc_po.generator.localMatrix));



                        // GAME_OBJECTS

                        if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            Matrix4x4  mx     = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                            copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);

                                                        #if UNITY_EDITOR
                            //if (parametricObject.model.isSelected(cellSrc_po) && cellSrc_po.selectedConsumerAddress == this_address)
                            //Selection.activeGameObject = copyGO;
                                                        #endif

                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = go.transform;
                        }
                    }



                    // SPAN_U
                    if (spanUSrc_po != null && spanUSrc_p.meshes != null && i < cellsU && k <= cellsV && ((i < repeaterToolV.edgeCount || i > cellsU - repeaterToolU.edgeCount - 1) || (k <= repeaterToolV.edgeCount || k > cellsV - repeaterToolV.edgeCount - 1)))
                    {
                        string this_address = "spanU_" + i + "_" + k;

                        // LOCAL PLACEMENT SPAN_U

                        localPlacement_mx = localSpanUMatrixFromAddress(i, k);


                        // AX_MESHES

                        for (int mi = 0; mi < spanUSrc_p.meshes.Count; mi++)
                        {
                            AXMesh dep_amesh = spanUSrc_p.meshes [mi];
                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }


                        // BOUNDING
                        boundingMeshes.Add(new AXMesh(spanUSrc_po.boundsMesh, localPlacement_mx * spanUSrc_po.generator.localMatrix));



                        // GAME_OBJECTS

                        if (spanUSrc_po != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            Matrix4x4  mx     = localPlacement_mx * spanUSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            GameObject copyGO = (GameObject)GameObject.Instantiate(spanUPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));


                            copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);

                                                        #if UNITY_EDITOR
                            //if (parametricObject.model.isSelected(spanUSrc_po) && spanUSrc_po.selectedConsumerAddress == this_address)
                            //	Selection.activeGameObject = copyGO;
                                                        #endif

                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = go.transform;
                        }
                    }

                    // SPAN_V
                    if (spanVSrc_po != null && spanVSrc_p.meshes != null && i <= cellsU && k < cellsV && ((i <= repeaterToolU.edgeCount || i > cellsU - repeaterToolU.edgeCount - 1) || (k < repeaterToolV.edgeCount || k > cellsV - repeaterToolV.edgeCount - 1)))
                    {
                        string this_address = "spanV_" + i + "_" + k;

                        // LOCAL PLACEMENT SPAN_U
                        localPlacement_mx = localSpanVMatrixFromAddress(i, k);



                        // AX_MESHES

                        for (int mi = 0; mi < spanVSrc_p.meshes.Count; mi++)
                        {
                            AXMesh dep_amesh = spanVSrc_p.meshes [mi];
                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }



                        // BOUNDING
                        boundingMeshes.Add(new AXMesh(spanVSrc_po.boundsMesh, localPlacement_mx * spanVSrc_po.generator.localMatrix));



                        // GAME_OBJECTS

                        if (spanVSrc_po != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            Matrix4x4  mx     = localPlacement_mx * spanVSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            GameObject copyGO = (GameObject)GameObject.Instantiate(spanVPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));


                            copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);

                                                        #if UNITY_EDITOR
                            //if (parametricObject.model.isSelected(spanVSrc_po) && spanVSrc_po.selectedConsumerAddress == this_address)
                            //	Selection.activeGameObject = copyGO;
                                                        #endif

                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = go.transform;
                        }
                    }
                }         // k
            }             //i


            GameObject.DestroyImmediate(nodePlugGO);
            GameObject.DestroyImmediate(cellPlugGO);
            GameObject.DestroyImmediate(spanUPlugGO);
            GameObject.DestroyImmediate(spanVPlugGO);



            // FINISH AX_MESHES

            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);



            // FINISH BOUNDS

            CombineInstance[] boundsCombinator = new CombineInstance[boundingMeshes.Count];
            for (int bb = 0; bb < boundsCombinator.Length; bb++)
            {
                boundsCombinator[bb].mesh      = boundingMeshes[bb].mesh;
                boundsCombinator[bb].transform = boundingMeshes[bb].transMatrix;
            }
            setBoundsWithCombinator(boundsCombinator);



            // FINISH GAME_OBJECTS

            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true);
                }

                Matrix4x4 tmx = parametricObject.generator.localMatrixWithAxisRotationAndAlignment;

                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScaleAxisRotated();

                return(go);
            }

            return(null);
        }
示例#11
0
        // GROUPER::GENERATE
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool renderToOutputParameter)
        {
            //if (ArchimatixUtils.doDebug)
            //Debug.Log (parametricObject.Name + " generate +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

            if (! parametricObject.isActive)
                return null;

            if (parametricObject.prefab == null)
                return null;

            preGenerate();

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

            Transform[] transforms = parametricObject.prefab.GetComponentsInChildren<Transform>();

            //Debug.Log("transforms: " + transforms.Length);
            for(int i=0; i<transforms.Length; i++)
            {
                MeshFilter mf = transforms[i].gameObject.GetComponent<MeshFilter>();
                Debug.Log("mf="+mf);
                if (mf != null)
                {
                    Material mater = AXModel.defaultMaterial;

                    Renderer renderer = transforms[i].gameObject.GetComponent<Renderer>();
                    if (renderer != null)
                         mater = renderer.sharedMaterial;

                    ax_meshes.Add (new AXMesh (mf.sharedMesh, transforms[i].localToWorldMatrix, mater));

                }
            }

            //Debug.Log("ax_meshes: " + ax_meshes.Count);

            CombineInstance[] boundsCombinator = new CombineInstance[ax_meshes.Count];
            int boundingCursor = 0;

            for(int i=0; i<ax_meshes.Count; i++)
            {
                boundsCombinator[boundingCursor].mesh 		= ax_meshes[i].mesh;
                boundsCombinator[boundingCursor].transform 	= ax_meshes[i].drawMeshMatrix;// localPlacement_mx * tmpSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                boundingCursor++;
            }
            setBoundsWithCombinator(boundsCombinator);

            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, renderToOutputParameter);

            // GAME_OBJECTS

            if (makeGameObjects)
            {
                GameObject go = GameObject.Instantiate( parametricObject.prefab);

                Transform[] ntransforms = go.GetComponentsInChildren<Transform>();
                for(int i=0; i<ntransforms.Length; i++)
                {
                    ArchimatixUtils.AddAXGameObjectTo(parametricObject, ntransforms[i].gameObject);
                }

                //GameObject go = ArchimatixUtils.createAXGameObjectFromPrefab(parametricObject, parametricObject.prefab);

                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                //Debug.Log(tmx);
                go.transform.rotation 		= AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position 		= AXUtilities.GetPosition(tmx);
                go.transform.localScale 	= parametricObject.getLocalScaleAxisRotated();
                return go;
            }
            return null;
        }
示例#12
0
        // GENERATE LINEAR_REPEATER
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            //Debug.Log("repeaterToolU="+repeaterToolU+", repeaterToolV="+repeaterToolV);
            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }

            if (repeaterTool == null)
            {
                return(null);
            }


            preGenerate();



            // FLOOR_MESH (NODE_MESH)
            AXParametricObject nodeSrc_po = null;
            GameObject         nodePlugGO = null;

            //Debug.Log("Get source");
            if (nodeSrc_p != null)
            {
                nodeSrc_po = nodeSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }



            // STORY MESH (CELL_MESH)
            AXParametricObject storySrc_po = null;
            GameObject         storyPlugGO = null;

            if (storySrc_p != null)
            {
                storySrc_po = storySrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    storyPlugGO = storySrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }

            // TOP_FLOOR
            AXParametricObject topSrc_po = null;
            GameObject         topPlugGO = null;

            if (topSrc_p != null)
            {
                topSrc_po = topSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    topPlugGO = topSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }
            // BOTTOM_FLOOR
            AXParametricObject bottomSrc_po = null;
            GameObject         bottomPlugGO = null;

            if (bottomSrc_p != null)
            {
                bottomSrc_po = bottomSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    bottomPlugGO = bottomSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }



            if (nodeSrc_po == null && storySrc_po == null && topSrc_po == null && bottomSrc_po == null)
            {
                if (P_Output != null)
                {
                    P_Output.meshes = null;
                }

                return(null);
            }


            GameObject go = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }



            List <AXMesh> ax_meshes = new List <AXMesh>();

            Matrix4x4 localPlacement_mx = Matrix4x4.identity;

            // -----------------------------------


            int max_reps = 150;

            int   cellsU     = Mathf.Clamp(repeaterTool.cells, 1, max_reps);
            float actualBayU = repeaterTool.actualBay;

            shiftU = -cellsU * actualBayU / 2;

            AXMesh tmpMesh;



            // BAY SPAN
            // Spanners are meshers that get replicated and sized to fit the bay...

            // prepare mesh to iterate in each direction



            // BOUNDING

            int boundingObjectCount = 0;

            if (nodeSrc_po != null && nodeSrc_p.meshes != null)
            {
                boundingObjectCount += cellsU + 1;

                if (!topFloor)
                {
                    boundingObjectCount--;
                }

                if (!bottomFloor)
                {
                    boundingObjectCount--;
                }
            }

            if (storySrc_p != null && storySrc_p.meshes != null)
            {
                boundingObjectCount += cellsU;

                if (!topStory)
                {
                    boundingObjectCount--;
                }

                if (!bottomStory)
                {
                    boundingObjectCount--;
                }
            }

            //Debug.Log(cellsU + " :::::: " + boundingObjectCount);

            CombineInstance[] boundsCombinator = new CombineInstance[boundingObjectCount];
            int boundingCursor = 0;

            // LOOP
            for (int i = 0; i <= cellsU; i++)
            {
                // FLOORS (NODES)
                if ((i == 0 && bottomFloor) || (i == cellsU && topFloor) || (i > 0 && i < cellsU))
                {
                    AXParameter        tmpSrc_p  = nodeSrc_p;
                    AXParametricObject tmpSrc_po = nodeSrc_po;
                    GameObject         tmpPlugGO = nodePlugGO;
                    if (i == 0 && bottomSrc_p != null)
                    {
                        tmpSrc_p  = bottomSrc_p;
                        tmpSrc_po = bottomSrc_po;
                        tmpPlugGO = bottomPlugGO;
                    }
                    else if (i == cellsU && topSrc_p != null)
                    {
                        tmpSrc_p  = topSrc_p;
                        tmpSrc_po = topSrc_po;
                        tmpPlugGO = topPlugGO;
                    }

                    if (tmpSrc_po != null && tmpSrc_p.meshes != null)
                    {
                        string this_address = "node_" + i;



                        localPlacement_mx = localNodeMatrixFromAddress(i);


                        // AX_MESHES

                        for (int j = 0; j < tmpSrc_p.meshes.Count; j++)
                        {
                            AXMesh dep_amesh = tmpSrc_p.meshes [j];

                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }



                        // BOUNDING MESHES

                        boundsCombinator[boundingCursor].mesh      = tmpSrc_po.boundsMesh;
                        boundsCombinator[boundingCursor].transform = localPlacement_mx * tmpSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                        boundingCursor++;


                        // GAME_OBJECTS

                        if (tmpPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            //Matrix4x4 mx = localPlacement_mx  * parametricObject.getTransMatrix() * source.getTransMatrix();

                            //Debug.Log(nodeSrc_po.getLocalMatrix());
                            Matrix4x4  mx     = localPlacement_mx * tmpSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            GameObject copyGO = (GameObject)GameObject.Instantiate(tmpPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                            copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);



                                                        #if UNITY_EDITOR
                            //if (parametricObject.model.isSelected(tmpSrc_po) && tmpSrc_po.selectedConsumerAddress == this_address)
                            //	Selection.activeGameObject = copyGO;
                                                        #endif


                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = go.transform;
                        }
                    }                     // \NODES
                }



                // STORIES (CELLS)
                if ((i == 0 && bottomStory) || (i == cellsU - 1 && topStory) || (i > 0 && i < cellsU - 1))
                {
                    if (storySrc_p != null && storySrc_p.meshes != null && i < cellsU)
                    {
                        string this_address = "cell_" + i;


                        // LOCAL_PLACEMENT
                        localPlacement_mx = localCellMatrixFromAddress(i);


                        // AX_MESHES

                        for (int j = 0; j < storySrc_p.meshes.Count; j++)
                        {
                            AXMesh dep_amesh = storySrc_p.meshes [j];
                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }



                        // BOUNDING MESHES
                        if (boundsCombinator.Length > boundingCursor)
                        {
                            boundsCombinator[boundingCursor].mesh      = storySrc_po.boundsMesh;
                            boundsCombinator[boundingCursor].transform = localPlacement_mx * storySrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            boundingCursor++;
                        }


                        // GAME_OBJECTS

                        if (storyPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            //Matrix4x4 mx = localPlacement_mx  * parametricObject.getTransMatrix() * source.getTransMatrix();
                            Matrix4x4  mx     = localPlacement_mx * storySrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                            GameObject copyGO = (GameObject)GameObject.Instantiate(storyPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = go.transform;
                        }
                    }     // \ STORIES (CELLS)
                }
            }             //i


            GameObject.DestroyImmediate(nodePlugGO);
            GameObject.DestroyImmediate(storyPlugGO);
            GameObject.DestroyImmediate(topPlugGO);
            GameObject.DestroyImmediate(bottomPlugGO);

            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);

            setBoundsWithCombinator(boundsCombinator);

            // Turn ax_meshes into GameObjects
            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true);
                }

                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScaleAxisRotated();                        //AXUtilities.GetScale(tmx);

                return(go);
            }


            return(null);
        }
示例#13
0
        // Maintain a AXHandle.GUID
        // and any other runtime preferences



        public static void OnGUI(AXHandleRuntimeAlias rth)
        {
            AXHandle handle = rth.handle;

            if (handle == null)
            {
                return;
            }

            //Event e = Event.current;

            GUILayout.BeginHorizontal();



            // FOLDOUT

            GUIStyle toggleStyle = new GUIStyle(EditorStyles.foldout);

            toggleStyle.fixedWidth = 50;

            rth.isEditing = EditorGUILayout.Foldout(rth.isEditing, GUIContent.none);

            //Debug.Log(pa.isEditing);
            // SLIDER AND NUMBER FIELD

            GUIStyle textfieldStyle = new GUIStyle(GUI.skin.textField);

            textfieldStyle.fixedWidth = 150;



            GUIStyle labelWrap = new GUIStyle(GUI.skin.label);

            labelWrap.stretchWidth = true;
            labelWrap.wordWrap     = true;
            labelWrap.fontSize     = 9;
            labelWrap.fixedWidth   = 150;
            if (rth.isEditing)
            {
                GUILayout.BeginVertical();

                rth.alias = GUILayout.TextField(rth.alias, textfieldStyle);

                GUILayout.Label("You can edit the alias without altering the source handle.", labelWrap);

                GUILayout.Label("Actual: ", labelWrap);
                if (GUILayout.Button(handle.parametricObject.Name + "." + handle.Name))
                {
                    handle.parametricObject.model.selectPO(handle.parametricObject);
                    //handle.ParentNode.isOpen = true;

                    float framePadding = 200;

                    Rect allRect = AXUtilities.getBoundaryRectFromPOs(handle.parametricObject.model.selectedPOs);
                    allRect.x      -= framePadding;
                    allRect.y      -= framePadding;
                    allRect.width  += framePadding * 2;
                    allRect.height += framePadding * 2;

                    AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                }


                GUILayout.Space(15);
                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.Label(rth.alias);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }         // OnGUI()
示例#14
0
        // GENERATE
        // This is the main function for generating a Shape, Mesh, or any other output that a node may be tasked with generating.
        // You can do pre processing of Inputs here, but that might best be done in an override of pollControlValuesFromParmeters().
        //
        // Often, you will be creating a list of AXMesh objects. AXMesh has a Mesh, a Matrix4x4 and a Material
        // to be used when drawing the ouput to the scene before creating GameObjects. Your list of AXMeshes generated
        // is pased to the model via parametricObject.finishMultiAXMeshAndOutput().
        //
        // When generate() is called by AX, it will be either with makeGameObjects set to true or false.
        // makeGameObjects=False is passed when the user is dragging a parameter and the model is regenerateing multiple times per second.
        // makeGameObjects=True is passed when the user has stopped editing (for example, OnMouseup from a Handle) and it is time to
        // build a GameObject hierarchy.

        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            if (parametricObject == null || !parametricObject.hasInputMeshReady("Input Mesh"))
            {
                return(null);
            }

            // At this point the amount variable has been set to the FloatValue of its amount parameter.
            preGenerate();


            //Vector3 center = Vector3.zero;

            // AXMeshes are the key product of a Generator3D
            List <AXMesh> ax_meshes = new List <AXMesh>();

            AXParameter        inputSrc_p  = P_Input.DependsOn;
            AXParametricObject inputSrc_po = inputSrc_p.parametricObject;


//			GameObject go       = null;
//			if (makeGameObjects && ! parametricObject.combineMeshes)
//				go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);


            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                GameObject GOsToDeformPlug = inputSrc_po.generator.generate(true, initiator_po, isReplica);

                modifyGameObject(GOsToDeformPlug, Matrix4x4.identity);


                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                GOsToDeformPlug.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                GOsToDeformPlug.transform.position   = AXUtilities.GetPosition(tmx);
                GOsToDeformPlug.transform.localScale = parametricObject.getLocalScaleAxisRotated();                   //AXUtilities.GetScale(tmx);

                return(GOsToDeformPlug);
            }
            else
            {
                // COMBINE

                if (inputSrc_p != null && inputSrc_p.meshes != null)                  // Is there an input node connected to this node?
                {
                    //Debug.Log("P_Input.DependsOn.meshes.Count="+P_Input.DependsOn.meshes.Count + ", "+ P_Input.DependsOn.meshes[0].GetType());
                    AXMesh amesh = null;


                    // EACH MESH
                    for (int i = 0; i < P_Input.DependsOn.meshes.Count; i++)
                    {
                        // Instance does not inhereit and build on the transform of its source object.
                        amesh = P_Input.DependsOn.meshes [i].Clone();
                        Mesh      m     = amesh.mesh;
                        Vector3[] verts = m.vertices;


                        // ---------- EACH VERTEX ----------------------
                        for (int j = 0; j < verts.Length; j++)
                        {
                            Vector3 vert = new Vector3(verts[j].x, verts[j].y, verts[j].z);

                            vert = P_Input.DependsOn.meshes[i].drawMeshMatrix.MultiplyPoint3x4(vert);

                            float scale = 1;

                            if (modifierCurve != null)
                            {
                                scale = modifierCurve.Evaluate(vert.y) * (1 - (amount * vert.y));
                            }


                            vert = new Vector3(vert.x * scale, vert.y, vert.z * scale);

//							Vector3 n = -vert.normalized;
//							n *= scale;
//							vert = vert + n;

                            verts [j] = P_Input.DependsOn.meshes[i].drawMeshMatrix.inverse.MultiplyPoint3x4(vert);
                        }
                        // ---------- EACH VERTEX ----------------------


                        m.vertices = verts;
                        //}
                        ax_meshes.Add(amesh);
                    }

                    parametricObject.bounds = inputSrc_po.bounds;
                    parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);

                    if (makeGameObjects)
                    {
                        if (parametricObject.combineMeshes)
                        {
                            return(parametricObject.makeGameObjectsFromAXMeshes(ax_meshes));
                        }
                    }
                }
            }

            return(null);
        }
示例#15
0
        // GENERATE REPLICANT
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool renderToOutputParameter)
        {
            //Debug.Log ("===> " + parametricObject.Name + " generate");

            if (parametricObject == null || !parametricObject.hasInputMeshReady("Input Mesh"))
            {
                return(null);
            }

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

            preGenerate();

            AXParameter input_p = parametricObject.getParameter("Input Mesh");

            if (parametricObject == null || input_p == null || input_p.DependsOn == null)
            {
                return(null);
            }

            AXParametricObject src_po = input_p.DependsOn.Parent;

            if (src_po == null)
            {
                return(null);
            }

            Matrix4x4 srcLocalM = src_po.getLocalMatrix().inverse;


            // 1. cache source object
            List <AXParameter> geometryControlParameterList = parametricObject.getAllParametersOfPType(AXParameter.ParameterType.GeometryControl);

            src_po.cacheAndSetParameters(geometryControlParameterList);

            if (!makeGameObjects)
            {
                // 2. re_generate source PO with temporary values set by this Replicant
                src_po.generateOutputNow(false, parametricObject, false);

                // 3. Now that the input_sourcePO has been regenerated,
                //    grab the temporaryOutputMeshes meshes
                //    from the input sources and add them here
                List <AXMesh> ax_meshes = new List <AXMesh>();
                if (src_po.temporaryOutputMeshes != null)
                {
                    for (int mi = 0; mi < src_po.temporaryOutputMeshes.Count; mi++)
                    {
                        AXMesh amesh = src_po.temporaryOutputMeshes [mi];
                        ax_meshes.Add(amesh.Clone(srcLocalM * amesh.transMatrix));
                    }
                }
                parametricObject.finishMultiAXMeshAndOutput(ax_meshes);

                setBoundaryFromAXMeshes(ax_meshes);
            }
            // 4. Make GAME OBJECTS
            GameObject go = null;

            if (makeGameObjects)
            {
                go      = src_po.generator.generate(true, initiator_po, false);
                go.name = src_po.Name + " Replicant";
                AXGameObject axgo = go.GetComponent <AXGameObject>();
                if (axgo != null)
                {
                    axgo.makerPO_GUID = parametricObject.Guid;
                }
            }



            //  5. restore source object; as though we were never here!
            src_po.revertParametersFromCache();


            // Turn ax_meshes into GameObjects
            if (makeGameObjects)
            {
                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScaleAxisRotated();

                return(go);
            }

            return(null);
        }
示例#16
0
        // GENERATE PAIR_REPEATER
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            //Debug.Log ("PairRepeater::Generate ");
            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }

            preGenerate();

            if ((nodeSrc_p == null || nodeSrc_p.meshes == null || nodeSrc_p.meshes.Count == 0) && (nodeSrc_po != null && !(nodeSrc_po.generator is PrefabInstancer)))
            {
                return(null);
            }


            if (P_Node == null || P_Node.DependsOn == null)
            {
                return(null);
            }

            GameObject go = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }


            List <AXMesh> ax_meshes = new List <AXMesh>();

            GameObject plugGO = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                plugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica);


                if (plugGO == null)
                {
                    return(null);
                }
            }



            float separationX = zAxis ? 0 : separation;
            float separationZ = zAxis ? -separation : 0;


            CombineInstance[] boundsCombinator = new CombineInstance[2];



            // * RIGHT INSTANCE	*
            // --------------------------------------------------------------------


            // Right Instance is at Address 0...
            Matrix4x4 localPlacement_mx = localNodeMatrixFromAddress(0);

            // use submeshes for right instance

            // AX_MESHES

            for (int mi = 0; mi < P_Node.DependsOn.meshes.Count; mi++)
            {
                AXMesh dep_amesh = P_Node.DependsOn.meshes [mi];
                ax_meshes.Add(dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix));
            }


            // BOUNDING MESHES

            boundsCombinator[0].mesh      = nodeSrc_po.boundsMesh;
            boundsCombinator[0].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;



            // GAME_OBJECTS

            if (plugGO != null && makeGameObjects && !parametricObject.combineMeshes)
            {
                Matrix4x4  mx     = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                GameObject copyGO = (GameObject)GameObject.Instantiate(plugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));
                copyGO.transform.localScale = nodeSrc_po.getLocalScaleAxisRotated();

                AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                if (axgo != null)
                {
                    axgo.consumerAddress = "node_0";
                }


                copyGO.name             = copyGO.name + "_node_right";
                copyGO.transform.parent = go.transform;
            }



            // * INVERSE (LEFT) INSTANCE
            // --------------------------------------------------------------------

            // ***--- AX_MESHES - INVERSE (LEFT) ---***



            translate = new Vector3(-separationX / 2, 0, -separationZ / 2);

            // LOCAL PLACEMENT
            localPlacement_mx = localNodeMatrixFromAddress(1);

            // use submeshes for left instance
            for (int mi = 0; mi < P_Node.DependsOn.meshes.Count; mi++)
            {
                // CLONE
                AXMesh dep_amesh = P_Node.DependsOn.meshes [mi];
                AXMesh clone     = dep_amesh.Clone();
                // SYMETRICAL?
                if (symmetrical)
                {
                    clone.mesh        = AXMesh.freezeWithMatrix(dep_amesh.mesh, symmetryM * dep_amesh.transMatrix);
                    clone.transMatrix = localPlacement_mx * symmetryM.inverse;
                }
                else
                {
                    clone = dep_amesh.Clone(localPlacement_mx * symmetryM.inverse * dep_amesh.transMatrix);
                }
                // ADD TO AX_MESHES
                ax_meshes.Add(clone);
            }



            // BOUNDING MESHES

            boundsCombinator[1].mesh      = nodeSrc_po.boundsMesh;
            boundsCombinator[1].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;



            //   *** --- INVERSE (LEFT) - GAME_OBJECT ---**
            if (plugGO != null && makeGameObjects && !parametricObject.combineMeshes)
            {
                // LOCAL PLACEMENT
                //Matrix4x4 mx = localPlacement_mx  * symmetryM * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;



                // GAME_OBJECT
                GameObject copyGO = (GameObject)GameObject.Instantiate(plugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));
                copyGO.transform.localScale = nodeSrc_po.getLocalScaleAxisRotated();

                // SYMETRICAL?
                if (symmetrical)
                {
                    copyGO.transform.localScale = copyGO.transform.localScale * -1;
                    if (zAxis)
                    {
                        copyGO.transform.Rotate(0, 180, 180);
                    }
                    else
                    {
                        copyGO.transform.Rotate(180, 0, 0);
                    }
                }


                // Force a refreshing of the colliders down the instatiatined hierachy
                // Based on a solution provided by pkamat here:http://forum.unity3d.com/threads/how-to-update-a-mesh-collider.32467/

                foreach (MeshCollider mc in copyGO.GetComponentsInChildren <MeshCollider>())
                {
                    mc.sharedMesh = null;
                    mc.sharedMesh = mc.gameObject.GetComponent <MeshFilter>().sharedMesh;
                }


                // ADD GAME_OBJECT
                AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                if (axgo != null)
                {
                    axgo.consumerAddress = "node_1";
                }

                copyGO.name             = copyGO.name + "_node_left";
                copyGO.transform.parent = go.transform;
            }



            GameObject.DestroyImmediate(plugGO);



            // COMBINE ALL THE MESHES
            CombineInstance[] combine = new CombineInstance[ax_meshes.Count];

            int combineCt = 0;

            for (int i = 0; i < ax_meshes.Count; i++)
            {
                AXMesh _amesh = ax_meshes [i];
                combine [combineCt].mesh      = _amesh.mesh;
                combine [combineCt].transform = _amesh.transMatrix;
                combineCt++;
            }
            Mesh combinedMesh = new Mesh();

            combinedMesh.CombineMeshes(combine);
            combinedMesh.RecalculateBounds();

            // BOUNDARY - Use combined meshes for boundary
            setBoundsWithCombinator(boundsCombinator);

            /*
             * // BOUNDS & CENTER
             *
             * Vector3 margin = new Vector3(source_po.bounds.size.x, source_po.bounds.size.y, source_po.bounds.size.z);
             * Bounds b = new Bounds();
             * b.size = new Vector3(separationX + margin.x, margin.y, separationZ + margin.z);
             * b.extents = b.size/2;
             * b.center = source_po.bounds.center;// + new Vector3(0, b.extents.y, 0);
             *
             * parametricObject.margin = margin;
             * parametricObject.bounds = b;
             */

            // FINISH
            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);


            // Turn ax_meshes into GameObjects
            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true, false);

                    // If combine, use combined mesh as invisible collider
                    MeshFilter mf = (MeshFilter)go.GetComponent(typeof(MeshFilter));
                    if (mf == null)
                    {
                        mf = (MeshFilter)go.AddComponent(typeof(MeshFilter));
                    }
                    if (mf != null)
                    {
                        mf.sharedMesh = combinedMesh;

                        parametricObject.addCollider(go);
                    }
                }

                //Matrix4x4 tmx = parametricObject.generator.localMatrix;
                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScaleAxisRotated();



                return(go);
            }


            return(null);
        }
示例#17
0
        // GROUPER::GENERATE
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            //if (ArchimatixUtils.doDebug)
            //Debug.Log (parametricObject.Name + " generate +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");


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



            preGenerate();


            GameObject go = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }


            List <AXMesh> ax_meshes = new List <AXMesh>();


            // BOUNDING

            List <AXMesh> boundingMeshes = new List <AXMesh>();



            // Reinstate the original functionality of the Grouper as simple combiner in addition to Groupees.
            if (inputs != null && inputs.Count > 0)
            {
                // ALL
                if (channel == inputs.Count)
                {
                    for (int i = 0; i < inputs.Count; i++)
                    {
                        if (inputs[i] != null && inputs[i].DependsOn != null)
                        {
                            if (inputs[i].Dependents != null || inputs[i].Dependents.Count == 0)
                            {
                                AXParameter        src_p  = inputs[i].DependsOn;
                                AXParametricObject src_po = inputs[i].DependsOn.parametricObject;
                                //if (! parametricObject.visited_pos.Contains (groupee))

                                //Debug.Log("groupee.generateOutputNow: " + groupee.Name + " isAltered="+groupee.isAltered);
                                if (src_po.isAltered)
                                {
                                    src_po.generateOutputNow(makeGameObjects, initiator_po);
                                    //Debug.Log("XXXXX: " + groupee.Output.meshes.Count);
                                    src_po.isAltered = false;
                                    parametricObject.model.AlteredPOs.Remove(src_po);
                                }

                                if (src_p != null && src_p.meshes != null)
                                {
                                    for (int j = 0; j < src_p.meshes.Count; j++)
                                    {
                                        AXMesh dep_amesh = src_p.meshes [j];
                                        ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix));
                                    }
                                }

                                // BOUNDING MESHES
                                //boundsCombinator[i].mesh      = input_p.DependsOn.parametricObject.boundsMesh;
                                //boundsCombinator[i].transform     = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment;
                                if (src_po.boundsMesh != null)
                                {
                                    boundingMeshes.Add(new AXMesh(src_po.boundsMesh, src_po.generator.localMatrixWithAxisRotationAndAlignment));
                                }



                                // GAME_OBJECTS

                                if (makeGameObjects && !parametricObject.combineMeshes)
                                {
                                    GameObject plugGO = src_po.generator.generate(true, initiator_po, isReplica);
                                    if (plugGO != null)
                                    {
                                        plugGO.transform.parent = go.transform;
                                    }
                                }
                            }
                        }
                    }
                }



                // JUST ONE CHANNEL
                else if (inputs.Count > channel && inputs[channel] != null)
                {
                    AXParameter src_p = inputs[channel].DependsOn;

                    if (src_p != null)
                    {
                        AXParametricObject src_po = src_p.parametricObject;

                        if (src_po.is3D())
                        {
                            if (src_po.Output != null && src_po.Output.meshes != null)
                            {
                                for (int j = 0; j < src_po.Output.meshes.Count; j++)
                                {
                                    AXMesh dep_amesh = src_po.Output.meshes [j];
                                    ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix));
                                }
                            }


                            // BOUNDING MESHES
                            //boundsCombinator[i].mesh      = input_p.DependsOn.parametricObject.boundsMesh;
                            //boundsCombinator[i].transform     = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment;
                            if (src_po.boundsMesh != null)
                            {
                                boundingMeshes.Add(new AXMesh(src_po.boundsMesh, src_po.generator.localMatrixWithAxisRotationAndAlignment));
                            }


                            // GAME_OBJECTS

                            if (makeGameObjects && !parametricObject.combineMeshes)
                            {
                                GameObject plugGO = src_po.generator.generate(true, initiator_po, isReplica);
                                if (plugGO != null)
                                {
                                    plugGO.transform.parent = go.transform;
                                }
                            }
                        }



                        P_Output.meshes = src_p.meshes;
                    }
                }


                // FINISH AX_MESHES


                //Debug.Log("ORG: " + ax_meshes.Count);
                parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);



                // FINISH BOUNDS

                CombineInstance[] boundsCombinator = new CombineInstance[boundingMeshes.Count];
                for (int bb = 0; bb < boundsCombinator.Length; bb++)
                {
                    boundsCombinator[bb].mesh      = boundingMeshes[bb].mesh;
                    boundsCombinator[bb].transform = boundingMeshes[bb].transMatrix;
                }
                setBoundsWithCombinator(boundsCombinator);


                if (P_BoundsX != null && !P_BoundsX.hasRelations() && !P_BoundsX.hasExpressions())
                {
                    P_BoundsX.FloatVal = parametricObject.bounds.size.x;
                }

                if (P_BoundsY != null && !P_BoundsY.hasRelations() && !P_BoundsY.hasExpressions())
                {
                    P_BoundsY.FloatVal = parametricObject.bounds.size.y;
                }

                if (P_BoundsZ != null && !P_BoundsZ.hasRelations() && !P_BoundsZ.hasExpressions())
                {
                    P_BoundsZ.FloatVal = parametricObject.bounds.size.z;
                }
            }



            // FINISH GAME_OBJECTS

            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true, false);


                    // COMBINE ALL THE MESHES
                    CombineInstance[] combine = new CombineInstance[ax_meshes.Count];

                    int combineCt = 0;
                    for (int i = 0; i < ax_meshes.Count; i++)
                    {
                        AXMesh _amesh = ax_meshes [i];
                        combine [combineCt].mesh      = _amesh.mesh;
                        combine [combineCt].transform = _amesh.transMatrix;
                        combineCt++;
                    }

                    Mesh combinedMesh = new Mesh();
                    combinedMesh.CombineMeshes(combine);

                    // If combine, use combined mesh as invisible collider
                    MeshFilter mf = (MeshFilter)go.GetComponent(typeof(MeshFilter));

                    if (mf == null)
                    {
                        mf = (MeshFilter)go.AddComponent(typeof(MeshFilter));
                    }

                    if (mf != null)
                    {
                        mf.sharedMesh = combinedMesh;
                        parametricObject.addCollider(go);
                    }
                }

                else
                {
                    Matrix4x4 tmx = parametricObject.getLocalMatrix();

                    go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                    go.transform.position   = AXUtilities.GetPosition(tmx);
                    go.transform.localScale = parametricObject.getLocalScaleAxisRotated();
                }
                return(go);
            }



            return(null);
        }
        // return the height of this gui area
        public static void OnGUI(Rect headerRect, AXNodeGraphEditorWindow editor)
        {
            Event e = Event.current;

            AXModel model = editor.model;

            // DO HEADER MENU BAR -- MODEL MENU


            GUILayout.BeginArea(headerRect);
            GUILayout.BeginHorizontal();

            GUIStyle labelstyle = new GUIStyle(GUI.skin.label);

            labelstyle.alignment = TextAnchor.LowerLeft;

            labelstyle.fixedWidth = 150;


            GUILayout.Space(5);


            if (GUILayout.Button("2D"))
            {
                ArchimatixEngine.openLibrary2D();
            }
            if (GUILayout.Button("3D"))
            {
                ArchimatixEngine.openLibrary3D();
            }



            // NEW MODEL
            GUILayout.Space(10);



            if (GUILayout.Button("▼"))
            {
                AXModel[] allModels = ArchimatixUtils.getAllModels();


                GenericMenu menu = new GenericMenu();

                //menu.AddSeparator("Library ...");


                if (allModels != null && allModels.Length > 0)
                {
                    for (int i = 0; i < allModels.Length; i++)
                    {
                        AXModel m = allModels [i];
                        menu.AddItem(new GUIContent(m.gameObject.name), false, () => {
                            Selection.activeGameObject    = m.gameObject;
                            ArchimatixEngine.currentModel = m;
                        });
                    }
                }


                menu.AddSeparator("");

                menu.AddItem(new GUIContent("New Model"), false, () => {
                    AXEditorUtilities.createNewModel();
                });

                menu.ShowAsContext();
            }



            Color bgc = GUI.backgroundColor;

            GUI.backgroundColor = Color.clear;



            if (model != null)
            {
                // SELECTED MODEL
                if (GUILayout.Button(model.name))
                {
                    model.currentWorkingGroupPO = null;

                    model.selectAllVisibleInGroup(null);

                    float framePadding = 50;

                    Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs);
                    allRect.x      -= framePadding;
                    allRect.y      -= framePadding;
                    allRect.width  += framePadding * 2;
                    allRect.height += framePadding * 2;



                    AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                }



                if (model.currentWorkingGroupPO != null)
                {
                    if (model.currentWorkingGroupPO.grouper != null)
                    {
                        // Make breadcrumb trail
                        List <AXParametricObject> crumbs = new List <AXParametricObject>();
                        AXParametricObject        cursor = model.currentWorkingGroupPO;


                        while (cursor.grouper != null)
                        {
                            crumbs.Add(cursor.grouper);
                            cursor = cursor.grouper;
                        }
                        crumbs.Reverse();

                        // model button frames



                        for (int i = 0; i < crumbs.Count; i++)
                        {
                            if (GUILayout.Button("> " + crumbs[i].Name))
                            {
                                model.currentWorkingGroupPO = crumbs[i];
                                Rect grouperCanvasRect = model.currentWorkingGroupPO.getBoundsRect();
                                editor.zoomToRect(grouperCanvasRect);
                            }
                        }
                    }
                    GUILayout.Button("> " + model.currentWorkingGroupPO.Name);
                }
            }
            GUILayout.FlexibleSpace();



            if (model != null)
            {
                Color  buildBG    = Color.Lerp(Color.cyan, Color.white, .8f);
                string buildLabel = "Rebuild";



                if (model.buildStatus == AXModel.BuildStatus.Generated)
                {
                    buildBG    = Color.red;
                    buildLabel = "Build";
                }



                GUI.backgroundColor = buildBG;
                if (GUILayout.Button(buildLabel))
                {
                    model.build();
                }

                GUI.backgroundColor = Color.cyan;


                if (model.generatedGameObjects != null && model.generatedGameObjects.transform.childCount == 0)
                {
                    GUI.enabled = false;
                }

                if (GUILayout.Button("Stamp"))
                {
                    model.stamp();
                }

                if (GUILayout.Button("Prefab"))
                {
                    string startDir = Application.dataPath;

                    string path = EditorUtility.SaveFilePanel(
                        "Save Prefab",
                        startDir,
                        ("" + model.name),
                        "prefab");

                    if (!string.IsNullOrEmpty(path))
                    {
                        AXPrefabWindow.makePrefab(model, path, editor);
                    }
                }
                GUI.enabled = true;

                GUILayout.Space(4);
            }


            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            GUI.backgroundColor = bgc;
        }
示例#19
0
        // GROUPER::GENERATE
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            //if (ArchimatixUtils.doDebug)
            //Debug.Log (parametricObject.Name + " generate +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

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

            if (parametricObject.Groupees == null)
            {
                return(null);
            }


            preGenerate();


            parametricObject.useMeshInputs = true;

            if (parametricObject.meshInputs == null)
            {
                parametricObject.meshInputs = new List <AXParameter>();
            }


            // PROCESS INPUT SHAPES

            // pass Input Shape through...


            //Debug.Log( parametricObject.Name + " <><><><><> PROCESS INPUT SHAPES");
            List <AXParameter> inputShapes = parametricObject.getAllInputShapes();

            for (int i = 0; i < inputShapes.Count; i++)
            {
                AXParameter inputShape = inputShapes[i];

                if (inputShape != null)
                {
                    inputShape.polyTree = null;
                    AXShape.thickenAndOffset(ref inputShape, inputShape.DependsOn);
                }
            }



            GameObject go = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }

            List <AXMesh> ax_meshes = new List <AXMesh>();


            List <AXMesh> boundingMeshes = new List <AXMesh>();

            // for each input


            //List<AXParameter> inputMeshes = parametricObject.getAllInputMeshParameters();



            // Reinstate the original functionality of the Grouper as simple combiner in addition to Groupees.
            if (inputs != null && inputs.Count > 0)
            {
                for (int i = 0; i < inputs.Count; i++)
                {
                    if (inputs[i] != null && inputs[i].DependsOn != null)
                    {
                        if (inputs[i].Dependents != null || inputs[i].Dependents.Count == 0)
                        {
                            AXParameter        src_p  = inputs[i].DependsOn;
                            AXParametricObject src_po = inputs[i].DependsOn.parametricObject;
                            //if (! parametricObject.visited_pos.Contains (groupee))

                            //Debug.Log("groupee.generateOutputNow: " + groupee.Name + " isAltered="+groupee.isAltered);
                            if (src_po.isAltered)
                            {
                                src_po.generateOutputNow(makeGameObjects, initiator_po);
                                //Debug.Log("XXXXX: " + groupee.Output.meshes.Count);
                                src_po.isAltered = false;
                                parametricObject.model.AlteredPOs.Remove(src_po);
                            }

                            if (src_p != null && src_p.meshes != null)
                            {
                                for (int j = 0; j < src_p.meshes.Count; j++)
                                {
                                    AXMesh dep_amesh = src_p.meshes [j];
                                    ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix));
                                }
                            }

                            // BOUNDING MESHES
                            //boundsCombinator[i].mesh      = input_p.DependsOn.parametricObject.boundsMesh;
                            //boundsCombinator[i].transform     = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment;
                            if (src_po.boundsMesh != null)
                            {
                                boundingMeshes.Add(new AXMesh(src_po.boundsMesh, src_po.generator.localMatrixWithAxisRotationAndAlignment));
                            }



                            // GAME_OBJECTS

                            if (makeGameObjects && !parametricObject.combineMeshes)
                            {
                                GameObject plugGO = src_po.generator.generate(true, initiator_po, isReplica);
                                if (plugGO != null)
                                {
                                    plugGO.transform.parent = go.transform;
                                }
                            }
                        }
                    }
                }
            }



            // *** GROUPEES - Generate the groupees here
            // so that all the inputs (thicknesses, etc.) have been processed first.

            //List<AXParametricObject> visited_pos = new List<AXParametricObject>();
            if (parametricObject.Groupees != null && parametricObject.Groupees.Count > 0)
            {
                for (int i = 0; i < parametricObject.Groupees.Count; i++)
                {
                    AXParametricObject groupee = parametricObject.Groupees [i];
                    //if (! parametricObject.visited_pos.Contains (groupee))

                    //Debug.Log("groupee.generateOutputNow: " + groupee.Name + " isAltered="+groupee.isAltered);
                    if (groupee.isAltered)
                    {
                        groupee.generateOutputNow(makeGameObjects, initiator_po);
                        //Debug.Log("XXXXX: " + groupee.Output.meshes.Count);
                        groupee.isAltered = false;
                        parametricObject.model.AlteredPOs.Remove(groupee);
                    }
                }
            }



            // BOUNDING



            // Process
            for (int i = 0; i < parametricObject.Groupees.Count; i++)
            {
                AXParametricObject groupee = parametricObject.Groupees [i];


                //if (input_p != null && input_p.DependsOn != null && input_p.DependsOn.meshes != null && input_p.DependsOn.meshes.Count > 0) {
                //if (groupee != null && groupee.is3D() && ! groupee.hasDependents() && groupee.Output != null && groupee.Output.meshes != null)
                if (groupee != null && groupee.is3D() && groupee.shouldRenderSelf(true))
                {
                    // AX_MESHES
                    //Debug.Log("(*) (*) (*) (*) groupee: " + groupee.Name + " " +groupee.Output.meshes.Count + " isAltered = " + groupee.isAltered);
                    if (groupee.Output != null && groupee.Output.meshes != null)
                    {
                        for (int j = 0; j < groupee.Output.meshes.Count; j++)
                        {
                            AXMesh dep_amesh = groupee.Output.meshes [j];
                            ax_meshes.Add(dep_amesh.Clone(dep_amesh.transMatrix));
                        }
                    }


                    // BOUNDING MESHES
                    //boundsCombinator[i].mesh      = input_p.DependsOn.parametricObject.boundsMesh;
                    //boundsCombinator[i].transform     = input_p.DependsOn.parametricObject.generator.localMatrixWithAxisRotationAndAlignment;
                    if (groupee.boundsMesh != null)
                    {
                        boundingMeshes.Add(new AXMesh(groupee.boundsMesh, groupee.generator.localMatrixWithAxisRotationAndAlignment));
                    }



                    // GAME_OBJECTS

                    if (makeGameObjects && !parametricObject.combineMeshes)
                    {
                        GameObject plugGO = groupee.generator.generate(true, initiator_po, isReplica);
                        if (plugGO != null)
                        {
                            plugGO.transform.parent = go.transform;
                        }
                    }
                }
            }



            // FINISH AX_MESHES


            //Debug.Log("ORG: " + ax_meshes.Count);
            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);



            // FINISH BOUNDS

            CombineInstance[] boundsCombinator = new CombineInstance[boundingMeshes.Count];
            for (int bb = 0; bb < boundsCombinator.Length; bb++)
            {
                boundsCombinator[bb].mesh      = boundingMeshes[bb].mesh;
                boundsCombinator[bb].transform = boundingMeshes[bb].transMatrix;
            }
            setBoundsWithCombinator(boundsCombinator);


            if (P_BoundsX != null && !P_BoundsX.hasRelations() && !P_BoundsX.hasExpressions())
            {
                P_BoundsX.FloatVal = parametricObject.bounds.size.x;
            }

            if (P_BoundsY != null && !P_BoundsY.hasRelations() && !P_BoundsY.hasExpressions())
            {
                P_BoundsY.FloatVal = parametricObject.bounds.size.y;
            }

            if (P_BoundsZ != null && !P_BoundsZ.hasRelations() && !P_BoundsZ.hasExpressions())
            {
                P_BoundsZ.FloatVal = parametricObject.bounds.size.z;
            }



            // FINISH GAME_OBJECTS

            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true, false);


                    // COMBINE ALL THE MESHES
                    CombineInstance[] combine = new CombineInstance[ax_meshes.Count];

                    int combineCt = 0;
                    for (int i = 0; i < ax_meshes.Count; i++)
                    {
                        AXMesh _amesh = ax_meshes [i];
                        combine [combineCt].mesh      = _amesh.mesh;
                        combine [combineCt].transform = _amesh.transMatrix;
                        combineCt++;
                    }

                    Mesh combinedMesh = new Mesh();
                    combinedMesh.CombineMeshes(combine);

                    // If combine, use combined mesh as invisible collider
                    MeshFilter mf = (MeshFilter)go.GetComponent(typeof(MeshFilter));

                    if (mf == null)
                    {
                        mf = (MeshFilter)go.AddComponent(typeof(MeshFilter));
                    }

                    if (mf != null)
                    {
                        mf.sharedMesh = combinedMesh;
                        parametricObject.addCollider(go);
                    }
                }

                else
                {
                    Matrix4x4 tmx = parametricObject.getLocalMatrix();

                    go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                    go.transform.position   = AXUtilities.GetPosition(tmx);
                    go.transform.localScale = parametricObject.getLocalScaleAxisRotated();
                }
                return(go);
            }


            //parametricObject.model.sw.milestone(parametricObject.Name + " generate");


            return(null);
        }
        // return the height of this gui area
        public static void OnGUI(AXParameterAlias pa)
        {
            AXParameter p = pa.parameter;

            //Event e = Event.current;


            //		if (Event.current.type == EventType.KeyUp)
            //		{
            //			if (p != null && ! GUI.GetNameOfFocusedControl().Contains("logicTextArea_") )
            //			{
            //				p.parametricObject.model.autobuildDelayed(1000);
            //			}
            //		}



            //Color oldBackgroundColor = GUI.backgroundColor;


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



            //Color defcolor = GUI.color;


            GUILayout.BeginHorizontal();

            // FOLDOUT

            GUIStyle toggleStyle = new GUIStyle(EditorStyles.foldout);

            toggleStyle.fixedWidth = 50;

            pa.isEditing = EditorGUILayout.Foldout(pa.isEditing, GUIContent.none);

            //Debug.Log(pa.isEditing);
            // SLIDER AND NUMBER FIELD

            GUIStyle textfieldStyle = new GUIStyle(GUI.skin.textField);

            textfieldStyle.fixedWidth = 150;



            GUIStyle labelWrap = new GUIStyle(GUI.skin.label);

            labelWrap.stretchWidth = true;
            labelWrap.wordWrap     = true;
            labelWrap.fontSize     = 9;
            labelWrap.fixedWidth   = 150;
            if (pa.isEditing)
            {
                GUILayout.BeginVertical();

                pa.alias = GUILayout.TextField(pa.alias, textfieldStyle);

                GUILayout.Label("You can edit the alias without altering the source parameter.", labelWrap);

                GUILayout.Label("Actual: ", labelWrap);
                if (GUILayout.Button(pa.parameter.parametricObject.Name + "." + pa.parameter.Name))
                {
                    pa.parameter.parametricObject.model.selectPO(pa.parameter.parametricObject);
                    pa.parameter.ParentNode.isOpen = true;

                    float framePadding = 200;

                    Rect allRect = AXUtilities.getBoundaryRectFromPOs(pa.parameter.parametricObject.model.selectedPOs);
                    allRect.x      -= framePadding;
                    allRect.y      -= framePadding;
                    allRect.width  += framePadding * 2;
                    allRect.height += framePadding * 2;

                    AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                }


                GUILayout.Space(15);
                GUILayout.EndVertical();
            }
            else
            {
                string nameString = pa.alias;

                switch (p.Type)
                {
                case AXParameter.DataType.Float:

                    // FLOAT SLIDER
                    if (p.PType != AXParameter.ParameterType.DerivedValue)
                    {
                        // VALIDATE INPUT - IF INVALID >> LOSE FOCUS
                        AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_Text_" + p.Name);

                        EditorGUI.BeginChangeCheck();
                        GUI.SetNextControlName("FloatField_Text_" + p.Guid + "_" + p.Name);
                        p.val = EditorGUILayout.FloatField(nameString, p.val);
                        if (EditorGUI.EndChangeCheck())
                        {
                            //Debug.Log(val);

                            Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name);
                            p.Parent.initiateRipple_setFloatValueFromGUIChange(p.Name, p.val);
                            p.parametricObject.model.isAltered(27);
                            p.parametricObject.generator.adjustWorldMatrices();
                        }
                    }
                    else
                    {
                        GUILayout.Label(p.Name);
                        GUILayout.Label("" + p.val);
                    }
                    break;

                case AXParameter.DataType.Int:
                {
                    // INT SLIDER
                    // VALIDATE INPUT - IF INVALID >> LOSE FOCUS

                    /*
                     * if (Event.current.type == EventType.KeyDown)
                     * {
                     *              if(Event.current.keyCode != KeyCode.None && !AXEditorUtilities.isValidIntFieldKeyCode(Event.current.keyCode) && GUI.GetNameOfFocusedControl() == ("IntField_" + p.Name))
                     *      {
                     *              Event.current.Use();
                     *              GUI.FocusControl("dummy_label");
                     *      }
                     * }
                     */

                    AXEditorUtilities.assertIntFieldKeyCodeValidity("IntField_" + p.Name);

                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("IntField_" + p.Guid + "_" + p.Name);
                    p.intval = EditorGUILayout.IntField(nameString, p.intval);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name);
                        p.initiateRipple_setIntValueFromGUIChange(p.intval);
                        p.parametricObject.model.isAltered(28);
                        p.parametricObject.generator.adjustWorldMatrices();
                    }

                    break;
                }

                case AXParameter.DataType.Bool:
                {
                    EditorGUI.BeginChangeCheck();

                    GUI.SetNextControlName("BoolToggle_" + p.Guid + "_" + p.Name);
                    p.boolval = EditorGUILayout.Toggle(nameString, p.boolval);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name);

                        p.parametricObject.initiateRipple_setBoolParameterValueByName(p.Name, p.boolval);
                        p.parametricObject.model.autobuild();
                        p.parametricObject.generator.adjustWorldMatrices();
                    }

                    break;
                }

                case AXParameter.DataType.String:
                    if (p.Parent.isEditing)
                    {
                        GUILayout.Label(nameString);
                    }
                    else
                    {
                        GUILayout.Label(nameString);
                    }

                    break;

                case AXParameter.DataType.Option:
                {
                    // OPTION POPUP

                    string[] options = ArchimatixUtils.getMenuOptions(p.Name);

                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("OptionPopup_" + p.Guid + "_" + p.Name);
                    p.intval = EditorGUILayout.Popup(
                        nameString,
                        p.intval,
                        options);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name);
                        p.parametricObject.model.autobuild();

                        if (p.PType == AXParameter.ParameterType.PositionControl)
                        {
                            p.parametricObject.generator.adjustWorldMatrices();
                        }
                    }

                    break;
                }

                case AXParameter.DataType.CustomOption:
                {
                    // OPTION POPUP

                    string[] options = p.optionLabels.ToArray();



                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("CustomOptionPopup_" + p.Guid + "_" + p.Name);
                    p.intval = EditorGUILayout.Popup(
                        nameString,
                        p.intval,
                        options);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name);

                        if (p.PType == AXParameter.ParameterType.PositionControl)
                        {
                            p.parametricObject.generator.adjustWorldMatrices();
                        }

                        p.parametricObject.model.autobuild();
                    }

                    break;
                }

                case AXParameter.DataType.Spline:
                {
                    GUILayout.Label(pa.alias);
                    break;
                }
                }                // END switch (Type)
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();



            //GUI.backgroundColor = oldBackgroundColor;



            //GUI.color = defcolor;
        }
示例#21
0
        // GENERATE STEP_REPEATER
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }

            preGenerate();



            // NODE_MESH
            GameObject nodePlugGO = null;

            if (nodeSrc_p != null)
            {
                nodeSrc_po = nodeSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }


            // CELL_MESH
            GameObject cellPlugGO = null;

            if (cellSrc_p != null)
            {
                cellSrc_po = cellSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }



            if (nodeSrc_po == null && cellSrc_po == null)
            {
                if (P_Output != null)
                {
                    P_Output.meshes = null;
                }

                return(null);
            }



            GameObject go = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }



            List <AXMesh> ax_meshes = new List <AXMesh>();

            Matrix4x4 localPlacement_mx = Matrix4x4.identity;

            // -----------------------------------



            shiftU = 0;
            //shiftU = (topStep) ? (-steps * actual_tread / 2) : (-(steps-1) * actual_tread / 2);


            AXMesh tmpMesh;


            // BOUNDING

            CombineInstance[] boundsCombinator = new CombineInstance[steps];



            // LOOP

            //Debug.Log(nodeSrc_po.Name + ": " + nodeSrc_po.boundsMesh.vertices.Length);
            //AXGeometryTools.Utilities
            for (int i = 0; i < steps; i++)
            {
                //Debug.Log("["+i+"] i*actualBay="+i*actualBay+", perval="+perlval);


                if (i == steps - 1 && !topStep)
                {
                    break;
                }



                // NODES
                if (nodeSrc_po != null && nodeSrc_p.meshes != null)
                {
                    string this_address = "node_" + i;


                    // LOCAL_PLACEMENT

                    localPlacement_mx = localMatrixFromAddress(RepeaterItem.Node, i);



                    // AX_MESHES

                    for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++)
                    {
                        AXMesh dep_amesh = nodeSrc_p.meshes [mi];

                        tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                        tmpMesh.subItemAddress = this_address;
                        ax_meshes.Add(tmpMesh);
                    }



                    // BOUNDING MESHES

                    boundsCombinator[i].mesh      = nodeSrc_po.boundsMesh;
                    boundsCombinator[i].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;



                    // GAME_OBJECTS

                    if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                    {
                        //Matrix4x4 mx = localPlacement_mx  * parametricObject.getTransMatrix() * source.getTransMatrix();

                        //Debug.Log(nodeSrc_po.getLocalMatrix());
                        Matrix4x4  mx     = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                        GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                        Vector3 newJitterScale = jitterScale + Vector3.one;
                        copyGO.transform.localScale  = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z);
                        copyGO.transform.localScale += jitterScale;


                                                #if UNITY_EDITOR
                        //if (parametricObject.model.isSelected(nodeSrc_po) && nodeSrc_po.selectedConsumerAddress == this_address)
                        //	Selection.activeGameObject = copyGO;
                                                #endif


                        AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                        if (axgo != null)
                        {
                            axgo.consumerAddress = this_address;
                        }

                        copyGO.name             = copyGO.name + "_" + this_address;
                        copyGO.transform.parent = go.transform;
                    }
                }                 // \NODES



                // CELLS
                if (cellSrc_po != null && cellSrc_p.meshes != null)
                {
                    string this_address = "cell_" + i;


                    // LOCAL_PLACEMENT

                    localPlacement_mx = localMatrixFromAddress(RepeaterItem.Cell, i);


                    // AX_MESHES

                    for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++)
                    {
                        AXMesh dep_amesh = cellSrc_p.meshes [mi];

                        tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                        tmpMesh.subItemAddress = this_address;
                        ax_meshes.Add(tmpMesh);
                    }



                    // BOUNDING MESHES

                    boundsCombinator[i].mesh      = cellSrc_po.boundsMesh;
                    boundsCombinator[i].transform = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment;



                    // GAME_OBJECTS

                    if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                    {
                        //Matrix4x4 mx = localPlacement_mx  * parametricObject.getTransMatrix() * source.getTransMatrix();

                        //Debug.Log(cellSrc_po.getLocalMatrix());
                        Matrix4x4  mx     = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                        GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                        Vector3 newJitterScale = jitterScale + Vector3.one;
                        copyGO.transform.localScale  = new Vector3(copyGO.transform.localScale.x * newJitterScale.x, copyGO.transform.localScale.y * newJitterScale.y, copyGO.transform.localScale.z * newJitterScale.z);
                        copyGO.transform.localScale += jitterScale;


                                                #if UNITY_EDITOR
                        //if (parametricObject.model.isSelected(nodeSrc_po) && nodeSrc_po.selectedConsumerAddress == this_address)
                        //	Selection.activeGameObject = copyGO;
                                                #endif


                        AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                        if (axgo != null)
                        {
                            axgo.consumerAddress = this_address;
                        }

                        copyGO.name             = copyGO.name + "_" + this_address;
                        copyGO.transform.parent = go.transform;
                    }
                }         // \CELLS
            }             //i



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



            GameObject.DestroyImmediate(nodePlugGO);
            GameObject.DestroyImmediate(cellPlugGO);


            // FINNISH AX_MESHES

            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);



            // FINISH BOUNDARIES

            setBoundsWithCombinator(boundsCombinator);



            // Turn ax_meshes into GameObjects
            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true);
                }

                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScaleAxisRotated();                        //AXUtilities.GetScale(tmx);

                return(go);
            }


            return(null);
        }
示例#22
0
        // GENERATE BOX
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool renderToOutputParameter)
        {
            if (parametricObject == null || !parametricObject.isActive)
            {
                return(null);
            }

            preGenerate();


            AXBoxGenerator boxer = new AXBoxGenerator(sizeX, sizeY, sizeZ);

            boxer.front  = front;
            boxer.back   = back;
            boxer.left   = left;
            boxer.right  = right;
            boxer.top    = top;
            boxer.bottom = bottom;

            Mesh mesh = new Mesh();

            boxer.generate(ref mesh, parametricObject.axTex);


            mesh.RecalculateBounds();
            AXGeometryTools.Utilities.calculateMeshTangents(ref mesh);

            AXMesh tmpAXmesh;

            tmpAXmesh                 = new AXMesh(mesh, Matrix4x4.identity, parametricObject.axMat.mat);
            tmpAXmesh.name            = parametricObject.Name;
            tmpAXmesh.hasContinuousUV = parametricObject.boolValue("hasContinuousUV");
            tmpAXmesh.makerPO         = parametricObject;


            List <AXMesh> ax_meshes = new List <AXMesh>();

            ax_meshes.Add(tmpAXmesh);


            //parametricObject.finishSingleAXMeshAndOutput(tmpAXmesh, isReplica);
            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, renderToOutputParameter);

            setBoundaryFromAXMeshes(ax_meshes);

            if (makeGameObjects)
            {
                /*
                 *      GameObject go =	parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, false);
                 *      //Matrix4x4 tmx = parametricObject.getLocalMatrix();
                 *      //go.transform.rotation         = AXUtilities.QuaternionFromMatrix(tmx);
                 *      //go.transform.position         = AXUtilities.GetPosition(tmx);
                 *      //go.transform.localScale   = parametricObject.getLocalScale();
                 *
                 */
                GameObject go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true);

                Matrix4x4 tmx = parametricObject.generator.localMatrixWithAxisRotationAndAlignment;
                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScale();



                return(go);
            }


            //Debug.Log ("gen time="+sw.stop ());

            return(null);
        }
示例#23
0
    public static void display(float imagesize = 64, AXNodeGraphEditorWindow editor = null)
    {
        //Debug.Log("imagesise="+imagesize);
        // called from an OnGUI
        //imagesize = 64;
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUIStyle.none, GUIStyle.none);

        EditorGUILayout.BeginVertical();

        string[] itemStrings = null;

        // Select menu item list
        if (editor.OutputParameterBeingDragged == null)
        {
            if (editor.model != null && editor.model.selectedPOs.Count > 1)
            {
                //if (editor.model.selectedPOs[0].is2D())
                //	itemStrings = ArchimatixEngine.nodeStringsFrom2DMultiSelect;

                //else
                itemStrings = ArchimatixEngine.nodeStringsFromMultiSelect;
            }
            else
            {
                itemStrings = ArchimatixEngine.nodeStrings;
            }
        }
        else if (editor.OutputParameterBeingDragged.parametricObject.is2D())
        {
            itemStrings = ArchimatixEngine.nodeStringsFrom2DOutput;
        }

        else if (editor.OutputParameterBeingDragged.parametricObject.is3D())
        {
            if (editor.OutputParameterBeingDragged.Type == AXParameter.DataType.Spline)
            {
                itemStrings = ArchimatixEngine.nodeStringsFrom2DOutput;
            }
            else
            {
                itemStrings = ArchimatixEngine.nodeStringsFrom3DOutput;
            }
        }
        else if (editor.OutputParameterBeingDragged.parametricObject.generator is RepeaterTool)
        {
            itemStrings = ArchimatixEngine.nodeStringsFromRepeaterTool;
        }


        /*
         * if (Library.last2DItem != null)
         * {
         *      if (GUILayout.Button(new GUIContent(Library.last2DItem.icon, Library.last2DItem.po.Name), new GUILayoutOption[] {GUILayout.Width(imagesize), GUILayout.Height(imagesize)}))
         *      {
         *
         *      }
         * }
         */


        List <string> stringList = null;

        if (itemStrings != null)
        {
            stringList = itemStrings.ToList();
        }

        if (stringList != null)
        {
            stringList.AddRange(Archimatix.customNodeNames);
        }

        // Build Menu
        string poName;

        if (stringList != null)
        {
            for (int i = 0; i < stringList.Count; i++)
            {
                string nodeName = stringList[i];

                Texture2D nodeIcon = null;


                if (ArchimatixEngine.nodeIcons.ContainsKey(nodeName))
                {
                    nodeIcon = ArchimatixEngine.nodeIcons[nodeName];
                }
                else
                {
                    if (ArchimatixEngine.nodeIcons.ContainsKey("CustomNode"))
                    {
                        nodeIcon = ArchimatixEngine.nodeIcons["CustomNode"];
                    }
                    else
                    {
                        continue;
                    }
                }



                if (nodeIcon != null)
                {
                    if (GUILayout.Button(new GUIContent(nodeIcon, nodeName), new GUILayoutOption[] { GUILayout.Width(imagesize), GUILayout.Height(imagesize) }))
                    {
                        //if (editor.DraggingOutputParameter != null)
                        //{
                        AXModel model = AXEditorUtilities.getOrMakeSelectedModel();

                        Undo.RegisterCompleteObjectUndo(model, "Node Menu Selection");

                        AXParametricObject mostRecentPO = model.recentlySelectedPO;


                        int index = nodeName.IndexOf("_");

                        poName = (index > 0) ? nodeName.Substring(0, index) : nodeName;

                        // Support multi-select operation
                        List <AXParametricObject> selectedPOs = new List <AXParametricObject>();
                        if (model.selectedPOs.Count > 0)
                        {
                            selectedPOs.AddRange(model.selectedPOs);
                        }



                        // ADD NEW PO TO MODEL (only this new po is selected after this)
                        AXParametricObject po = AXEditorUtilities.addNodeToCurrentModel(poName, false);

                        if (po == null || po.generator == null)
                        {
                            return;
                        }


                        float max_x = -AXGeometryTools.Utilities.IntPointPrecision;


                        if (poName == "FreeCurve")
                        {
                            ArchimatixEngine.sceneViewState = ArchimatixEngine.SceneViewState.AddPoint;
                        }



                        // DRAGGING A PARAMETER? THEN RIG'R UP!
                        if (editor.OutputParameterBeingDragged != null)
                        {
                            AXParametricObject draggingPO  = editor.OutputParameterBeingDragged.parametricObject;
                            AXParameter        new_input_p = null;

                            switch (nodeName)
                            {
                            case "Instance2D":
                            case "ShapeOffsetter":
                                po.getParameter("Input Shape").makeDependentOn(editor.OutputParameterBeingDragged);
                                po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis"));

                                if (po.geometryControls != null)
                                {
                                    po.geometryControls.isOpen = true;
                                }
                                break;

                            case "ShapeDistributor":
                                List <AXParameter> deps = new List <AXParameter>();

                                for (int dd = 0; dd < editor.OutputParameterBeingDragged.Dependents.Count; dd++)
                                {
                                    deps.Add(editor.OutputParameterBeingDragged.Dependents[dd]);
                                }

                                for (int dd = 0; dd < deps.Count; dd++)
                                {
                                    deps[dd].makeDependentOn(po.getParameter("Output Shape"));
                                }

                                po.getParameter("Input Shape").makeDependentOn(editor.OutputParameterBeingDragged);
                                po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis"));

                                if (po.geometryControls != null)
                                {
                                    po.geometryControls.isOpen = true;
                                }
                                break;

                            case "ShapeMerger":
                                po.generator.getInputShape().addInput().makeDependentOn(editor.OutputParameterBeingDragged);
                                if (editor.OutputParameterBeingDragged.axis != Axis.NONE)
                                {
                                    po.intValue("Axis", (int)editor.OutputParameterBeingDragged.axis);
                                }
                                else
                                {
                                    po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis"));
                                }

                                break;

                            case "PlanRepeater2D":
                            case "PlanRepeater2D_Corner":
                                po.getParameter("Corner Shape").makeDependentOn(editor.OutputParameterBeingDragged);
                                po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis"));
                                break;

                            case "PlanRepeater_Corner":
                                po.getParameter("Corner Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;


                            case "PairRepeater2D":
                            case "RadialRepeater2D":
                            case "RadialRepeater2D_Node":
                            case "LinearRepeater2D":
                            case "LinearRepeater2D_Node":
                            case "GridRepeater2D":
                            case "GridRepeater2D_Node":
                                po.getParameter("Node Shape").makeDependentOn(editor.OutputParameterBeingDragged);
                                po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis"));
                                break;

                            case "RadialRepeater2D_Cell":
                            case "LinearRepeater2D_Cell":
                            case "GridRepeater2D_Cell":
                                po.getParameter("Cell Shape").makeDependentOn(editor.OutputParameterBeingDragged);
                                po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis"));
                                break;

                            case "Grouper":
                                //po.addInputMesh().makeDependentOn(editor.OutputParameterBeingDragged);


                                po.addGroupee(editor.OutputParameterBeingDragged.parametricObject);

                                break;

                            case "PlanRepeater2D_Plan":
                            case "Polygon_Plan":
                            case "Extrude_Plan":
                            case "PlanSweep_Plan":
                            case "PlanRepeater_Plan":
                            case "PlanDeformer_Plan":

                                // SYNC AXES
                                if (editor.OutputParameterBeingDragged.axis != Axis.NONE)
                                {
                                    po.intValue("Axis", (int)editor.OutputParameterBeingDragged.axis);
                                }
                                else
                                {
                                    po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis"));
                                }


                                if (nodeName == "Extrude_Plan" && po.intValue("Axis") != (int)Axis.Y)
                                {
                                    po.floatValue("Bevel", 0);
                                }



                                // INSERT SHAPE_DISTRIBUTOR?
                                new_input_p = po.getParameter("Plan", "Input Shape");
                                //if (draggingPO.is2D() && !(draggingPO.generator is ShapeDistributor) && editor.OutputParameterBeingDragged.Dependents != null && editor.OutputParameterBeingDragged.Dependents.Count > 0)
                                //	model.insertShapeDistributor(editor.OutputParameterBeingDragged, new_input_p);
                                //else
                                new_input_p.makeDependentOn(editor.OutputParameterBeingDragged);

                                // the output of the new node should match the shapestate of the input
                                if (po.generator.P_Output != null)
                                {
                                    po.generator.P_Output.shapeState = new_input_p.shapeState;
                                }

                                AXNodeGraphEditorWindow.repaintIfOpen();

                                break;

                            case "Lathe_Section":
                            case "PlanSweep_Section":
                            case "PlanRepeater_Section":

                                //po.getParameter("Section").makeDependentOn(editor.OutputParameterBeingDragged);

                                // INSERT SHAPE_DISTRIBUTOR?
                                new_input_p = po.getParameter("Section");
                                if (draggingPO.is2D() && !(draggingPO.generator is ShapeDistributor) && draggingPO.hasDependents())
                                {
                                    model.insertShapeDistributor(editor.OutputParameterBeingDragged, new_input_p);
                                }
                                else
                                {
                                    new_input_p.makeDependentOn(editor.OutputParameterBeingDragged);
                                }

                                // the output of the new node should match the shapestate of the input
                                //if (po.generator.P_Output != null)
                                //Debug.Log(new_input_p.Name+" "+new_input_p.shapeState + " :=: " +editor.OutputParameterBeingDragged.Name + " " + editor.OutputParameterBeingDragged.shapeState);



                                AXNodeGraphEditorWindow.repaintIfOpen();


                                break;


                            case "NoiseDeformer":
                            case "ShearDeformer":
                            case "TwistDeformer":
                            case "DomicalDeformer":
                            case "TaperDeformer":
                            case "InflateDeformer":
                            case "PlanDeformer":

                                po.getParameter("Input Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;

                            //case "PlanDeformer_Plan":



                            case "PairRepeater":
                            case "StepRepeater":
                            case "RadialStepRepeater":

                                po.getParameter("Node Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;


                            case "LinearRepeater_Node":
                                AXParameter nodeMesh_p = po.getParameter("Node Mesh");
                                nodeMesh_p.makeDependentOn(editor.OutputParameterBeingDragged);

                                // if the src is very long in x, assume you want to repeat in Z
                                if (editor.OutputParameterBeingDragged.parametricObject.bounds.size.x > (6 * editor.OutputParameterBeingDragged.parametricObject.bounds.size.z))
                                {
                                    po.initiateRipple_setBoolParameterValueByName("zAxis", true);
                                }

                                break;

                            case "LinearRepeater_Cell":
                            case "PlanRepeater_Cell":
                                po.getParameter("Cell Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;

                            case "LinearRepeater_Span":
                                po.getParameter("Bay SpanU").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;


                            case "LinearRepeater":
                                po.getParameter("RepeaterU").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;

                            case "FloorRepeater":
                                po.getParameter("Floor Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;

                            case "RadialRepeater":
                            case "RadialRepeater_Node":
                            case "GridRepeater_Node":
                            case "PlanRepeater_Node":
                                po.getParameter("Node Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;

                            case "RadialRepeater_Span":
                            case "GridRepeater_Span":
                                po.getParameter("Bay SpanU", "SpanU Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;

                            case "GridRepeater_Cell":
                                po.getParameter("Cell Mesh").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;


                            case "ShapeRepeater_Plan":
                                AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Plan").makeDependentOn(editor.OutputParameterBeingDragged);
                                break;


                            default:
                                AXEditorUtilities.addNodeToCurrentModel(nodeName);
                                break;
                            }


                            if (editor.OutputParameterBeingDragged.parametricObject != null)
                            {
                                mostRecentPO = editor.OutputParameterBeingDragged.parametricObject;
                                //po.rect = editor.OutputParameterBeingDragged.parametricObject.rect;
                                //po.rect.x += 325;
                            }

                            /*
                             * else
                             * {
                             *      po.rect.x = (model.focusPointInGraphEditor.x)+100;// + UnityEngine.Random.Range(-100, 300);
                             *      po.rect.y = (model.focusPointInGraphEditor.y - 250) + UnityEngine.Random.Range(-10, 0);
                             * }
                             */
                        }



                        // NO DRAGGING - CONNECT ALL MULTI_SELECTED
                        else if (selectedPOs != null && selectedPOs.Count > 0)
                        {
                            switch (nodeName)
                            {
                            case "ShapeMerger":
                                AXShape shp = po.generator.getInputShape();
                                for (int j = 0; j < selectedPOs.Count; j++)
                                {
                                    AXParametricObject poo = selectedPOs [j];
                                    if (j == 0)
                                    {
                                        po.intValue("Axis", selectedPOs [j].intValue("Axis"));
                                    }
                                    max_x = Mathf.Max(max_x, poo.rect.x);
                                    if (poo.is2D())
                                    {
                                        AXParameter out_p = poo.generator.getPreferredOutputParameter();
                                        if (out_p != null)
                                        {
                                            shp.addInput().makeDependentOn(out_p);
                                        }
                                    }
                                }

                                po.rect.x = max_x + 250;
                                break;

                            case "Grouper":
                                //Debug.Log("selectedPOs="+selectedPOs.Count);

                                //if (model.currentWorkingGroupPO != null && ! selectedPOs.Contains(model.currentWorkingGroupPO))
                                //{
                                po.addGroupees(selectedPOs);

                                Rect r = AXUtilities.getBoundaryRectFromPOs(selectedPOs);
                                po.rect.x = r.center.x - po.rect.width / 2;
                                po.rect.y = r.center.y - po.rect.height / 2;
                                //}
                                //po.rect.x = max_x+250;
                                break;

                            case "Channeler":
                                //Debug.Log("selectedPOs="+selectedPOs.Count);

                                //if (model.currentWorkingGroupPO != null && ! selectedPOs.Contains(model.currentWorkingGroupPO))
                                //{
                                foreach (AXParametricObject selpo in selectedPOs)
                                {
                                    AXParameter inputer = po.addInputMesh();

                                    inputer.makeDependentOn(selpo.generator.P_Output);
                                }


                                Rect cr = AXUtilities.getBoundaryRectFromPOs(selectedPOs);
                                po.rect.x = cr.center.x - po.rect.width / 2;
                                po.rect.y = cr.center.y - po.rect.height / 2;
                                //}
                                //po.rect.x = max_x+250;
                                break;
                            }
                        }

                        else
                        {
                            switch (nodeName)
                            {
                            case "ShapeMerger":
                                po.assertInputControls();
                                //po.generator.getInputShape().addInput();
                                break;
                            }
                        }



                        editor.OutputParameterBeingDragged = null;
                        model.autobuild();

                        po.generator.adjustWorldMatrices();

                        if (mostRecentPO != null)
                        {
                            po.rect    = mostRecentPO.rect;
                            po.rect.x += (mostRecentPO.rect.width + 50);
                        }
                        else
                        {
                            po.rect.x = (model.focusPointInGraphEditor.x) + 100;                          // + UnityEngine.Random.Range(-100, 300);
                            po.rect.y = (model.focusPointInGraphEditor.y - 250) + UnityEngine.Random.Range(-10, 0);
                        }

                        po.rect.height = 700;

                        //AXNodeGraphEditorWindow.zoomToRectIfOpen(po.rect);


                        //model.beginPanningToRect(po.rect);
                    }
                }
            }
        }
        //GUILayout.Label (GUI.tooltip);


        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndScrollView();

        /* Not sure why I was doing this - it took up a huge amount of CPU!
         *
         *
         * editor.Repaint();
         * SceneView sv = SceneView.lastActiveSceneView;
         * if (sv != null)
         *      sv.Repaint();
         *
         */
    }
        // GENERATE LINEAR_REPEATER
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            //Debug.Log("repeaterToolU="+repeaterToolU+", repeaterToolV="+repeaterToolV);

            //Debug.Log("LINEAR REPEATER: Gentrate");



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

            if (repeaterToolU == null && repeaterToolV == null)
            {
                return(null);
            }


            preGenerate();


            repeaterTool = (zAxis) ? repeaterToolV : repeaterToolU;

            repeaterTool = repeaterToolU;



            //Terrain terrain = Terrain.activeTerrain;


            // NODE_MESH
            AXParametricObject nodeSrc_po = null;
            GameObject         nodePlugGO = null;

            if (nodeSrc_p != null)
            {
                nodeSrc_po = nodeSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    nodePlugGO = nodeSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }

            // CELL_MESH
            AXParametricObject cellSrc_po = null;
            GameObject         cellPlugGO = null;

            if (cellSrc_p != null)
            {
                cellSrc_po = cellSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    cellPlugGO = cellSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }

            // BAY_SPAN
            AXParametricObject spanSrc_po = null;
            GameObject         spanPlugGO = null;

            if (spanUSrc_p != null)
            {
                spanSrc_po = spanUSrc_p.parametricObject;
                if (makeGameObjects && !parametricObject.combineMeshes)
                {
                    spanPlugGO = spanSrc_po.generator.generate(true, initiator_po, isReplica);
                }
            }



            if (nodeSrc_po == null && spanSrc_po == null && cellSrc_po == null)
            {
                if (P_Output != null)
                {
                    P_Output.meshes = null;
                }

                return(null);
            }


            GameObject go = null;

            if (makeGameObjects && !parametricObject.combineMeshes)
            {
                go = ArchimatixUtils.createAXGameObject(parametricObject.Name, parametricObject);
            }



            Paths boundingSolids = null;
            Paths boundingHoles  = null;



            List <AXMesh> ax_meshes = new List <AXMesh>();

            Matrix4x4 localPlacement_mx = Matrix4x4.identity;

            // -----------------------------------


            int max_reps = 150;

            int   cellsU     = Mathf.Clamp(repeaterTool.cells, 1, max_reps);
            float actualBayU = repeaterTool.actualBay;

            if (float.IsNaN(actualBayU))
            {
                return(null);
            }

            shiftU = -cellsU * actualBayU / 2;

            AXMesh tmpMesh;


            // BAY SPAN
            // Spanners are meshers that get replicated and sized to fit the bay...

            // prepare mesh to iterate in each direction

            List <AXMesh> ax_meshes_X = new List <AXMesh>();



            if (spanUSrc_p != null)
            {
                ax_meshes_X = spanUSrc_p.meshes;
            }



            /* NEED TO INTEGRATE THIS BACK IN IN THE FUTRE...
             * if (cell_center_source != null)
             * {
             *      // Y-AXIS
             *      // For now, only set the boundaries.
             *      // Perhaps later, may want to set other like controls as in Replicant
             *      // 1. cache source object
             *      cell_center_source.cacheParameterValues();
             *
             *
             *
             *      //bay_center_source.propagateParameterByBinding(1, bayx);
             *      //bay_center_source.propagateParameterByBinding(3, bayz);
             *
             *      // 2. re_generate with temporary values set by this Replicant
             *      cell_center_source.generateOutputNow (makeGameObjects, parametricObject);
             *
             *      // 3. Now that the bay_span_source has been regenerted,  grab the meshes from the input sources and add them here
             *      AXParameter bc_output_p = cell_center_source.getParameter("Output Mesh");
             *      foreach (AXMesh amesh in bc_output_p.meshes)
             *              ax_meshes_Y.Add (amesh.Clone(amesh.transMatrix));
             *
             *      // 4. restore source object; as though we were never here!
             *      cell_center_source.revertParametersFromCache();
             *
             * }
             */



            // BOUNDING

            int boundingObjectCount = 0;

            if (nodeSrc_po != null && nodeSrc_p.meshes != null)
            {
                boundingObjectCount += cellsU + 1;

                if (!doFirstNode)
                {
                    boundingObjectCount--;
                }

                if (!doLastNode)
                {
                    boundingObjectCount--;
                }
            }


            else if (cellSrc_p != null && cellSrc_p.meshes != null)
            {
                boundingObjectCount += cellsU;
            }

            if (spanUSrc_p != null && spanUSrc_p.meshes != null)
            {
                boundingObjectCount += cellsU;
            }

            CombineInstance[] boundsCombinator = new CombineInstance[boundingObjectCount];


            // FOR EACH ADDRESS

            for (int i = 0; i <= cellsU; i++)
            {
                //Debug.Log("["+i+"] i*actualBay="+i*actualBay+", perval="+perlval);

                if (boundingSolids != null)
                {
                    IntPoint ip = new IntPoint((i * repeaterToolU.actualBay + shiftU) * AXGeometryTools.Utilities.IntPointPrecision, 0);

                    bool exclude = true;

                    if (boundingSolids != null)
                    {
                        foreach (Path path in boundingSolids)
                        {
                            if (Clipper.PointInPolygon(ip, path) == 1 && Clipper.Orientation(path))
                            {
                                exclude = false;
                                break;
                            }
                        }
                    }

                    if (boundingHoles != null)
                    {
                        foreach (Path hole in boundingHoles)
                        {
                            if (Clipper.PointInPolygon(ip, hole) == 1)
                            {
                                exclude = true;
                                break;
                            }
                        }
                    }

                    if (exclude)
                    {
                        continue;
                    }
                }



                //Debug.Log(" ** ** ** * " + nodeSrc_p.meshes);

                // NODES
                if (nodeSrc_po != null && nodeSrc_p.meshes != null)
                {
                    // Debug.Log("nodeSrc_po.getLocalAlignMatrix()"+nodeSrc_po.getLocalAlignMatrix());
                    if ((i > 0 && i < cellsU) || (i == 0 && doFirstNode) || (i == (cellsU) && doLastNode))
                    {
                        string this_address = "node_" + i;

                        int ni = doFirstNode ? i : i - 1;


                        // LOCAL_PLACEMENT //

                        localPlacement_mx = localNodeMatrixFromAddress(i);


                        if (float.IsNaN(localPlacement_mx.m00))
                        {
                            continue;
                        }


                        // AX_MESHES

                        for (int mi = 0; mi < nodeSrc_p.meshes.Count; mi++)
                        {
                            AXMesh dep_amesh = nodeSrc_p.meshes [mi];

                            //tmpMesh = dep_amesh.CloneTransformed (localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                            tmpMesh.subItemAddress = this_address;
                            ax_meshes.Add(tmpMesh);
                        }



                        // BOUNDING MESHES

                        boundsCombinator[ni].mesh      = nodeSrc_po.boundsMesh;
                        boundsCombinator[ni].transform = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;


                        // GAME_OBJECTS

                        if (nodePlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                        {
                            //Matrix4x4 mx = localPlacement_mx  * parametricObject.getTransMatrix() * source.getTransMatrix();

                            //Debug.Log(nodeSrc_po.getLocalMatrix());
                            Matrix4x4 mx = localPlacement_mx * nodeSrc_po.generator.localMatrixWithAxisRotationAndAlignment;


                            GameObject copyGO = (GameObject)GameObject.Instantiate(nodePlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                            copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);

                            AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                            if (axgo != null)
                            {
                                axgo.consumerAddress = this_address;
                            }

                            copyGO.name             = copyGO.name + "_" + this_address;
                            copyGO.transform.parent = go.transform;
                        }
                    }
                }                 // \NODES



                // CELL CENTERS
                if (cellSrc_p != null && cellSrc_p.meshes != null && i < cellsU)
                {
                    string this_address = "cell_" + i;

                    //Debug.Log("Here");
                    // LOCAL_PLACEMENT
                    localPlacement_mx = localCellMatrixFromAddress(i);


                    // ACTUAL MESHES
                    for (int mi = 0; mi < cellSrc_p.meshes.Count; mi++)
                    {
                        AXMesh dep_amesh = cellSrc_p.meshes [mi];
                        tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                        tmpMesh.subItemAddress = this_address;
                        ax_meshes.Add(tmpMesh);
                    }



                    // BOUNDING MESHES

                    boundsCombinator[i].mesh      = cellSrc_po.boundsMesh;
                    boundsCombinator[i].transform = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment;;



                    // GAME_OBJECTS

                    if (cellPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                    {
                        //Matrix4x4 mx = localPlacement_mx  * parametricObject.getTransMatrix() * source.getTransMatrix();
                        Matrix4x4  mx     = localPlacement_mx * cellSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                        GameObject copyGO = (GameObject)GameObject.Instantiate(cellPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                        copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);

                        AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                        if (axgo != null)
                        {
                            axgo.consumerAddress = this_address;
                        }

                        copyGO.name             = copyGO.name + "_" + this_address;
                        copyGO.transform.parent = go.transform;

                        //Debug.Log("LINEAR: " + axgo.consumerAddress);
                    }
                }                 // \CELLS



                // SPANS

                if (spanUSrc_p != null && spanUSrc_p.meshes != null && i < cellsU)
                {
                    string this_address = "spanU_" + i;
                    // X-AXIS

                    // LOCAL_PLACEMENT

                    localPlacement_mx = localCellMatrixFromAddress(i);



                    // AX_MESHES
                    // AX_MESHES
                    for (int mi = 0; mi < ax_meshes_X.Count; mi++)
                    {
                        AXMesh dep_amesh = ax_meshes_X [mi];
                        tmpMesh = dep_amesh.Clone(localPlacement_mx * dep_amesh.transMatrix);
                        tmpMesh.subItemAddress = this_address;
                        ax_meshes.Add(tmpMesh);
                    }



                    // BOUNDING MESHES

                    boundsCombinator[i].mesh      = spanUSrc_po.boundsMesh;
                    boundsCombinator[i].transform = localPlacement_mx * spanUSrc_po.generator.localMatrixWithAxisRotationAndAlignment;


                    // GAME_OBJECTS

                    if (spanPlugGO != null && makeGameObjects && !parametricObject.combineMeshes)
                    {
                        Matrix4x4  mx     = localPlacement_mx * spanSrc_po.generator.localMatrixWithAxisRotationAndAlignment;
                        GameObject copyGO = (GameObject)GameObject.Instantiate(spanPlugGO, AXUtilities.GetPosition(mx), AXUtilities.QuaternionFromMatrix(mx));

                        copyGO.transform.localScale = new Vector3(copyGO.transform.localScale.x * jitterScale.x, copyGO.transform.localScale.y * jitterScale.y, copyGO.transform.localScale.z * jitterScale.z);


                        AXGameObject axgo = copyGO.GetComponent <AXGameObject>();
                        if (axgo != null)
                        {
                            axgo.consumerAddress = this_address;
                        }

                        copyGO.name = copyGO.name + "_" + this_address;

                        copyGO.transform.parent = go.transform;
                    }
                }         // \SPANS
            }             //i


            GameObject.DestroyImmediate(nodePlugGO);
            GameObject.DestroyImmediate(cellPlugGO);
            GameObject.DestroyImmediate(spanPlugGO);


            parametricObject.finishMultiAXMeshAndOutput(ax_meshes, isReplica);


            setBoundsWithCombinator(boundsCombinator);

            // Turn ax_meshes into GameObjects
            if (makeGameObjects)
            {
                if (parametricObject.combineMeshes)
                {
                    go = parametricObject.makeGameObjectsFromAXMeshes(ax_meshes, true);
                }
                Matrix4x4 tmx = parametricObject.getLocalMatrix();

                go.transform.rotation   = AXUtilities.QuaternionFromMatrix(tmx);
                go.transform.position   = AXUtilities.GetPosition(tmx);
                go.transform.localScale = parametricObject.getLocalScaleAxisRotated();                        //AXUtilities.GetScale(tmx);

                return(go);
            }


            return(null);
        }