Example #1
0
        public LibraryItem(AXParametricObject po = null)
        {
            if (po == null)
            {
                return;
            }



            Name = po.Name;
            guid = po.Guid;

            description = po.description;

            is2D    = po.is2D();
            sortval = po.sortval;

            tags = po.tags;

            author = po.author;

            documentationURL = po.documentationURL;

            readIntoLibraryFromRelativeAXOBJPath = po.readIntoLibraryFromRelativeAXOBJPath;

            includeInSidebarMenu = po.includeInSidebarMenu;
        }
Example #2
0
    // 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);
    }
Example #3
0
		public void connect(AXParametricObject po)
		{
			AXShape shp = getInputShape();

			if (po.is2D ()) {
				AXParameter out_p = po.generator.getPreferredOutputParameter ();
				if (out_p != null)
					shp.addInput().makeDependentOn(out_p);
				
				po.intValue ("Axis", parametricObject.intValue ("Axis"));

			}
		}
Example #4
0
        public override void connectionMadeWith(AXParameter to_p, AXParameter from_p)
        {
            AXParameter this_p = (to_p.parametricObject == parametricObject) ? to_p   : from_p;
            AXParameter src_p  = (to_p.parametricObject == parametricObject) ? from_p : to_p;


            base.connectionMadeWith(to_p, from_p);

            this_p.shapeState = src_p.shapeState;
            this_p.breakGeom  = src_p.breakGeom;
            this_p.breakNorm  = src_p.breakNorm;


            AXParametricObject po = from_p.parametricObject;


            //Debug.Log ("HERE!!!! " + po.Name);



            if (po.is2D())
            {
                if ((Axis)parametricObject.intValue("Axis") == Axis.NONE)
                {
                    parametricObject.intValue("Axis", po.intValue("Axis"));
                }
            }

            this_p.shapeState = src_p.shapeState;


            if (this_p.Name == "Plan")
            {
                parametricObject.boolValue("Top Cap", (this_p.shapeState == ShapeState.Closed) ? true : false);
                parametricObject.boolValue("Bottom Cap", (this_p.shapeState == ShapeState.Closed) ? true : false);
            }
        }
Example #5
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();
         *
         */
    }
