// INSTANCE public static AXParametricObject instancePO(AXParametricObject po) { // make an instance AXParametricObject src_po = po; if (po.is2D()) { AXParameter output_p = po.generator.P_Output; if (output_p == null && po.generator is ShapeMerger) { ShapeMerger gener = (ShapeMerger)po.generator; output_p = gener.S_InputShape.getSelectedOutputParameter(); } if (output_p != null) { AXParametricObject instance_po = AXEditorUtilities.addNodeToCurrentModel("Instance2D", true, po); instance_po.getParameter("Input Shape").makeDependentOn(output_p); return(instance_po); } } else { if (src_po.generator is IReplica) { // get next PO from downstream AXParameter in_p = po.getParameter("Input Mesh"); if (in_p.DependsOn != null) { src_po = in_p.DependsOn.parametricObject; } } AXParameter out_p = src_po.getParameter("Output Mesh", "Output"); if (out_p != null) { AXParametricObject instance_po = AXEditorUtilities.addNodeToCurrentModel("Instance", true, src_po); instance_po.getParameter("Input Mesh").makeDependentOn(out_p); return(instance_po); } } return(null); }
public void display(float imagesize = 64, AXNodeGraphEditorWindow editor = null, string mode = "2D") // mode { //Debug.Log("imagesise="+imagesize); // called from an OnGUI //imagesize = 64; Event e = Event.current; scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUIStyle.none, GUIStyle.none); //StopWatch sw = new StopWatch(); EditorGUILayout.BeginVertical(); if (mode == "2D") { if (ArchimatixEngine.library != null && ArchimatixEngine.library.filteredResults != null) { // EACH 2D ITEM for (int i = 0; i < ArchimatixEngine.library.filteredResults.Count; i++) { // ** THE BIG CLICK 2D LibraryItem li = ArchimatixEngine.library.filteredResults [i]; if (!li.includeInSidebarMenu) { continue; } if (!li.is2D) { continue; } if (GUILayout.Button(new GUIContent(li.icon, li.Name), GUILayout.Width(imagesize), GUILayout.Height(imagesize))) { e.Use(); AXParametricObject prevSelectedPO = null; if (ArchimatixEngine.currentModel != null && ArchimatixEngine.currentModel.selectedPOs != null && ArchimatixEngine.currentModel.selectedPOs.Count > 0) { //foreach(AXParametricObject poo in ArchimatixEngine.currentModel.selectedPOs) // Debug.Log(" --- " + poo.Name); prevSelectedPO = ArchimatixEngine.currentModel.selectedPOs [ArchimatixEngine.currentModel.selectedPOs.Count - 1]; ArchimatixEngine.currentModel.deselectAll(); } AXParametricObject npo = Library.instantiateParametricObject(li.readIntoLibraryFromRelativeAXOBJPath); npo.generator.pollInputParmetersAndSetUpLocalReferences(); if (prevSelectedPO != null) { // AUTO-CONNECT TO A SELECTED SHAPE_MERGER ShapeMerger shapeMerger = null; Rect rect = new Rect(); if (prevSelectedPO != null && prevSelectedPO.generator is ShapeMerger) { shapeMerger = prevSelectedPO.generator as ShapeMerger; rect = new Rect(prevSelectedPO.rect.x - 300, prevSelectedPO.rect.y, prevSelectedPO.rect.width, prevSelectedPO.rect.height); } if (shapeMerger == null && prevSelectedPO.generator.P_Output != null) { foreach (AXParameter d in prevSelectedPO.generator.P_Output.Dependents) { if (d.parametricObject.generator is ShapeMerger) { shapeMerger = d.parametricObject.generator as ShapeMerger; rect = new Rect(prevSelectedPO.rect.x + 50, prevSelectedPO.rect.y + 50, prevSelectedPO.rect.width, prevSelectedPO.rect.height); break; } } } if (shapeMerger != null) { shapeMerger.connect(npo); npo.rect = rect; npo.generator.pollInputParmetersAndSetUpLocalReferences(); shapeMerger.pollInputParmetersAndSetUpLocalReferences(); ArchimatixEngine.currentModel.autobuild(); shapeMerger.adjustWorldMatrices(); npo.generator.adjustWorldMatrices(); //AXNodeGraphEditorWindow.zoomToRectIfOpen(npo.rect); } } if (npo != null) { if (npo.rect.width < npo.generator.minNodePaletteWidth) { npo.rect.width = npo.generator.minNodePaletteWidth; } } //Selection.activeGameObject = null; } } } } else { // 3D Library if (ArchimatixEngine.library != null && ArchimatixEngine.library.filteredResults != null) { for (int i = 0; i < ArchimatixEngine.library.filteredResults.Count; i++) { // THE BIG CLICK 3D !!!! LibraryItem li = ArchimatixEngine.library.filteredResults [i]; if (!li.includeInSidebarMenu) { continue; } if (li.is2D) { continue; } if (GUILayout.Button(new GUIContent(li.icon, li.Name), GUILayout.Width(imagesize), GUILayout.Height(imagesize))) { Library.instantiateParametricObject(li.readIntoLibraryFromRelativeAXOBJPath); //Selection.activeGameObject = null; } } } } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); //Debug.Log(sw.stop()); 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(); * */ }