Example #6
0
    public void doPO(AXParametricObject po)
    {
        Color guiColorOrig        = GUI.color;
        Color guiContentColorOrig = GUI.contentColor;

        GUI.color        = Color.white;
        GUI.contentColor = Color.white;

        Color textColor    = new Color(.82f, .80f, .85f);
        Color textColorSel = new Color(.98f, .95f, 1f);


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

        //int fontSize = labelstyle.fontSize;
        labelstyle.fixedHeight = 30;
        labelstyle.alignment   = TextAnchor.UpperLeft;

        labelstyle.normal.textColor = textColorSel;

        labelstyle.fontSize = 20;

//		GUIStyle labelstyleTmp = GUI.skin.GetStyle("Label");
//		labelstyleTmp.normal.textColor = Color.red;

        Color bgcolorOrig = GUI.backgroundColor;
        //GUI.backgroundColor = Color.cyan;



        GUIStyle gsTest = new GUIStyle();

        gsTest.normal.background = ArchimatixEngine.nodeIcons ["Blank"];        // //Color.gray;
        gsTest.normal.textColor  = Color.white;

        GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout);

        foldoutStyle.normal.textColor  = textColor;
        foldoutStyle.active.textColor  = textColorSel;
        foldoutStyle.hover.textColor   = textColor;
        foldoutStyle.focused.textColor = textColorSel;

        foldoutStyle.onNormal.textColor  = textColor;
        foldoutStyle.onActive.textColor  = textColorSel;
        foldoutStyle.onHover.textColor   = textColor;
        foldoutStyle.onFocused.textColor = textColorSel;

        GUIStyle smallFoldoutStyle = new GUIStyle(EditorStyles.foldout);

        smallFoldoutStyle.fixedWidth = 0;



        GUILayout.BeginVertical(gsTest);


        GUILayout.BeginHorizontal(gsTest);
        GUILayout.Space(40);
        Rect rect = GUILayoutUtility.GetLastRect();

        //GUI.DrawTexture(new Rect(position.x, rect.y, EditorGUIUtility.currentViewWidth, 100), ArchimatixEngine.nodeIcons["Blank"], ScaleMode.ScaleToFit, true, 1.0F);

        GUILayout.Space(10);

        // TITLE
        GUILayout.Label(po.Name, labelstyle);


        labelstyle.fontSize = 12;
        GUILayout.EndHorizontal();



        if (po.is2D() && po.generator.hasOutputsReady())
        {
            AXParameter output_p = po.generator.getPreferredOutputParameter();
            GUIDrawing.DrawPathsFit(output_p, new Vector2(42, rect.y + 15), 28, ArchimatixEngine.AXGUIColors ["ShapeColor"]);
        }
        else if (ArchimatixEngine.nodeIcons != null && ArchimatixEngine.nodeIcons.ContainsKey(po.Type))
        {
            //Rect thumbRect = new Rect (28, rect.y - 0, 36, 36);
            //GUI.DrawTexture(thumbRect,    po.renTex, ScaleMode.ScaleToFit, true, 1.0F);
            EditorGUI.DrawTextureTransparent(new Rect(28, rect.y - 0, 36, 36), ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
        }
        Rect rectthumb2 = GUILayoutUtility.GetLastRect();


        if (po.is3D() && po.renTex != null)
        {
            GUIStyle thumbLgStyle = new GUIStyle();
            float    thumbLgSize  = 64;

            thumbLgStyle.fixedHeight = thumbLgSize;
            GUILayout.BeginHorizontal(thumbLgStyle);
            GUILayout.Space(thumbLgSize);

            Rect thumbRectLG = new Rect(40, rectthumb2.y + 35, thumbLgSize, thumbLgSize);
            EditorGUI.DrawTextureTransparent(thumbRectLG, po.renTex, ScaleMode.ScaleToFit, 1.0F);

            GUILayout.EndHorizontal();
        }



        EditorGUI.indentLevel++;


        //GUILayout.Space(20);

        GUILayout.BeginHorizontal();

        EditorGUIUtility.labelWidth = 35;

        EditorGUI.BeginChangeCheck();
        //EditorGUIUtility.labelWidth = 65;

        po.isActive = EditorGUILayout.ToggleLeft("Enabled", po.isActive);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(po.model, "isActive value change for " + po.Name);
            po.model.autobuild();
            po.generator.adjustWorldMatrices();
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Select in Node Graph"))
        {
            po.model.selectAndPanToPO(po);
        }

        GUILayout.EndHorizontal();



        // FLAGS, TAGS & LAYERS
        if (po.is3D())
        {
            po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name, Flags, Tags & Layers", true, foldoutStyle);
        }
        else
        {
            po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name", true, foldoutStyle);
        }



        if (po.displayFlagsTagsLayers)
        {
            //EDIT TITLE
//			if (showTitle(po))
//			{
            //GUILayout.BeginHorizontal();



            GUILayout.BeginHorizontal();
            GUILayout.Space(35);
            GUILayout.Label("Name: ");

            EditorGUIUtility.labelWidth = 65;
            po.Name = GUILayout.TextField(po.Name);
            GUILayout.EndHorizontal();



            if (po.is3D())
            {
                EditorGUIUtility.labelWidth = 75;

                EditorGUI.BeginChangeCheck();
                po.axStaticEditorFlags = (AXStaticEditorFlags)EditorGUILayout.EnumMaskField("Static: ", po.axStaticEditorFlags);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Static value change for " + po.Name);

                    po.setUpstreamersToYourFlags();
                    // post dialog to change all children...
                    ArchimatixEngine.scheduleBuild();
                }


                GUI.backgroundColor = bgcolorOrig;



                EditorGUIUtility.labelWidth = 75;



                // TAGS
                EditorGUI.BeginChangeCheck();
                po.tag = EditorGUILayout.TagField("Tag:", po.tag);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Tag value change for " + po.Name);
                    ArchimatixEngine.scheduleBuild();
                }



                // LAYERS
                EditorGUI.BeginChangeCheck();
                int intval = EditorGUILayout.LayerField("Layer:", po.layer);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Layer value change for " + po.Name);
                    po.layer = intval;
                    ArchimatixEngine.scheduleBuild();
                }



                bool hasMeshRenderer = !po.noMeshRenderer;
                EditorGUI.BeginChangeCheck();
                hasMeshRenderer = EditorGUILayout.ToggleLeft("Mesh Renderer", hasMeshRenderer);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "hasMeshRenderer");
                    po.noMeshRenderer = !hasMeshRenderer;
                    ArchimatixEngine.scheduleBuild();
                }
            }
            else if (po.generator is MaterialTool)
            {
                EditorGUI.BeginChangeCheck();

                //float thumbSize = 16;

                po.axMat.mat = (Material)EditorGUILayout.ObjectField(po.axMat.mat, typeof(Material), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Material");

                    po.model.remapMaterialTools();
                    po.model.autobuild();
                }
            }
        }         // FLAGS< TAGS & LAYERS



        // POSITION CONTROLS

        if (po.positionControls != null && po.positionControls.children != null)
        {
            po.positionControls.isOpenInInspector = EditorGUILayout.Foldout(po.positionControls.isOpenInInspector, "Transform", true, foldoutStyle);

            if (po.positionControls.isOpenInInspector)
            {
                InspectorParameterGUI.OnGUI(po.positionControls.children);
            }
        }



        // GEOMETRY CONTROLS

        if (po.geometryControls != null && po.geometryControls.children != null)
        {
            po.geometryControls.isOpenInInspector = EditorGUILayout.Foldout(po.geometryControls.isOpenInInspector, "Geometry Controls", true, foldoutStyle);
            if (po.geometryControls.isOpenInInspector)
            {
                InspectorParameterGUI.OnGUI(po.geometryControls.children);
            }
        }


        // PROTOTYPES

        if (po.is3D())
        {
            po.displayPrototypes = EditorGUILayout.Foldout(po.displayPrototypes, "Prototypes", true, foldoutStyle);

            if (po.displayPrototypes)
            {
                EditorGUI.BeginChangeCheck();
                po.prototypeGameObject = (GameObject)EditorGUILayout.ObjectField(po.prototypeGameObject, typeof(GameObject), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Prototype GameObject set for " + po.model.name);
                    if (po.prototypeGameObject != null)
                    {
                        AXPrototype proto = (AXPrototype)po.prototypeGameObject.GetComponent("AXPrototype");
                        if (proto == null)
                        {
                            proto = po.prototypeGameObject.AddComponent <AXPrototype> ();
                        }
                        if (!proto.parametricObjects.Contains(po))
                        {
                            proto.parametricObjects.Add(po);
                        }
                    }
                    po.model.autobuild();
                }
            }
        }


        if (po.selectedAXGO != null)
        {
            GUILayout.Label(po.selectedAXGO.consumerAddress);
        }



//		if (po.is3D() && po.renTex != null)
//		{
//		GUIStyle thumbLgStyle = new GUIStyle();
//			float thumbLgSize = 194;
//
//			thumbLgStyle.fixedHeight = thumbLgSize;
//			GUILayout.BeginHorizontal(thumbLgStyle);
//			GUILayout.Space(40);
//			Rect rectthumb = GUILayoutUtility.GetLastRect();
//			Rect thumbRectLG = new Rect(28, rectthumb.y-0, thumbLgSize, thumbLgSize);
//		GUI.DrawTexture(thumbRectLG,    po.renTex, ScaleMode.ScaleToFit, true, 1.0F);
//
//		GUILayout.EndHorizontal();
//		}
//


        EditorGUI.indentLevel--;



        GUILayout.EndVertical();
        GUILayout.Space(30);


        GUI.color        = guiColorOrig;
        GUI.contentColor = guiContentColorOrig;
    }
Example #7
0
    public static int GeometryControlsOnGUI(int cur_y, AXNodeGraphEditorWindow editor, AXParametricObject po)
    {
        int gap     = ArchimatixUtils.gap;
        int lineHgt = ArchimatixUtils.lineHgt;

        float x1         = 10;
        float x2         = 20;
        float winMargin  = ArchimatixUtils.indent;
        float innerWidth = po.rect.width - 2 * winMargin;



        AXParameter p = null;

        // Geometry (and other) controllers
        if (po.geometryControls != null && po.geometryControls.children != null)
        {
            for (int i = 0; i < po.geometryControls.children.Count; i++)
            {
                p = po.geometryControls.children[i] as AXParameter;

                if (p.PType != AXParameter.ParameterType.None && p.PType != AXParameter.ParameterType.GeometryControl)
                {
                    continue;
                }

                // these points are world, not relative to the this GUIWindow
                p.inputPoint  = new Vector2(po.rect.x, po.rect.y + cur_y + lineHgt / 2);
                p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + cur_y + lineHgt / 2);

                Rect pRect = new Rect(x1, cur_y, innerWidth, lineHgt);

                try {
                    int hgt = ParameterGUI.OnGUI(pRect, editor, p);
                    cur_y += hgt + gap;
                } catch {
                }
            }
        }

        if (po.is2D() || po.generator is Grouper)
        {
            if (GUI.Button(new Rect(x2, cur_y, lineHgt * 1.25f, lineHgt), new GUIContent("+", "Create a new Control Parameter")))
            {
                Undo.RegisterCompleteObjectUndo(po.model, "New AXParameter");
                AXParameter tmpP = po.addParameter(new AXParameter());

                foreach (AXParameter pop in po.parameters)
                {
                    if (pop != p)
                    {
                        pop.isOpen = false;
                    }
                }

                po.model.indexedParameters.Add(tmpP.Guid, tmpP);

                po.doneEditing();

                tmpP.isOpen      = true;
                tmpP.isEditing   = false;
                tmpP.shouldFocus = true;
                //po.isEditing  = true;

                po.model.cleanGraph();


                AXNodeGraphEditorWindow.repaintIfOpen();
            }

            /*
             * if (GUI.Button (new Rect(x1+editButtonWid+6, cur_y, editButtonWid,lineHgt), "Done" ))
             *              po.doneEditing();
             * else
             *      if (GUI.Button (new Rect(x1+editButtonWid+6, cur_y, editButtonWid,lineHgt), "Edit Controls" ))
             *              po.isEditing = true;
             */
            cur_y += lineHgt + gap + 5;
        }


        if (po.generator is MaterialTool)
        {
            MaterialTool materialTool = (po.generator as MaterialTool);

            GUIStyle labelstyle = GUI.skin.GetStyle("Label");
            labelstyle.alignment = TextAnchor.MiddleLeft;
            GUI.Label(new Rect(10, cur_y, 250, 32), "   Texels/Unit: " + materialTool.texelsPerUnit.ToString("F0"));
            cur_y += 32;
        }
        else if (po.generator is ShapeOffsetter)
        {
            ShapeOffsetter offsetter = (po.generator as ShapeOffsetter);

            AXParameter output_p = offsetter.P_Output;

            if (output_p == null)
            {
                output_p = po.getParameter("Output Shape");
            }

            if (output_p == null)
            {
                return(cur_y);
            }


            Rect tRect = new Rect(25, cur_y, 150, 16);

            GUIStyle labelstyle = GUI.skin.GetStyle("Label");
            labelstyle.alignment = TextAnchor.MiddleLeft;

            /*
             * if (p.PType == AXParameter.ParameterType.Output)
             * {
             * labelstyle.alignment = TextAnchor.MiddleRight;
             * labelstyle.fixedWidth = lRect.width+5;
             * }
             */

            // JOIN_TYPE: Square, Round, Miter
            if (offsetter.offset != 0)
            {
                string[] options = ArchimatixUtils.getMenuOptions("JoinType");
                EditorGUIUtility.labelWidth = 75;                //-50;

                EditorGUI.BeginChangeCheck();
                output_p.joinType = (JoinType)EditorGUI.Popup(tRect, "JoinType", (int)output_p.joinType, options);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "value change for JoinType");
                    po.model.autobuild();
                }
                cur_y += ArchimatixUtils.lineHgt + ArchimatixUtils.gap;
            }

            // ARC_TOLERANCE (for JoinType.Round)
            if (output_p.joinType == AXClipperLib.JoinType.jtRound || output_p.endType == AXClipperLib.EndType.etOpenRound)
            {
                tRect.y = cur_y;


                if (float.IsNaN(output_p.arcTolerance))
                {
                    output_p.arcTolerance = 50;
                }
                if (output_p.arcTolerance < .25f)
                {
                    output_p.arcTolerance = .25f;
                }

                float smooth = (float)(120 / (output_p.arcTolerance * output_p.arcTolerance));

                AXEditorUtilities.assertFloatFieldKeyCodeValidity("shapehandler_Text_smoothness_" + output_p.Guid + "_" + output_p.Name);

                EditorGUI.BeginChangeCheck();
                GUI.SetNextControlName("shapehandler" + output_p.Name);
                smooth = EditorGUI.FloatField(tRect, "smoothness", smooth);
                if (EditorGUI.EndChangeCheck())
                {
                    output_p.arcTolerance = (float)(Mathf.Sqrt(120 / smooth));
                    Undo.RegisterCompleteObjectUndo(po.model, "value change for " + output_p.Name);
                    if (output_p.arcTolerance < .25f)
                    {
                        output_p.arcTolerance = .25f;
                    }
                    if (output_p.arcTolerance > 50)
                    {
                        output_p.arcTolerance = 50;
                    }
                    if (float.IsNaN(output_p.arcTolerance))
                    {
                        output_p.arcTolerance = 50;
                    }
                    po.model.isAltered(20);
                }
                cur_y += ArchimatixUtils.lineHgt + ArchimatixUtils.gap;
            }
        }

        return(cur_y);
    }
Example #8
0
        // return the height of this gui area
        public static void OnGUI(int win_id, AXNodeGraphEditorWindow editor, AXParametricObject po)
        {
            Event e = Event.current;

            AXModel model = editor.model;


            AXParameter p;

            string buttonLabel;
            Rect   buttonRect;

            Color inactiveColor = new Color(.7f, .7f, .7f);


            Color oldBackgroundColor = GUI.backgroundColor;



            // START LAYOUT OF INNER PALETTE


            // Horizontal layput
            float winMargin  = ArchimatixUtils.indent;
            float innerWidth = po.rect.width - 2 * winMargin;



            int x1 = 10;
            int x2 = 20;

            // vertical layut
            int cur_y   = 25;
            int gap     = ArchimatixUtils.gap;
            int lineHgt = ArchimatixUtils.lineHgt;


//		if (EditorGUIUtility.isProSkin)
//		{
//			GUI.color = po.generator.GUIColorPro;
//			GUI.backgroundColor = Color.Lerp(po.generator.GUIColorPro, Color.white, .5f) ;
//		}
//		else
//		{
//			GUI.color = po.generator.GUIColor;
//			GUI.backgroundColor = Color.Lerp(po.generator.GUIColor, Color.white, .5f) ;
//
//		}



            // DRAW HIGHLIGHT AROUND SELECTED NODE PALETTE
            if (model.isSelected(po))
            {
                float pad     = (EditorGUIUtility.isProSkin) ? 1 : 1;
                Rect  outline = new Rect(0, 0, po.rect.width - pad, po.rect.height - pad);
                Handles.color = Color.white;

                Handles.DrawSolidRectangleWithOutline(outline, new Color(1, 1, 1, 0f), ArchimatixEngine.AXGUIColors ["NodePaletteHighlightRect"]);
                //Handles.DrawSolidRectangleWithOutline(outline, new Color(.1f, .1f, .3f, .05f), new Color(.1f, .1f, .8f, 1f));
            }


            // TITLE

            if (GUI.Button(new Rect(x1, cur_y, innerWidth - lineHgt * 2 - 6, lineHgt * 2), po.Name))
            {
//				po.isEditing = true;
//				for (int i = 0; i < po.parameters.Count; i++) {
//					p = po.parameters [i];
//					p.isEditing = false;
//				}
                po.isMini = false;
            }


            if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type))
            {
                EditorGUI.DrawTextureTransparent(new Rect(x1 + innerWidth - lineHgt * 2 - 4, cur_y, lineHgt * 2, lineHgt * 2), ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
            }


            cur_y += lineHgt + 2 * gap;



            // DO THUMBNAIL / DROP_ZONE



            int bottomPadding    = 55;
            int splineCanvasSize = (int)(po.rect.width - 60);

            editor.mostRecentThumbnailRect = new Rect(x1, cur_y + lineHgt, innerWidth, innerWidth);

            Rect lowerRect = new Rect(0, cur_y - 50, po.rect.width, po.rect.width);


            if (po.thumbnailState == ThumbnailState.Open)
            {
                //if (po.Output != null && po.Output.Type == AXParameter.DataType.Spline)
                if (po.is2D())
                {
                    AXParameter output_p = po.generator.getPreferredOutputParameter();
                    if (po.generator.hasOutputsReady())
                    {
                        if (ArchimatixEngine.nodeIcons.ContainsKey("Blank"))
                        {
                            EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons ["Blank"], ScaleMode.ScaleToFit, 1.0F);
                        }

                        Color color = po.thumbnailLineColor;

                        if (color.Equals(Color.clear))
                        {
                            color = Color.magenta;
                        }

                        GUIDrawing.DrawPathsFit(output_p, new Vector2(po.rect.width / 2, cur_y + po.rect.width / 2), po.rect.width - 60, ArchimatixEngine.AXGUIColors ["ShapeColor"]);
                    }
                    else if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type.ToString()))
                    {
                        EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
                    }
                }
                else
                {
                    //Debug.Log ("po.renTex.IsCreated()="+po.renTex.IsCreated());

                    //Debug.Log (po.renTex + " :::::::::::::::::::::::--::



                    if (po.generator is PrefabInstancer && po.prefab != null)
                    {
                        Texture2D thumber = AssetPreview.GetAssetPreview(po.prefab);
                        if (e.type == EventType.Repaint)
                        {
                            if (thumber != null)
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, thumber, ScaleMode.ScaleToFit, 1.0F);
                            }
                            else
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
                            }
                        }
                    }
                    else if (((po.Output != null && po.Output.meshes != null && po.Output.meshes.Count > 0) || po.generator is MaterialTool) && (po.renTex != null || po.thumbnail != null))
                    {                   //if ( po.thumbnail != null )
                        //Debug.Log("thumb " + po.renTex);
                        if (e.type == EventType.Repaint)
                        {
                            EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, po.renTex, ScaleMode.ScaleToFit, 1.0F);


                            // DROP ZONE

                            if (po.generator is Grouper && editor.editorState == AXNodeGraphEditorWindow.EditorState.DraggingNodePalette && editor.mouseIsDownOnPO != po && po != model.currentWorkingGroupPO)
                            {
                                if (editor.mostRecentThumbnailRect.Contains(e.mousePosition))
                                {
                                    EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneOverTex, ScaleMode.ScaleToFit, 1.0F);
                                    editor.OverDropZoneOfPO = po;
                                }
                                else
                                {
                                    EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneTex, ScaleMode.ScaleToFit, 1.0F);
                                }
                            }
                        }
                        //else
                        //	GUI.DrawTexture(editor.mostRecentThumbnailRect, po.thumbnail, ScaleMode.ScaleToFit, false, 1.0F);



                        if (editor.mostRecentThumbnailRect.Contains(e.mousePosition) || editor.draggingThumbnailOfPO == po)
                        {
                            Rect orbitButtonRect = new Rect(x1 + innerWidth - 16 - 3, cur_y + lineHgt + 3, 16, 16);

                            if (e.command || e.control)
                            {
                                EditorGUI.DrawTextureTransparent(orbitButtonRect, editor.dollyIconTex);
                            }
                            else
                            {
                                EditorGUI.DrawTextureTransparent(orbitButtonRect, editor.orbitIconTex);
                            }


                            if (e.type == EventType.MouseDown && orbitButtonRect.Contains(e.mousePosition))
                            {
                                model.selectOnlyPO(po);
                                editor.draggingThumbnailOfPO = po;
                                e.Use();
                            }
                        }
                    }
                    else if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type.ToString()))
                    {
                        EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);

                        // DROP ZONE

                        if (po.generator is Grouper && editor.editorState == AXNodeGraphEditorWindow.EditorState.DraggingNodePalette && editor.mouseIsDownOnPO != po && po != model.currentWorkingGroupPO)
                        {
                            if (editor.mostRecentThumbnailRect.Contains(e.mousePosition))
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneOverTex, ScaleMode.ScaleToFit, 1.0F);
                                editor.OverDropZoneOfPO = po;
                            }
                            else
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneTex, ScaleMode.ScaleToFit, 1.0F);
                            }
                        }
                    }
                }

                cur_y += lineHgt + bottomPadding + splineCanvasSize + gap;

                po.rect.height = cur_y;
                cur_y         += 4 * gap;
            }
            else
            {
                // no thumbnail
                cur_y         += 2 * lineHgt;
                po.rect.height = cur_y;
            }



            // INLETS
            // INPUT ITEMS
            // Parameter Lines

            //for (int i=0; i<po.parameters.Count; i++) {
            if ((po.inputControls != null && po.inputControls.children != null))
            {
                for (int i = 0; i < po.inputControls.children.Count; i++)
                {
                    p = (AXParameter)po.inputControls.children [i];


                    if (p.PType != AXParameter.ParameterType.Input)
                    {
                        continue;
                    }


                    //if ( p.DependsOn != null && !p.DependsOn.Parent.isOpen && ! p.Name.Contains ("External"))
                    //	continue;


                    //if (parametricObjects_Property != null)
                    if (model.parametricObjects != null)
                    {
                        // these points are world, not rlative to the this GUIWindow
                        p.inputPoint  = new Vector2(po.rect.x, po.rect.y + 100);
                        p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + cur_y + lineHgt / 2);
                    }
                }
            }



            // OUTLETS

            if (po.outputsNode != null)
            {
                for (int i = 0; i < po.outputsNode.children.Count; i++)
                {
                    p = (AXParameter)po.outputsNode.children [i];

                    if (p == null)
                    {
                        continue;
                    }

                    //if (p.hasInputSocket || ! p.hasOutputSocket)
                    if (p.PType != AXParameter.ParameterType.Output)
                    {
                        continue;
                    }


                    //if (parametricObjects_Property != null)
                    if (model.parametricObjects != null)
                    {
                        // these points are world, not relative to the this GUIWindow
                        p.inputPoint  = new Vector2(po.rect.x, po.rect.y + cur_y + lineHgt / 2);
                        p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + po.rect.width);


                        Rect pRect = new Rect(x1, cur_y, innerWidth, lineHgt);


                        //if (parameters_Property.arraySize > i)
                        if (po.parameters != null && po.parameters.Count > i)
                        {
                            int hgt = 0;

                            if (po.is2D())
                            {
                                hgt   = ParameterSplineGUI.OnGUI_Spline(pRect, editor, p);
                                cur_y = hgt + gap;
                            }
                            else
                            {
                                //hgt = ParameterGUI.OnGUI (pRect, editor, p);
                                //cur_y += hgt + gap;

                                Color dataColor = editor.getDataColor(p.Type);

                                // PERSONAL
                                if (!EditorGUIUtility.isProSkin)
                                {
                                    dataColor = new Color(dataColor.r, dataColor.b, dataColor.g, .3f);
                                }

                                GUI.color = dataColor;

                                buttonLabel = (editor.OutputParameterBeingDragged == p) ? "-" : "";
                                buttonRect  = new Rect(p.Parent.rect.width - pRect.height - 10, p.Parent.rect.width - 10, 2 * ArchimatixEngine.buttonSize, 2 * ArchimatixEngine.buttonSize);

                                // button color
                                if (editor.InputParameterBeingDragged != null)
                                {
                                    if (editor.InputParameterBeingDragged.Type != p.Type)
                                    {
                                        GUI.backgroundColor = inactiveColor;
                                    }
                                    else if (buttonRect.Contains(Event.current.mousePosition))
                                    {
                                        GUI.backgroundColor = Color.white;
                                    }
                                }
                                else if (editor.OutputParameterBeingDragged != null)
                                {
                                    if (editor.OutputParameterBeingDragged == p)
                                    {
                                        GUI.backgroundColor = Color.white;
                                    }
                                    else
                                    {
                                        GUI.backgroundColor = inactiveColor;
                                    }
                                }


                                if (GUI.Button(buttonRect, buttonLabel))
                                {
                                    if (editor.InputParameterBeingDragged != null && editor.InputParameterBeingDragged.Type != p.Type)
                                    {
                                        editor.InputParameterBeingDragged = null;
                                    }
                                    else
                                    {
                                        editor.outputSocketClicked(p);
                                    }
                                }
                            }
                        }
                    }
                }
            }



            // FOOTER //



            // STATS
            if (po.stats_VertCount > 0 || po.generator is MaterialTool)
            {
                string statsText;

                if (po.generator is MaterialTool)
                {
                    statsText = (po.generator as MaterialTool).texelsPerUnit.ToString("F0") + " Texels/Unit";
                }
                else
                {
                    statsText = po.stats_VertCount + " verts";

                    if (po.stats_TriangleCount > 0)
                    {
                        statsText += ", " + po.stats_TriangleCount + " tris";
                    }
                }

                GUIStyle   statlabelStyle        = GUI.skin.GetStyle("Label");
                TextAnchor prevStatTextAlignment = statlabelStyle.alignment;
                statlabelStyle.alignment    = TextAnchor.MiddleLeft;
                EditorGUIUtility.labelWidth = 500;
                GUI.Label(new Rect(10, po.rect.height - x2 + 2, 500, lineHgt), statsText);
                statlabelStyle.alignment = prevStatTextAlignment;
            }



            if (e.type == EventType.MouseDown && lowerRect.Contains(e.mousePosition))
            {
                editor.clearFocus();
                GUI.FocusWindow(po.guiWindowId);
            }

            // WINDOW RESIZE
            buttonRect = new Rect(po.rect.width - 16, po.rect.height - 17, 14, 14);
            if (e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition))
            {
                Undo.RegisterCompleteObjectUndo(model, "GUI Window Resize");

                editor.editorState             = AXNodeGraphEditorWindow.EditorState.DragResizingNodePalleteWindow;
                editor.DraggingParameticObject = po;
            }
            //GUI.Button ( buttonRect, "∆", GUIStyle.none);
            GUI.Button(buttonRect, editor.resizeCornerTexture, GUIStyle.none);


            if (e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition))
            {
            }

            //cur_y += lineHgt + gap;

            // Window title bar is the dragable area
            //GUI.DragWindow(headerRect);

            if (editor.draggingThumbnailOfPO == null || editor.draggingThumbnailOfPO != po)
            {
                GUI.DragWindow();
            }
        }
        // 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();



            // Reinstate the original functionality of the Grouper as simple combiner in addition to Groupees.
            if (inputs != null && inputs.Count > 0)
            {
                // ALL
                // Combine all paths
                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))
//
//						}
//					}
                }



                // 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.is2D())
                        {
                            if (src_po.Output != null && src_po.Output.polyTree != null)
                            {
                                P_Output.polyTree = src_po.Output.polyTree;
                            }
                            else
                            {
                                P_Output.polyTree = null;
                                P_Output.paths    = src_po.Output.paths;
                            }

                            P_Output.parametricObject.bounds = src_po.bounds;
                        }

                        P_Output.meshes = src_p.meshes;
                    }
                }
            }



            return(null);
        }
        // Update is called once per frame
        void Update()
        {
            if (!Application.isPlaying)
            {
                return;
            }


            bool byPlane = true;


            if (handle == null)
            {
                return;
            }

            AXParametricObject parametricObject = handle.parametricObject;



            // GET POSITION

            if (parametricObject.is2D())
            {
                context = parametricObject.model.transform.localToWorldMatrix * parametricObject.worldDisplayMatrix;

                if (parametricObject.generator.hasOutputsConnected() || parametricObject.is2D())
                {
                    context *= parametricObject.generator.localMatrix.inverse;
                }
                else
                {
                    context *= parametricObject.getAxisRotationMatrix().inverse *parametricObject.generator.localMatrix.inverse *parametricObject.getAxisRotationMatrix();
                }
            }
            else
            {
                // GROUPER MATRIX NOT WORKING....
                context = parametricObject.model.transform.localToWorldMatrix * parametricObject.generator.parametricObject.worldDisplayMatrix * (parametricObject.getAxisRotationMatrix() * parametricObject.generator.getLocalAlignMatrix()).inverse * parametricObject.generator.localMatrix.inverse;
            }


            // position handle by parmeters.
            positionHandleGameObject();



            double h_diff = 0;
            double v_diff = 0;


            if (mouseIsDown)
            {
                if (Input.touchCount == 1)
                {
                    // touch input - works better with deltaPosition
                    var touch = Input.GetTouch(0);
                    //var dx = touch.deltaPosition.x;
                    h_diff = (100.0 / Screen.width) * touch.deltaPosition.x;
                    v_diff = (100.0 / Screen.width) * touch.deltaPosition.y;
                }
                else
                {
                    // 0 touches: must be mouse input
                    h_diff = (5000 / Screen.width) * Input.GetAxis("Mouse X");
                    v_diff = (5000 / Screen.width) * Input.GetAxis("Mouse Y");
                }
                h_diff /= 5;
                v_diff /= 5;
                //Debug.Log(h_diff +", " + v_diff);



                //using plane
                if (byPlane)
                {
                    establishDrawingSurface();
                    //Vector3 prevPosition = transform.position;
                }



                // BASED ON PLANE
                Vector3 world_pos = transform.position;

                if (byPlane)
                {
                    Vector3 hit_position3D = sampleHitPoint();
                    world_pos          = hit_position3D - mouseDownDiff;
                    transform.position = world_pos;
                }



                Vector3 localPosition = context.inverse.MultiplyPoint3x4(world_pos);



                //transform.position = world_pos;

                //if (transform.position != prevPosition)
                if (h_diff != 0 || v_diff != 0)
                {
                    //Debug.Log("moved");



                    // Determine the orientation of the camera


                    //The normal OperatingSystemFamily the handle plane
                    //Debug.Log (lookV);

                    float threshold = .707f;

                    double diffX = -v_diff;
                    double diffZ = h_diff;

                    // This logic works with a normal vector

                    if (!byPlane)
                    {
                        if (lookV.x > 0 && lookV.z < 0)
                        {
                            diffX = (1 - lookV.x) * h_diff - lookV.x * v_diff;
                            diffZ = (1 + lookV.z) * h_diff - lookV.z * v_diff;
                        }
                        else if (lookV.x > 0 && lookV.z > 0)
                        {
                            diffX = -((lookV.x)) * h_diff - lookV.x * v_diff;
                            diffZ = (1 + lookV.z) * h_diff - lookV.z * v_diff;
                        }
                        else if (lookV.x < 0 && lookV.z > 0)
                        {
                            diffX = (1 + lookV.x) * h_diff + lookV.x * v_diff;
                            diffZ = (1 - lookV.z) * h_diff + lookV.z * v_diff;
                        }
                        else if (lookV.x > 0 && lookV.z > 0)
                        {
                            diffX = -((lookV.x)) * h_diff - (lookV.x) * v_diff;
                            diffZ = (1 + lookV.z) * h_diff - lookV.z * v_diff;    //(-lookV.x + lookV.z) * v_diff;
                        }
                        else if (lookV.z > threshold)                             // pointing forwards
                        {
                            diffX = -h_diff;
                            diffZ = -v_diff;
                        }
                        else if (lookV.z < -threshold)
                        {
                            // pointing backwards
                            diffX = h_diff;
                            diffZ = v_diff;
                        }
                        else if (lookV.x > 0)
                        {
                            // pointing right
                            diffX = -h_diff;
                            diffZ = v_diff;
                        }
                        else
                        {
                            // pointing left
                            diffX = v_diff;
                            diffZ = -h_diff;
                        }
                    }



                    AXHandle han = handle;


                    string hanString = "han_y";
                    float  posV      = localPosition.y;

                    if (parametricObject.is3D())
                    {
                        hanString = "han_z";
                        posV      = localPosition.z;
                    }

                    if (byPlane)
                    {
                        parametricObject.setVar("han_x", (localPosition.x));
                        if (parametricObject.is3D())
                        {
                            parametricObject.setVar("han_z", world_pos.z);
                        }
                        else
                        {
                            parametricObject.setVar("han_y", localPosition.y);
                        }
                    }
                    else
                    {
                        // Relative slide of cursor
                        parametricObject.setVar("han_x", (localPosition.x + (float)diffX));
                        parametricObject.setVar(hanString, (posV + (float)diffZ));
                    }

                    // From plane
//					parametricObject.setVar("han_x", localPosition.x);
//					parametricObject.setVar("han_y", localPosition.y);
//					parametricObject.setVar("han_z", localPosition.z);


                    // EACH EXPRESSION
                    for (int i = 0; i < han.expressions.Count; i++)
                    {
                        if (han.expressions [i] == "")
                        {
                            continue;
                        }

                        string expression = Regex.Replace(han.expressions [i], @"\s+", "");

                        string paramName  = expression.Substring(0, expression.IndexOf("="));
                        string definition = expression.Substring(expression.IndexOf("=") + 1);
                        //Debug.Log (param + " --- " + definition);

                        try {
                            if (parametricObject.getParameter(paramName).Type == AXParameter.DataType.Int)
                            {
                                parametricObject.initiateRipple_setIntValueFromGUIChange(paramName, Mathf.RoundToInt((float)parametricObject.parseMath(definition)));
                            }
                            else
                            {
                                parametricObject.initiateRipple_setFloatValueFromGUIChange(paramName, (float)parametricObject.parseMath(definition));
                            }
                        } catch (System.Exception e) {
                            parametricObject.codeWarning = "10. Handle error: Please check syntax of: \"" + definition + "\" " + e.Message;
                        }
                    }

                    parametricObject.model.isAltered();
                    //parametricObject.model.autobuild();
                }
            }
        }
Example #11
0
        // DO THE ACTUAL SAVE
        public static void saveParametricObject(AXParametricObject po, bool withInputSubparts, string filepathname)
        {
            //Debug.Log(filepathname);
            //EditorUtility.DisplayDialog("Archimatix Library", "Saving to Library: This may take a few moments.", "Ok");

            po.readIntoLibraryFromRelativeAXOBJPath = ArchimatixUtils.getRelativeFilePath(filepathname);

            Library.recentSaveFolder = System.IO.Path.GetDirectoryName(filepathname);



            // If this head po has a grouperKey, lose it!
            // This is because when it is later instantiated,
            // that grouper may not exist or may not be the desired place for this.

            po.grouperKey = null;



            // gather relations as you go...
            List <AXRelation> rels = new List <AXRelation>();

            // BUILD JSON STRING
            StringBuilder sb = new StringBuilder();

            sb.Append("{");
            sb.Append("\"parametric_objects\":[");
            sb.Append(JSONSerializersAX.ParametricObjectAsJSON(po));

            // gather rels
            foreach (AXParameter p in po.parameters)
            {
                foreach (AXRelation rr in p.relations)
                {
                    if (!rels.Contains(rr))
                    {
                        rels.Add(rr);
                    }
                }
            }



            // SUB NODES

            if (withInputSubparts)
            {
                // GATHER SUB_NODES
                //Debug.Log("Start gather");
                po.gatherSubnodes();
                //Debug.Log("End gather");

                foreach (AXParametricObject spo in po.subnodes)
                {
                    //Debug.Log("-- " + spo.Name);
                    sb.Append(',' + JSONSerializersAX.ParametricObjectAsJSON(spo));

                    // gather rels
                    foreach (AXParameter p in spo.parameters)
                    {
                        foreach (AXRelation rr in p.relations)
                        {
                            if (!rels.Contains(rr))
                            {
                                rels.Add(rr);
                            }
                        }
                    }
                }
            }
            sb.Append("]");



            // add relations to json
            string thecomma;

            // RELATIONS
            if (rels != null && rels.Count > 0)
            {
                sb.Append(", \"relations\": [");                                // begin parametric_objects

                thecomma = "";
                foreach (AXRelation rr in rels)
                {
                    sb.Append(thecomma + rr.asJSON());
                    thecomma = ", ";
                }
                sb.Append("]");
            }



            sb.Append("}");



            // *** SAVE AS ASSET ***



            // Since we have added the newItem to the live library,
            // generating this new file will not force a recreation of the library from the raw JSON file.
            File.WriteAllText(filepathname, sb.ToString());



            // THUMBNAIL TO PNG



            if (po.is2D())
            {
                Library.cache2DThumbnail(po);
            }
            else
            {
                Thumbnail.BeginRender();
                Thumbnail.render(po, true);
                Thumbnail.EndRender();
            }
            //string thumb_filename = System.IO.Path.ChangeExtension(filepathname, ".png");
            string filename = System.IO.Path.GetFileNameWithoutExtension(filepathname);

            string prefix         = (po.is2D()) ? "zz-AX-2DLib-" : "zz-AX-3DLib-";
            string thumb_filename = System.IO.Path.ChangeExtension(filepathname, ".jpg");

            thumb_filename = thumb_filename.Replace(filename, prefix + filename);



            byte[] bytes = po.thumbnail.EncodeToJPG();
            //File.WriteAllBytes(libraryFolder + "data/"+ po.Name + ".png", bytes);
            File.WriteAllBytes(thumb_filename, bytes);

            //AssetDatabase.Refresh();

            string thumbnailRelativePath = ArchimatixUtils.getRelativeFilePath(thumb_filename);

            //Debug.Log(path);
            AssetDatabase.ImportAsset(thumbnailRelativePath);
            TextureImporter importer = AssetImporter.GetAtPath(thumbnailRelativePath) as TextureImporter;

            if (importer != null)
            {
                importer.textureType    = TextureImporterType.GUI;
                importer.maxTextureSize = 256;



                                #if UNITY_5_5_OR_NEWER
                importer.textureCompression = TextureImporterCompression.Uncompressed;
                                #else
                importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
                                #endif
            }

            AssetDatabase.WriteImportSettingsIfDirty(thumbnailRelativePath);


            // Save the recent path to prefs
            EditorPrefs.SetString("LastLibraryPath", System.IO.Path.GetDirectoryName(filepathname));


            EditorUtility.DisplayDialog("Archimatix Library", "ParametricObject saved to " + System.IO.Path.GetDirectoryName(thumbnailRelativePath) + " as " + filename, "Great, thanks!");

            Texture2D tex = (Texture2D)AssetDatabase.LoadAssetAtPath(thumbnailRelativePath, typeof(Texture2D));



            LibraryItem newItem = new LibraryItem(po);
            newItem.icon = tex;
            ArchimatixEngine.library.addLibraryItemToList(newItem);
            ArchimatixEngine.library.sortLibraryItems();


            ArchimatixEngine.saveLibrary();



            AssetDatabase.Refresh();

            //Debug.Log("yo 2");
            //ArchimatixEngine.library.readLibraryFromFiles();
        }
Example #12
0
    public void doPO(AXParametricObject po)
    {
        GUIStyle labelstyle = GUI.skin.GetStyle("Label");

        //int fontSize = labelstyle.fontSize;



        labelstyle.fontSize = 20;


        GUILayout.BeginHorizontal();
        GUILayout.Space(40);
        Rect rect = GUILayoutUtility.GetLastRect();

        // NAME
        GUILayout.Label(po.Name);


        labelstyle.fontSize = 12;
        GUILayout.EndHorizontal();

        if (po.is2D() && po.generator.hasOutputsReady())
        {
            AXParameter output_p = po.generator.getPreferredOutputParameter();
            GUIDrawing.DrawPathsFit(output_p, new Vector2(32, rect.y + 10), 32);
        }
        else if (ArchimatixEngine.nodeIcons != null && ArchimatixEngine.nodeIcons.ContainsKey(po.Type))
        {
            GUI.DrawTexture(new Rect(16, rect.y - 5, 32, 32), ArchimatixEngine.nodeIcons[po.Type], ScaleMode.ScaleToFit, true, 1.0F);
        }

        if (showTitle(po))
        {
            GUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            EditorGUIUtility.labelWidth = 0;
            po.isActive = EditorGUILayout.Toggle(po.isActive, GUILayout.MaxWidth(20));
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "isActive value change for " + po.Name);
                po.model.autobuild();
                po.generator.adjustWorldMatrices();
            }

            EditorGUIUtility.labelWidth = 0;
            po.Name = GUILayout.TextField(po.Name);



            if (po.is3D())
            {
                EditorGUIUtility.labelWidth = 35;
                EditorGUI.BeginChangeCheck();
                po.axStaticEditorFlags = (AXStaticEditorFlags)EditorGUILayout.EnumMaskField("Static", po.axStaticEditorFlags);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Static value change for " + po.Name);

                    po.setUpstreamersToYourFlags();
                    // post dialog to change all children...
                    po.model.autobuild();

                    /*
                     * int option = EditorUtility.DisplayDialogComplex("Change Static Flags?",
                     *      "Do you want to disable the Lightmap Static flag for all the child objects as well? ",
                     *
                     *      "No, only this ParametricObject",
                     *      "Yes, change children",
                     *      "Cancel");
                     *
                     *
                     * switch( option )
                     * {
                     *      // Save Scene
                     *      case 0:
                     *              Debug.Log("ONLY");
                     *              break;
                     *
                     *      // Save and Quit.
                     *
                     *      // SAVE THIS MASK FOR CHILDREN AS WELL.
                     *      case 1:
                     *              Debug.Log("CHILDREN");
                     *              break;
                     *
                     *      case 2:
                     *              Debug.Log("CANCEL");
                     *              break;
                     *
                     *
                     *      default:
                     *              Debug.LogError( "Unrecognized option." );
                     *              break;
                     * }
                     */
                }
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Select"))
            {
                po.model.selectAndPanToPO(po);
            }


            GUILayout.EndHorizontal();
        }


        if (po.is3D())
        {
            EditorGUIUtility.labelWidth = 35;

            GUILayout.BeginHorizontal();


            // TAGS
            EditorGUI.BeginChangeCheck();
            po.tag = EditorGUILayout.TagField("Tag:", po.tag);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "Tag value change for " + po.Name);
            }



            // LAYERS
            EditorGUI.BeginChangeCheck();
            int intval = EditorGUILayout.LayerField("Layer:", po.layer);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "Layer value change for " + po.Name);
                po.layer = intval;
            }


            GUILayout.EndHorizontal();

            bool hasMeshRenderer = !po.noMeshRenderer;
            EditorGUI.BeginChangeCheck();
            hasMeshRenderer = EditorGUILayout.ToggleLeft("Mesh Renderer", hasMeshRenderer);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "hasMeshRenderer");
                po.noMeshRenderer = !hasMeshRenderer;
            }
        }
        else if (po.generator is MaterialTool)
        {
            EditorGUI.BeginChangeCheck();

            //float thumbSize = 16;

            po.axMat.mat = (Material)EditorGUILayout.ObjectField(po.axMat.mat, typeof(Material), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "Material");

                po.model.remapMaterialTools();
                po.model.autobuild();
            }
        }



        AXParameter p;



        //EditorGUIUtility.labelWidth = 200;//EditorGUIUtility.currentViewWidth-16;

        if (po.geometryControls != null && po.geometryControls.children != null)
        {
            for (int i = 0; i < po.geometryControls.children.Count; i++)
            {
                p = po.geometryControls.children[i] as AXParameter;

                EditorGUIUtility.labelWidth = 150;



                // PARAMETERS
                switch (p.Type)
                {
                // ANIMATION_CURVE

                case AXParameter.DataType.AnimationCurve:

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.CurveField(p.animationCurve);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "ModifierCurve");
                        p.parametricObject.model.isAltered(28);
                    }

                    break;

                // FLOAT
                case AXParameter.DataType.Float:
                    AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_" + p.Name);

                    GUILayout.BeginHorizontal();



                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("FloatField_" + p.Name);
                    p.FloatVal = EditorGUILayout.FloatField(p.Name, p.FloatVal);
                    if (EditorGUI.EndChangeCheck())
                    {
                        //Debug.Log(p.FloatVal);
                        Undo.RegisterCompleteObjectUndo(po.model, "value change for " + p.Name);
                        p.parametricObject.initiateRipple_setFloatValueFromGUIChange(p.Name, p.FloatVal);
                        p.parametricObject.model.isAltered(27);
                        p.parametricObject.generator.adjustWorldMatrices();
                    }

                    // Expose
                    EditorGUI.BeginChangeCheck();
                    p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20));
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter");

                        if (p.exposeAsInterface)
                        {
                            p.parametricObject.model.addExposedParameter(p);
                        }
                        else
                        {
                            p.parametricObject.model.removeExposedParameter(p);
                        }
                    }


                    GUILayout.EndHorizontal();
                    break;

                // INT
                case AXParameter.DataType.Int:

                    GUILayout.BeginHorizontal();



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

                    // Expose
                    EditorGUI.BeginChangeCheck();
                    p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20));
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter");

                        if (p.exposeAsInterface)
                        {
                            p.parametricObject.model.addExposedParameter(p);
                        }
                        else
                        {
                            p.parametricObject.model.removeExposedParameter(p);
                        }
                    }


                    GUILayout.EndHorizontal();
                    break;

                // BOOL
                case AXParameter.DataType.Bool:
                    //EditorGUIUtility.currentViewWidth-16;

                    GUILayout.BeginHorizontal();



                    //EditorGUIUtility.labelWidth = 150;
                    EditorGUI.BeginChangeCheck();
                    p.boolval = EditorGUILayout.Toggle(p.Name, p.boolval);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(po.model, " value change for " + p.Name);
                        p.parametricObject.initiateRipple_setBoolParameterValueByName(p.Name, p.boolval);
                        //p.parametricObject.model.autobuild();
                        p.parametricObject.model.isAltered(27);
                        //p.parametricObject.generator.adjustWorldMatrices();
                    }

                    GUILayout.FlexibleSpace();

                    // Expose
                    EditorGUI.BeginChangeCheck();
                    p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20));
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter");

                        if (p.exposeAsInterface)
                        {
                            p.parametricObject.model.addExposedParameter(p);
                        }
                        else
                        {
                            p.parametricObject.model.removeExposedParameter(p);
                        }
                    }


                    GUILayout.EndHorizontal();
                    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(
                        p.Name,
                        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;
                }
                }

                //if (p.PType != AXParameter.ParameterType.None && p.PType != AXParameter.ParameterType.GeometryControl)
                //	continue;
            }
        }


        // PROTOTYPE
        if (po.is3D())
        {
            po.displayPrototypes = EditorGUILayout.Foldout(po.displayPrototypes, "Prototypes");

            if (po.displayPrototypes)
            {
                EditorGUI.BeginChangeCheck();
                po.prototypeGameObject = (GameObject)EditorGUILayout.ObjectField(po.prototypeGameObject, typeof(GameObject), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Prototype GameObject set for " + po.model.name);
                    if (po.prototypeGameObject != null)
                    {
                        AXPrototype proto = (AXPrototype)po.prototypeGameObject.GetComponent("AXPrototype");
                        if (proto == null)
                        {
                            proto = po.prototypeGameObject.AddComponent <AXPrototype>();
                        }
                        if (!proto.parametricObjects.Contains(po))
                        {
                            proto.parametricObjects.Add(po);
                        }
                    }
                    po.model.autobuild();
                }
            }
        }


        if (po.selectedAXGO != null)
        {
            GUILayout.Label(po.selectedAXGO.consumerAddress);
        }
        GUILayout.Space(30);
    }