Example #1
0
    void GenerateDesign(AXModel mod)
    {
        AXParametricObject nodePO = mod.parametricObjects.FirstOrDefault(p => p.Name == "House Roof Design");

        nodePO.curve.Clear();

        float point0 = Random.Range(-11.1f, -8f);
        float point1 = Random.Range(-10f, -8f);
        float point2 = Random.Range(-11f, -8f);
        float point3 = Random.Range(-11f, -8f);
        float point4 = Random.Range(-10.5f, -8f);
        float point5 = Random.Range(-11.1f, -8f);

        //assign point values for curves
        nodePO.curve.Add(new CurvePoint(point0, -17.37f));
        nodePO.curve.Add(new CurvePoint(point1, -14f));
        nodePO.curve.Add(new CurvePoint(point2, -11f));
        nodePO.curve.Add(new CurvePoint(point3, -8));
        nodePO.curve.Add(new CurvePoint(point4, -6f));
        nodePO.curve.Add(new CurvePoint(point5, -3.75f));
        nodePO.curve.Add(new CurvePoint(-11.4f, -3.75f));
        nodePO.curve.Add(new CurvePoint(-10.8f, -6f));
        nodePO.curve.Add(new CurvePoint(-11.3f, -8));
        nodePO.curve.Add(new CurvePoint(-11.3f, -11f));
        nodePO.curve.Add(new CurvePoint(-10.3f, -14f));
        nodePO.curve.Add(new CurvePoint(-11.4f, -17.37f));
    }
Example #2
0
        public void setupFullReferencesInModel(AXModel model)
        {
            //Debug.Log ("SETTING UP REFERENCES IN MODEL pA_guid="+pA_guid);
            // USE THIS TO INITIALIZE REFERENCES AFTER DESERIALIZATION

            if (pA_guid != null && pB_guid != "")
            {
                // - pA
                //Debug.Log ("pA_guid="+pA_guid);
                pA = model.getParameterByGUID(pA_guid);
                if (pA != null && !pA.relations.Contains(this))
                {
                    //Debug.Log ("AXRelation::setupReferencesInModel - relations.add pA="+pA.Name+" : " + pA.Guid);
                    pA.relations.Add(this);
                }
                // - pA
                pB = model.getParameterByGUID(pB_guid);

                if (pB != null && !pB.relations.Contains(this))
                {
                    //Debug.Log ("AXRelation::setupReferencesInModel - relations.add pB="+pB.Name+" : " + pB.Guid);
                    pB.relations.Add(this);
                }
            }
            //Debug.Log (toString ());
        }
    public static void displayModelOfSelectedGameObject()
    {
        /*
         * When the selection has changed,
         * 1. select the AXModel in the scene
         * 2. within the model select the PO
         * 3. if the PO is the same as last time, try to select PO's consumer.
         * 4. If it has no consumer, select an input PO upstream.
         */


        if (ArchimatixEngine.currentModel == null)
        {
            return;
        }

        //Debug.Log("SELECTION CHANGED::"+ Selection.activeGameObject.name);

        // IS it an AX gameObject? That is, a sub gameobject of the model root?
        AXModel model = (AXModel)Selection.activeGameObject.GetComponent <AXModel>();

        if (model != null)
        {
            model.selectFirstHeadPO();
        }
        //Repaint ();
    }
    public static GameObject createNewModel(string m_name = null)
    {
        GameObject modelGO = new GameObject();
        AXModel    model   = modelGO.AddComponent <AXModel>();

        ArchimatixEngine.currentModel = model;



        if (String.IsNullOrEmpty(m_name))
        {
            // for auto naming, get highest count...
            // (can't use static variable for this, since it is cleared when scene reloads).
            int       highestnum = 0;
            AXModel[] axModels   = GameObject.FindObjectsOfType(typeof(AXModel)) as AXModel[];
            foreach (AXModel m in axModels)
            {
                String[] numbers = Regex.Split(m.name, @"\D+");
                if (numbers != null && numbers.Length > 0)
                {
                    string numString = numbers[numbers.Length - 1];
                    if (!string.IsNullOrEmpty(numString))
                    {
                        int num = int.Parse(numString);

                        if (num > highestnum)
                        {
                            highestnum = num;
                        }
                    }
                }
            }
            highestnum++;

            modelGO.name = "AXModel_" + highestnum;
        }
        else
        {
            modelGO.name = m_name;
        }

        Selection.activeGameObject = modelGO;


        model.axMat = new AXMaterial();

        model.axMat.mat     = (Material)AssetDatabase.LoadAssetAtPath(ArchimatixEngine.ArchimatixAssetPath + "/Materials/AX_GridPurple.mat", typeof(Material));
        model.axMat.physMat = (PhysicMaterial)AssetDatabase.LoadAssetAtPath(ArchimatixEngine.ArchimatixAssetPath + "/Materials/AX_DefaultPhysicMaterial.physicMaterial", typeof(PhysicMaterial));
        model.axMat.density = 1;

        //if (ArchimatixEngine.graphEditorIsOpen())
        if (ArchimatixEngine.useKyle)
        {
            ArchimatixEngine.createScalingFigure();
        }


        return(modelGO);
    }
 public static void makeLightmapStatic(AXModel model)
 {
     if (model.generatedGameObjects != null)
     {
         Transform[] transforms = model.generatedGameObjects.GetComponentsInChildren <Transform> ();
         foreach (Transform transform in transforms)
         {
             if (transform.GetComponent <Rigidbody> () == null)
             {
                 GameObjectUtility.SetStaticEditorFlags(transform.gameObject, StaticEditorFlags.LightmapStatic);
             }
         }
         model.buildStatus = AXModel.BuildStatus.Lightmapped;
     }
 }
    // MODEL STATIC FLAGS


    public static void makeBatchingStatic(AXModel model)
    {
        Debug.Log("makeBatchingStatic");
        if (model.generatedGameObjects != null)
        {
            Transform[] transforms = model.generatedGameObjects.GetComponentsInChildren <Transform> ();
            foreach (Transform transform in transforms)
            {
                if (transform.GetComponent <Rigidbody> () == null)
                {
                    GameObjectUtility.SetStaticEditorFlags(transform.gameObject, StaticEditorFlags.BatchingStatic);
                }
            }
        }
    }
    public static AXParametricObject addNodeToCurrentModel(string nodeName, bool panTo = true, AXParametricObject basedOnPO = null)
    {
        AXModel model = getOrMakeSelectedModel();


        Undo.RegisterCompleteObjectUndo(model, "Add Generator named " + nodeName);


        AXParametricObject npo = model.createNode(nodeName, panTo, basedOnPO);

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

        if (basedOnPO != null)
        {
            //Debug.Log("basedOnPO.Name="+basedOnPO.Name);
            basedOnPO.copyTransformTo(npo);
        }



        ArchimatixEngine.repaintGraphEditorIfExistsAndOpen();


        bool isInstanceofCurrentGrouper = ((npo.generator is IReplica) && model.currentWorkingGroupPO != null && basedOnPO == model.currentWorkingGroupPO);


        if (model.currentWorkingGroupPO != null)
        {
            List <AXParametricObject> npos = new List <AXParametricObject>();
            npos.Add(npo);


            if (!isInstanceofCurrentGrouper)
            {
                model.currentWorkingGroupPO.addGroupees(npos);
            }
        }

        if (isInstanceofCurrentGrouper)
        {
            model.currentWorkingGroupPO = model.currentWorkingGroupPO.grouper;
        }

        return(npo);
    }
Example #8
0
        public static void pasteFromJSONString(AXModel m, string json_string)
        {
            List <AXParametricObject> poList       = new List <AXParametricObject>();
            List <AXRelation>         relationList = new List <AXRelation>();


            AXParametricObject po = null;

            Debug.Log(json_string);

            AX.SimpleJSON.JSONNode jn = AX.SimpleJSON.JSON.Parse(json_string);

            if (jn == null || jn["parametric_objects"] == null)
            {
                return;
            }

            foreach (AX.SimpleJSON.JSONNode pn in jn["parametric_objects"].AsArray)
            {
                po      = JSONSerializersAX.ParametricObjectFromJSON(pn);
                po.rect = new Rect(po.rect.x + 125, po.rect.y + 125, po.rect.width, po.rect.height);
                poList.Add(po);
            }

            //Debug.Log ("TEST: " + poList.Count + " - " + poList[0].isHead() + " - " + poList[0].generator + " .... " + jn["model_guid"].Value + " - " + m.Guid);
            if (poList.Count == 1 && poList[0].isHead() && jn["model_guid"].Value == m.Guid)
            {
                // common case of copying and pasting a single palette which is a head into the same model
                // as the source po
                // Find the source and instance it.
                AXParametricObject        src_po   = m.getParametricObjectByGUID(poList[0].Guid);
                List <AXParametricObject> src_List = new List <AXParametricObject>();
                src_List.Add(src_po);

                m.instancePOsFromList(src_List);
            }

            else
            {
                foreach (AX.SimpleJSON.JSONNode rNode in jn["relations"].AsArray)
                {
                    relationList.Add(AXRelation.fromJSON(rNode));
                }
                Debug.Log("COPYINGING: " + poList.Count + ", " + relationList.Count);
                // really duplicate
                m.addAndRigUp(poList, relationList);
            }
        }
Example #9
0
    void GenerateBackyard(AXModel mod)
    {
        //changes the backyard content
        float choice = Random.Range(0f, 1f);

        mod.getParameter("Chair_Enabled").initiateRipple_setBoolValueFromGUIChange(false);
        mod.getParameter("Pool_Enabled").initiateRipple_setBoolValueFromGUIChange(false);
        mod.getParameter("Statue_Enabled").initiateRipple_setBoolValueFromGUIChange(false);

        if (choice < .4f)
        {
            //changes the position of the chair
            mod.getParameter("Chair_Enabled").initiateRipple_setBoolValueFromGUIChange(true);
            mod.getParameter("Chair_Trans_X").initiateRipple_setFloatValueFromGUIChange(Random.Range(-8.5f, 9.5f));
            mod.getParameter("Chair_Trans_Z").initiateRipple_setFloatValueFromGUIChange(Random.Range(-3.5f, 2.5f));
            mod.getParameter("Chair_Rot_Y").initiateRipple_setFloatValueFromGUIChange(Random.Range(0f, 360f));
        }

        else if (choice < .65f)
        {
            //changes the scale of the pool
            mod.getParameter("Pool_Enabled").initiateRipple_setBoolValueFromGUIChange(true);
            mod.getParameter("Pool_Scale_X").initiateRipple_setFloatValueFromGUIChange(Random.Range(0.5f, 2.5f));
            mod.getParameter("Pool_Scale_Y").initiateRipple_setFloatValueFromGUIChange(Random.Range(0.1f, 1.5f));
            mod.getParameter("Pool_Scale_Z").initiateRipple_setFloatValueFromGUIChange(Random.Range(0.1f, 1f));

            //changes the pool to a new random material
            int index = Random.Range(0, Pool.Count);
            swimmingPool.parametricObject.axMat.mat = Pool[index];
        }

        else
        {
            //changes the scale/position of the statue
            float scaleX = Random.Range(0.5f, 4.5f);
            float scaleZ = Random.Range(0.5f, 1.5f);
            mod.getParameter("Statue_Enabled").initiateRipple_setBoolValueFromGUIChange(true);
            mod.getParameter("Statue_Scale_X").initiateRipple_setFloatValueFromGUIChange(scaleX);
            mod.getParameter("Statue_Scale_Z").initiateRipple_setFloatValueFromGUIChange(scaleZ);
            mod.getParameter("Statue_Rot_Y").initiateRipple_setFloatValueFromGUIChange(Random.Range(0f, 360f));
            mod.getParameter("Statue_Trans_X").initiateRipple_setFloatValueFromGUIChange(Random.Range(-10f + scaleX, 10f - scaleX));
            mod.getParameter("Statue_Trans_Z").initiateRipple_setFloatValueFromGUIChange(Random.Range(-3f + scaleX, 3f - scaleX));

            //changes the statue to a new random material
            int index1 = Random.Range(0, Statue.Count);
            monument.parametricObject.axMat.mat = Statue[index1];
        }
    }
Example #10
0
        // It would be preferable to have these serializers in
        // the classes to keep there private parts private.
        // Unfortunately, since there are cases where the AssetDatabase needs to be accessed,
        // these must be in an editor script :-(


        #region Model JSON

        // MODEL JSON SERIALIZATION
        public static string Model_asJSON(AXModel m)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("{");

            sb.Append("\"guid\":\"" + m.Guid + "\"");
            sb.Append(", \"name\":\"" + m.name + "\"");

            string thecomma = "";

            // PARAMETRIC_OBJECTS
            sb.Append(", \"parametric_objects\": [");                           // begin parametric_objects

            thecomma = "";
            foreach (AXParametricObject po in m.parametricObjects)
            {
                sb.Append(thecomma + JSONSerializersAX.ParametricObjectAsJSON(po));
                thecomma = ", ";
            }

            sb.Append("]");                                                             // end parametric_objects



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

                thecomma = "";
                foreach (AXRelation r in m.relations)
                {
                    sb.Append(thecomma + r.asJSON());
                    thecomma = ", ";
                }
            }

            sb.Append("]");                                                             // end parametric_objects


            // end model
            sb.Append("}");

            return(sb.ToString());
        }
    public static void makeLightMapUVs(AXModel model)
    {
        //Debug.Log("Making secondary");
        if (model.generatedGameObjects != null)
        {
            List <Mesh> meshesProcessed = new List <Mesh> ();



            Transform[] transforms = model.generatedGameObjects.GetComponentsInChildren <Transform> ();
            foreach (Transform transform in transforms)
            {
                if (transform.GetComponent <Rigidbody> () == null)
                {
                    AXGameObject axgo = transform.gameObject.GetComponent <AXGameObject>();

                    if (axgo != null && axgo.parametricObject != null && ((axgo.parametricObject.axStaticEditorFlags & AXStaticEditorFlags.LightmapStatic) == AXStaticEditorFlags.LightmapStatic))
                    {
                        //Debug.Log(transform.gameObject.name + " gets secondary");
                        MeshFilter meshFilter = transform.gameObject.GetComponent <MeshFilter> ();

                        if (meshFilter != null)
                        {
                            Mesh mesh = meshFilter.sharedMesh;

                            if (!meshesProcessed.Contains(mesh))
                            {
                                Debug.Log("doin' it!");


                                Unwrapping.GenerateSecondaryUVSet(mesh);
                                //Mesh tmpMesh = mesh;

                                //tmpMesh.uv2 = mesh.uv2;

                                meshesProcessed.Add(mesh);
                            }
                            //GameObjectUtility.SetStaticEditorFlags (transform.gameObject, StaticEditorFlags.LightmapStatic);
                        }
                    }
                }
            }
            model.buildStatus = AXModel.BuildStatus.lightmapUVs;
        }
    }
Example #12
0
    void GenerateHouse()
    {
        //ensures houses are created in a horizontal line
        float oldRandX = randX;

        randX = Random.Range(SizeRange.x, SizeRange.y);
        randY = Random.Range(SizeRange.x, SizeRange.y);
        randZ = Random.Range(SizeRange.x, SizeRange.y);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            distX += (10.2f * randX) + (10.2f * oldRandX);
        }

        if (Input.GetKeyDown(KeyCode.RightShift) || Input.GetKeyDown(KeyCode.LeftShift))
        {
            distX  = posX;
            distZ += (27.5f * SizeRange.y);
        }

        //Creates a new house
        AXModel newModel = Instantiate(model, new Vector3(distX, model.transform.position.y, distZ), Quaternion.identity);

        GenerateDesign(newModel);

        //changes the width of the landscape
        newModel.getParameter("Full House_Scale_X").initiateRipple_setFloatValueFromGUIChange(randX);
        //newModel.GetComponentInChildren<TerrainGenerator>().scaleX = randX;
        //field.scaleX = randX;

        //changes the height of the landscape
        newModel.getParameter("Full House_Scale_Y").initiateRipple_setFloatValueFromGUIChange(randY);
        //newModel.GetComponentInChildren<TerrainGenerator>().scaleY = randY;
        //field.scaleY = randY;

        //changes the length of the landscape
        newModel.getParameter("Full House_Scale_Z").initiateRipple_setFloatValueFromGUIChange(randZ);
        //newModel.GetComponentInChildren<TerrainGenerator>().scaleZ = randZ;
        //field.scaleZ = randZ;

        GenerateBackyard(newModel);

        newModel.build();
    }
Example #13
0
    // Use this for initialization

    protected void InitializeController()
    {
        // Assume that this controller is attached to a GameObject
        // under the AXModel's GameObject.

        if (model == null && transform.parent != null)
        {
            model = transform.parent.gameObject.GetComponent <AXModel>();
        }


        // Build the model to make sure its
        // starting form reflects all its internal parameters.
        if (model != null)
        {
            // BIND THE EXPOSED RUNTIME PARAMETERS
            // This way you don't have to do the model lookup with
            // each seting or getting of the parameter value.
            InitializeParameterReferences();

            // Make sure the model is built with current parameter values.
            model.autobuild();
        }
    }
Example #14
0
        public override void OnSceneGUI()
        {
            AXModel model = ArchimatixEngine.currentModel;


            FreeCurve gener = (FreeCurve)generator;

            Event e = Event.current;



            if (model != null)
            {
                Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;                // * generator.localMatrix;



                drawGUIControls();



                if ((ArchimatixEngine.sceneViewState == ArchimatixEngine.SceneViewState.AddPoint || (e.type == EventType.mouseDrag && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0)) && !e.alt)
                {
                    Vector3 v1 = context.MultiplyPoint3x4(Vector3.zero);
                    Vector3 v2 = context.MultiplyPoint3x4(new Vector3(100, 0, 0));
                    Vector3 v3 = context.MultiplyPoint3x4(new Vector3(0, 100, 0));

                    //Debug.Log ("-"+ArchimatixEngine.sceneViewState + "- plane points: " + v1 + ", " + v2+ ", " + v3 );


                    Plane drawingSurface = new Plane(v1, v2, v3);


                    //Matrix4x4 = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;// * generator.localMatrix.inverse;



                    Ray ray = HandleUtility.GUIPointToWorldRay(e.mousePosition);

                    float   rayDistance = 0;
                    Vector3 hitPoint;



                    // Point on Plane
                    if (drawingSurface.Raycast(ray, out rayDistance))
                    {
                        hitPoint = ray.GetPoint(rayDistance);


                        Vector3 hit_position3D = new Vector3(hitPoint.x, hitPoint.y, hitPoint.z);



                        if (ArchimatixEngine.snappingOn())
                        {
                            hit_position3D = AXGeometryTools.Utilities.SnapToGrid(hit_position3D, parametricObject.model.snapSizeGrid);
                        }



                        int nearId = HandleUtility.nearestControl;

                        if (nearId == 0)
                        {
                            Color cyan = Color.cyan;
                            cyan.a = .1f;

                            float hScale = .09f * HandleUtility.GetHandleSize(hit_position3D);
                            float lScale = 5 * hScale;

                            Handles.color = cyan;
                            Handles.DrawSolidDisc(hit_position3D,
                                                  Vector3.up,
                                                  hScale);

                            cyan.a        = .8f;
                            Handles.color = cyan;
                            Handles.DrawWireDisc(hit_position3D,
                                                 Vector3.up,
                                                 2 * hScale);


                            Handles.DrawLine(hit_position3D + lScale * Vector3.forward, hit_position3D - lScale * Vector3.forward);

                            //Handles.color = Color.white;
                            Handles.DrawLine(hit_position3D + lScale * Vector3.right, hit_position3D - lScale * Vector3.right);


                            // put visual cue under mouse....
                            //Debug.Log (hitPoint);
                        }



                        hitPoint = context.inverse.MultiplyPoint3x4(hitPoint);

                        Vector2 hit_position2D = new Vector2(hitPoint.x, hitPoint.y);

                        if (ArchimatixEngine.snappingOn())
                        {
                            hit_position2D = AXGeometryTools.Utilities.SnapToGrid(hit_position2D, parametricObject.model.snapSizeGrid);
                        }


                        // EVENTS

                        if (e.type == EventType.MouseDown && !e.alt && nearId == 0 && e.button == 0)
                        {
                            ArchimatixEngine.isPseudoDraggingSelectedPoint = -1;

                            if (gener != null)
                            {
                                if (!e.control)                                  // add to end of line
                                {
                                    // ADD POINT AT END

                                    gener.parametricObject.curve.Add(new CurvePoint(hit_position2D.x, hit_position2D.y));
                                    gener.selectedIndex = gener.parametricObject.curve.Count - 1;
                                }
                                else                                 // ADD POINT TO BEGINNING
                                {
                                    gener.parametricObject.curve.Insert(0, new CurvePoint(hit_position2D.x, hit_position2D.y));
                                    gener.selectedIndex = 0;
                                }


                                ArchimatixEngine.isPseudoDraggingSelectedPoint = gener.selectedIndex;
                                model.autobuild();
                            }
                        }
                        else if (e.type == EventType.mouseDrag)
                        {
                            //Debug.Log("Dragging "+ ArchimatixEngine.isPseudoDraggingSelectedPoint + " :: " +  generator.selectedIndices);

                            if (gener == ArchimatixEngine.selectedFreeCurve && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0)
                            {
                                if (gener.parametricObject.curve.Count > ArchimatixEngine.isPseudoDraggingSelectedPoint && generator.selectedIndices != null)
                                {
                                    // The actual point being dragged:
                                    Vector2 displ = hit_position2D - gener.parametricObject.curve[ArchimatixEngine.isPseudoDraggingSelectedPoint].position;
                                    gener.parametricObject.curve[ArchimatixEngine.isPseudoDraggingSelectedPoint].position = hit_position2D;


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

                                        if (fc != null && fc.selectedIndices != null)
                                        {
                                            for (int j = 0; j < fc.selectedIndices.Count; j++)
                                            {
                                                if (!(fc == gener && fc.selectedIndices[j] == ArchimatixEngine.isPseudoDraggingSelectedPoint))
                                                {
                                                    fc.parametricObject.curve[fc.selectedIndices[j]].position += displ;
                                                }
                                            }
                                        }
                                    }

                                    //Debug.Log ("DRAGGING");
                                    parametricObject.setAltered();
                                    model.isAltered();
                                    generator.adjustWorldMatrices();
                                }
                            }
                        }
                        if (e.type == EventType.mouseUp)
                        {
                            //if (ArchimatixEngine.isPseudoDraggingSelectedPoint > -1)


                            ArchimatixEngine.isPseudoDraggingSelectedPoint = -1;
                            ArchimatixEngine.draggingNewPointAt            = -1;
                            //model.autobuild();

                            //Debug.Log("mouse up");
                        }


                        if ((e.type == EventType.mouseDown) || (e.type == EventType.mouseDrag && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0) || (e.type == EventType.mouseUp))
                        {
                            //e.Use();
                        }



                        SceneView sv = SceneView.lastActiveSceneView;
                        if (sv != null)
                        {
                            sv.Repaint();
                        }
                    }
                }
            }
        }         // \OnScenView
Example #15
0
    public override void OnInspectorGUI()
    {
        //if (Event.current.type != EventType.Layout)
        //	return;
        AXModel model = (AXModel)target;


        Event e = Event.current;

        //GUI.skin = axskin;
        //GUI.skin = null;

        //Debug.Log(evt.type);
        switch (e.type)
        {
        case EventType.Layout:
            if (doAutobuild)
            {
                doAutobuild = false;
                //model.autobuild ();
                ArchimatixEngine.scheduleBuild();
            }
            break;


        case EventType.MouseDown:
            //Debug.Log("Down");

            break;

        case EventType.MouseUp:

            //doAutobuild = true;
            break;

        case EventType.KeyUp:

            if (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter)
            {
                Undo.RegisterCompleteObjectUndo(model, "Enter");
                doAutobuild = true;
            }
            //Debug.Log("KeyUp");
            //doAutobuild = true;
            break;

        case EventType.DragUpdated:
            UnityEngine.Debug.Log("Dragging");
            break;

        case EventType.DragPerform:
            //DragAndDrop.AcceptDrag();
            UnityEngine.Debug.Log("Drag and Drop not supported... yet");
            Undo.RegisterCompleteObjectUndo(model, "Default material scale");

            doAutobuild = true;
            break;
        }



        if (richLabelStyle == null)
        {
            richLabelStyle          = new GUIStyle(GUI.skin.label);
            richLabelStyle.richText = true;
            richLabelStyle.wordWrap = true;
        }
        //if (infoIconTexture = null)


        String rubricColor = (EditorGUIUtility.isProSkin) ? "#bbbbff" : "#bbbbff";



        GUIStyle gsTest = new GUIStyle();

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


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

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

        rubric.normal.textColor = textColor;


        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;



        GUILayout.Space(10);

        GUILayout.BeginVertical(gsTest);



        EditorGUI.indentLevel++;


        EditorGUIUtility.labelWidth = 150;


        model.displayModelDefaults = EditorGUILayout.Foldout(model.displayModelDefaults, "Model Defaults", true, foldoutStyle);

        if (model.displayModelDefaults)
        {
            // PRECISION LEVEL
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("Precision Level", rubric);
            GUILayout.FlexibleSpace();
            model.precisionLevel = (PrecisionLevel)EditorGUILayout.EnumPopup("", model.precisionLevel);
            EditorGUILayout.EndHorizontal();


            if (!AXNodeGraphEditorWindow.IsOpen)
            {
                GUILayout.Space(10);

                if (GUILayout.Button("Open in Node Graph"))
                {
                    AXNodeGraphEditorWindow.Init();
                }
            }


            //GUILayout.Space(20);



            // -- RUBRIC - MATERIAL --

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("Material (Default)", rubric);
            GUILayout.FlexibleSpace();

            //if (GUILayout.Button ( infoIconTexture, GUIStyle.none))
            if (GUILayout.Button(infoIconTexture, GUIStyle.none, new GUILayoutOption[] {
                GUILayout.Width(16),
                GUILayout.Height(16)
            }))
            {
                Application.OpenURL("http://www.archimatix.com/manual/materials");
            }

            EditorGUILayout.EndHorizontal();

            // --------
            if (model.axMat.mat.name == "AX_GridPurple")
            {
                EditorGUILayout.HelpBox("Set the default Material for this model.", MessageType.Info);
            }

            // Material
            EditorGUI.BeginChangeCheck();

            model.axMat.mat = (Material)EditorGUILayout.ObjectField(model.axMat.mat, typeof(Material), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name);
                model.remapMaterialTools();
                model.autobuild();
            }

            GUILayout.Space(10);

            // Texture //
            model.showDefaultMaterial = EditorGUILayout.Foldout(model.showDefaultMaterial, "Texture Scaling", true, foldoutStyle);
            if (model.showDefaultMaterial)
            {
                EditorGUI.BeginChangeCheck();
                model.axTex.scaleIsUnified = EditorGUILayout.Toggle("Unified Scaling", model.axTex.scaleIsUnified);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(model, "Default material scale");
                    model.axTex.scale.y = model.axTex.scale.x;
                    model.isAltered();
                }

                if (model.axTex.scaleIsUnified)
                {
                    EditorGUI.BeginChangeCheck();
                    model.axTex.scale.x = EditorGUILayout.FloatField("Scale", model.axTex.scale.x);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name);

                        model.axTex.scale.y = model.axTex.scale.x;
                        model.isAltered();
                        ArchimatixEngine.scheduleBuild();
                    }
                }
                else
                {
                    // Scale X
                    EditorGUI.BeginChangeCheck();
                    model.axTex.scale.x = EditorGUILayout.FloatField("Scale X", model.axTex.scale.x);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name);
                        model.isAltered();
                        ArchimatixEngine.scheduleBuild();
                    }

                    // Scale Y
                    EditorGUI.BeginChangeCheck();
                    model.axTex.scale.y = EditorGUILayout.FloatField("Scale Y", model.axTex.scale.y);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name);
                        model.isAltered();
                        ArchimatixEngine.scheduleBuild();
                    }
                }

                EditorGUI.BeginChangeCheck();
                model.axTex.runningU = EditorGUILayout.Toggle("Running U", model.axTex.runningU);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(model, "Running U");
                    model.isAltered();
                    ArchimatixEngine.scheduleBuild();
                }
            }

            GUILayout.Space(10);


            // PhysicMaterial //
            model.axMat.showPhysicMaterial = EditorGUILayout.Foldout(model.axMat.showPhysicMaterial, "Physics Material", true, foldoutStyle);
            if (model.axMat.showPhysicMaterial)
            {
                // PHYSIC MATERIAL
                EditorGUI.BeginChangeCheck();
                model.axMat.physMat = (PhysicMaterial)EditorGUILayout.ObjectField(model.axMat.physMat, typeof(PhysicMaterial), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(model, "Default PhysicMaterial for " + model.name);
                    model.remapMaterialTools();
                    ArchimatixEngine.scheduleBuild();
                }

                // DENSITY
                EditorGUI.BeginChangeCheck();
                model.axMat.density = EditorGUILayout.FloatField("Density", model.axMat.density);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(model, "Material Density for " + model.name);
                    model.isAltered();
                    ArchimatixEngine.scheduleBuild();
                }
            }


            GUILayout.Space(20);



            model.automaticModelRegeneration = EditorGUILayout.ToggleLeft("Automatic Model Regeneration", model.automaticModelRegeneration);

            GUILayout.Space(20);

            // -- RUBRIC - LIGHTING --

            EditorGUILayout.BeginHorizontal();


            GUILayout.Space(20);
            GUILayout.Label("Lighting", rubric);


            //GUILayout.Label ("<color=" + rubricColor + "> <size=13>Lighting</size></color>", richLabelStyle);
            GUILayout.FlexibleSpace();

            //if (GUILayout.Button ( infoIconTexture, GUIStyle.none))
            if (GUILayout.Button(infoIconTexture, GUIStyle.none, new GUILayoutOption[] {
                GUILayout.Width(16),
                GUILayout.Height(16)
            }))
            {
                Application.OpenURL("http://www.archimatix.com/manual/lightmapping-with-archimatix");
            }

            EditorGUILayout.EndHorizontal();

            // --------


            // LIGHTMAP FLAGS ENABLED
            EditorGUI.BeginChangeCheck();
            model.staticFlagsEnabled = EditorGUILayout.ToggleLeft("Lightmap Flags Enabled", model.staticFlagsEnabled);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(model, "Static Masks Enabled change for " + model.name);

                model.staticFlagsJustEnabled = true;

                ArchimatixEngine.scheduleBuild();
            }

            // SECONDARY UVs
            if (model.staticFlagsEnabled)
            {
                //if (model.buildStatus == AXModel.BuildStatus.Generated)
                EditorGUI.BeginChangeCheck();
                model.createSecondaryUVs = EditorGUILayout.ToggleLeft("Create Secondary UVs (for Baked GI)", model.createSecondaryUVs);
                if (EditorGUI.EndChangeCheck())
                {
                    //if (model.createSecondaryUVs)
                    //	AXEditorUtilities.makeLightMapUVs (model);
                    model.createSecondaryUVsJustEnabled = true;
                }
            }



            GUILayout.Space(20);
        }         // displayModelDefaults

        /*
         * if (GUILayout.Button("Set All Objects as Lightmap Static"))
         * {
         *      Debug.Log("Set all");
         *      model.setLightmapStaticForAllPOs();
         * }
         */



        if (ArchimatixEngine.plevel == 3)
        {
            // RUNTIME //

            string countString = "";
            if (model.exposedParameterAliases != null && model.exposedParameterAliases.Count > 0)
            {
                countString = " (" + model.exposedParameterAliases.Count + ")";
            }

            model.displayModelRuntimeParameters = EditorGUILayout.Foldout(model.displayModelRuntimeParameters, "Runtime Parameters" + countString, true, foldoutStyle);

            if (model.displayModelRuntimeParameters)
            {
                //GUILayout.Label("<color="+rubricColor+"> <size=13>Pro Runtime Features</size></color>", richLabelStyle);


                // EXPOSED PARAMETERS
                //if (model.cycleSelectedAXGO != null)
                //	GUILayout.Label("Consumer Address: "+model.cycleSelectedAXGO.consumerAddress);

                //GUILayout.Label("Runtime Parameters");

                if (model.exposedParameterAliases != null && model.exposedParameterAliases.Count > 0)
                {
                    EditorGUI.BeginChangeCheck();
                    foreach (AXParameterAlias pa in model.exposedParameterAliases)
                    {
                        ParameterAliasGUILayout.OnGUI(pa);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        model.isAltered();
                    }
                }
                else
                {
//					GUIStyle labelSty = new GUIStyle("Label");
//					labelSty.wordWrap = true;
//					labelSty.richText = true;

                    EditorGUILayout.HelpBox("You can add runntime parameters by opening any parameter in the graph and checking \"Enable Runtime\"", MessageType.Info);

                    //GUILayout.Label ("<color=\"gray\">You can add runntime parameters by opening any parameter in the graph and checking \"Enable Runtime\"</color>", labelSty);
                }


                GUILayout.Space(15);

                if (model.exposedParameterAliases != null && model.exposedParameterAliases.Count > 0)
                {
                    if (GUILayout.Button("Create Runtime Controller", GUILayout.Width(200)))
                    {
                        ArchimatixEngine.createControllerForModel = model;
                    }
                }



                // RUNTIME HANDLES
                //if (model.cycleSelectedAXGO != null)
                //	GUILayout.Label("Consumer Address: "+model.cycleSelectedAXGO.consumerAddress);
                if (model.runtimeHandleAliases != null && model.runtimeHandleAliases.Count > 0)
                {
                    //GUILayout.Label("Runtime Handles");


                    foreach (AXHandleRuntimeAlias rth in model.runtimeHandleAliases)
                    {
                        AXRuntimeHandlesGUI.OnGUI(rth);
                    }
                }



                GUILayout.Space(20);
            }
        }         // RUNTIME



        // RELATIONS

        if (model.selectedRelationInGraph != null)
        {
            GUILayout.Space(20);

            GUILayout.Label("<color=" + rubricColor + "> <size=13>Selected Relation</size></color>", richLabelStyle);


            AXRelation r = model.selectedRelationInGraph;
            RelationEditorGUI.OnGUI(r);
        }


        //GUILayout.Space(20);


        model.displayModelSelectedNodes = EditorGUILayout.Foldout(model.displayModelSelectedNodes, "Selected Node Controls", true, foldoutStyle);

        if (model.displayModelSelectedNodes)
        {
            // -- RUBRIC - SELECTED NODES --

            EditorGUILayout.BeginHorizontal();

            //GUILayout.Label("<color="+rubricColor+"> <size=13>Selected Nodes</size></color>", richLabelStyle);
            GUILayout.FlexibleSpace();

            //if (GUILayout.Button ( infoIconTexture, GUIStyle.none))
            if (GUILayout.Button(infoIconTexture, GUIStyle.none, new GUILayoutOption[] {
                GUILayout.Width(16),
                GUILayout.Height(16)
            }))
            {
                Application.OpenURL("http://www.archimatix.com/manual/node-selection");
            }

            EditorGUILayout.EndHorizontal();

            // --------



            //GUILayout.Space(10);

            if (model.selectedPOs != null && model.selectedPOs.Count > 0)
            {
                for (int i = 0; i < model.selectedPOs.Count; i++)
                {
                    //Debug.Log(i);
                    AXParametricObject po = model.selectedPOs [i];

                    //Debug.Log(i+" ------------------------ po.Name="+po.Name+ " -- " + po.generator.AllInput_Ps.Count);


                    doPO(po);

                    // for subnodes...

                    if (po.generator.AllInput_Ps != null)
                    {
                        for (int j = po.generator.AllInput_Ps.Count - 1; j >= 0; j--)
                        {
                            AXParameter p = po.generator.AllInput_Ps [j];

                            if (p.DependsOn != null)
                            {
                                AXParametricObject spo = p.DependsOn.parametricObject;
                                doPO(spo);

                                // sub-sub nodes...
                                for (int k = spo.generator.AllInput_Ps.Count - 1; k >= 0; k--)
                                {
                                    if (spo.generator.AllInput_Ps [k].DependsOn != null)
                                    {
                                        doPO(spo.generator.AllInput_Ps [k].DependsOn.parametricObject);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                GUILayout.Label("<color=\"gray\">...no nodes selected</color>", richLabelStyle);
            }

            GUILayout.Space(50);
        }

        EditorGUI.indentLevel--;

        GUILayout.EndVertical();
//		Editor currentTransformEditor = Editor.CreateEditor(model.gameObject.);
//		if (currentTransformEditor != null) {
//            currentTransformEditor.OnInspectorGUI ();
//        }



        //model.controls[0].val = EditorGUILayout.Slider(model.controls[0].val, 0, 100);


        /*
         * switch (e.type)
         * {
         * case EventType.KeyUp:
         * case EventType.mouseUp:
         *
         *      model.autobuild();
         *      //e.Use ();
         *
         *      //return;
         *      break;
         *
         * case EventType.mouseDown:
         *
         *      //model.autobuild();
         *      //e.Use ();
         *      break;
         *
         * }
         */


        //DrawDefaultInspector ();
    }
Example #16
0
        public static void OnGUI(List <AXNode> parameters)
        {
            for (int i = 0; i < parameters.Count; i++)
            {
                AXParameter p = parameters [i] as AXParameter;

                EditorGUIUtility.labelWidth = 150;


                AXModel model = p.parametricObject.model;


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

                case AXParameter.DataType.AnimationCurve:

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

                    break;

                case AXParameter.DataType.Color:

                    EditorGUI.BeginChangeCheck();
                    p.colorVal = EditorGUILayout.ColorField(p.colorVal);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Color");
                        model.isAltered(28);
                    }
                    break;

                // FLOAT
                case AXParameter.DataType.Float:

                    AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_" + p.Name);

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

                    if (p.isOpen)
                    {
                        EditorGUILayout.BeginHorizontal("Box");
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                    }

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

                    p.isOpen = EditorGUILayout.Foldout(p.isOpen, GUIContent.none);

                    EditorGUILayout.EndHorizontal();



                    if (p.isOpen)
                    {
                        EditorGUI.indentLevel++;

                        InspectorParameterEditGUI.OnGUI(p);

                        EditorGUI.indentLevel--;
                    }



                    break;

                // INT
                case AXParameter.DataType.Int:

                    //GUI.backgroundColor = new Color(.6f,.6f,.9f,.1f) ;
//					if (p.isOpen)
//						EditorGUILayout.BeginHorizontal ("Box");
//					else

                    EditorGUILayout.BeginHorizontal();

                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("IntFieldFieldInsp_" + p.Name);
                    p.IntVal = EditorGUILayout.IntField(p.Name, p.IntVal);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(model, "value change for " + p.Name);
                        p.parametricObject.initiateRipple_setIntValueFromGUIChange(p.Name, p.IntVal);
                        model.isAltered(27);
                        p.parametricObject.generator.adjustWorldMatrices();
                        ArchimatixEngine.scheduleBuild();
                    }

                    p.isOpen = EditorGUILayout.Foldout(p.isOpen, GUIContent.none);

                    EditorGUILayout.EndHorizontal();


                    if (p.isOpen)
                    {
                        EditorGUI.indentLevel++;

                        InspectorParameterEditGUI.OnGUI(p);

                        EditorGUI.indentLevel--;
                    }



                    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(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();
                        ArchimatixEngine.scheduleBuild();
                    }

                    GUILayout.FlexibleSpace();


                    p.isOpen = EditorGUILayout.Foldout(p.isOpen, GUIContent.none);



                    // 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();
                        }
                        ArchimatixEngine.scheduleBuild();
                    }

                    break;
                }
                }

                //if (p.PType != AXParameter.ParameterType.None && p.PType != AXParameter.ParameterType.GeometryControl)
                //	continue;
            }
        }
        // return the height of this gui area
        public static void OnGUI(Rect footerRect, AXNodeGraphEditorWindow editor)
        {
            Event e = Event.current;

            AXModel model = editor.model;



            float statusBarY = footerRect.y;

            GUI.Box(footerRect, GUIContent.none);

            float bSize = 32;

            Rect vButtonRect = new Rect(4, statusBarY - 3, bSize, bSize);


            GUIStyle s        = new GUIStyle(EditorStyles.label);
            Color    oldColor = s.normal.textColor;

            s.alignment        = TextAnchor.MiddleLeft;
            s.normal.textColor = ArchimatixEngine.AXGUIColors["GrayText"];
            s.fixedWidth       = 120;

            Color vcolor = Color.white;

            vcolor.a = .5f;

            GUI.color = vcolor;
            GUI.Label(vButtonRect, "AX v" + ArchimatixEngine.version, s);
            GUI.color = Color.white;



            Rect mButtonRect = new Rect(90, statusBarY, bSize, bSize);
            Rect tooltipRect = new Rect(mButtonRect.x - 10, statusBarY - 25, 100, bSize);

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

            labelstyle.alignment = TextAnchor.MiddleLeft;

            Color prevGUIColor = GUI.color;

            Color gcol = GUI.color;

            GUI.backgroundColor = Color.gray;

            tooltipRect.x = mButtonRect.x - 10;
            // BUTTON: Close All Controls
            if (mButtonRect.Contains(Event.current.mousePosition))             // TOOLTIP
            {
                gcol.a = .8f;
                GUI.Label(tooltipRect, "Close All Controls");
            }
            else
            {
                gcol.a = .5f;
            }
            GUI.color = gcol;
            if (GUI.Button(mButtonRect, editor.CloseAllControlsIcon))
            {
                editor.closeAllControls();
            }


            // BUTTON: Close All Tools
            mButtonRect.x += bSize + 3;
            tooltipRect.x  = mButtonRect.x - 10;

            if (mButtonRect.Contains(Event.current.mousePosition))            // TOOLTIP
            {
                gcol.a    = .8f;
                GUI.color = gcol;
                GUI.Label(tooltipRect, "Close All Tools");
            }
            else
            {
                gcol.a = .5f;
            }
            GUI.color = gcol;
            if (GUI.Button(mButtonRect, editor.CloseAllToolsIcon))
            {
                editor.closeTools();
            }


            // BUTTON: Show All Nodes
            mButtonRect.x += bSize + 3;
            tooltipRect.x  = mButtonRect.x - 10;

            if (mButtonRect.Contains(Event.current.mousePosition))            // TOOLTIP
            {
                gcol.a    = .8f;
                GUI.color = gcol;
                GUI.Label(tooltipRect, "Show All Nodes");
            }
            else
            {
                gcol.a = .5f;
            }
            GUI.color = gcol;
            if (GUI.Button(mButtonRect, editor.ShowAllNodesIcon))
            {
                foreach (AXParametricObject po in model.parametricObjects)
                {
                    po.isOpen = true;
                }
            }


            // zoomScale

            mButtonRect.x    += bSize + 3;
            tooltipRect.x     = mButtonRect.x - 10;
            mButtonRect.width = 45;
            if (mButtonRect.Contains(Event.current.mousePosition))            // TOOLTIP
            {
                gcol.a    = .8f;
                GUI.color = gcol;
                GUI.Label(tooltipRect, "Zoom Scale");
            }
            else
            {
                gcol.a = .5f;
            }
            GUI.color = gcol;
            if (GUI.Button(mButtonRect, ("" + (model.zoomScale * 100)) + "%"))
            {
                editor.zoomScale = 1;
                model.zoomScale  = 1;
                editor.Repaint();
            }



            GUI.color = prevGUIColor;


            //GUI.Label (new Rect (position.width / 2, statusBarY + 10, 100, 20), "Archimatix v " + ArchimatixEngine.version);



            if (model != null)
            {
                //Debug.Log("model.stats_TriangleCount="+model.stats_TriangleCount);
                EditorGUI.LabelField(new Rect(editor.position.width - 335, statusBarY + 7, 100, 20), "Vertices: " + model.stats_VertCount, s);
                EditorGUI.LabelField(new Rect(editor.position.width - 230, statusBarY + 7, 100, 20), "Triangles: " + model.stats_TriangleCount, s);



                EditorGUI.BeginChangeCheck();
                EditorGUIUtility.labelWidth = 70;
                //model.segmentReductionFactor = EditorGUI.Slider( new Rect(position.width-120, statusBarY+7, 115, 20), "Detail Level", model.segmentReductionFactor, 0, 1);
                model.segmentReductionFactor = EditorGUI.Slider(new Rect(editor.position.width - 120, statusBarY + 7, 115, 20), "Detail Level", model.segmentReductionFactor, 0, 1);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(model, "Segment Reduction");
                    model.isAltered();
                }
            }

            Handles.BeginGUI( );
            Handles.color = Color.gray;
            Handles.DrawLine(
                new Vector3(0, statusBarY, 0),
                new Vector3(editor.position.width, statusBarY, 0));
            Handles.EndGUI();


            s.normal.textColor = oldColor;
        }
    public static void processEventCommand(Event e, AXModel model)
    {
        if (e.type == EventType.ValidateCommand)
        {
            e.Use();
        }

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


        var view = SceneView.lastActiveSceneView;

        string focusedControlName = GUI.GetNameOfFocusedControl();

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

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

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


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


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


            case "SelectAll":

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


                e.Use();
                break;

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

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

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

                break;

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

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

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

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

                break;

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

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

                    instancePO(selectedPO);
                }

                model.autobuild();

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

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


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


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

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



                break;

            case "SoftDelete":
            case "Delete":

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

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

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

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


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

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

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

                    model.autobuild();

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



                break;



            case "FrameSelected":

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


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


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

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

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

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

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

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

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

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

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


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

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

                break;
            }
        }

        // EDITOR WINDOW

        ArchimatixEngine.repaintGraphEditorIfExistsAndOpen();

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


        lastCommand = e.commandName;
    }
Example #19
0
    public static void makePrefab(AXModel model, string prefabPath, AXNodeGraphEditorWindow _editor)
    {
        //if (model == null)
        //	return null;

        if (model.generatedGameObjects != null)
        {
            // extrat folder path from path

            //string filename = System.IO.Path.GetFileName (filepath);
            string prefabName = System.IO.Path.GetFileNameWithoutExtension(prefabPath);

            string relativePrefabPath = ArchimatixUtils.getRelativeFilePath(prefabPath);

            string folderPath         = System.IO.Path.GetDirectoryName(prefabPath);
            string relativeFolderPath = ArchimatixUtils.getRelativeFilePath(folderPath);

            // if no directory selected in dialog, then relativeFolderPath is empty
            if (String.IsNullOrEmpty(relativeFolderPath))
            {
                relativeFolderPath = "Assets";
            }

            Debug.Log(folderPath + " :: " + relativeFolderPath + " :: " + prefabName);

            model.build();

            GameObject stampedGO = model.stamp();

            // Only save unique, sharedMeshes to the AssetsDatabase
            List <Mesh> meshesToSave = new List <Mesh> ();
            int         meshCount    = 0;

            Transform[] transforms = stampedGO.GetComponentsInChildren <Transform> ();
            foreach (Transform transform in transforms)
            {
                MeshFilter meshFilter = transform.gameObject.GetComponent <MeshFilter> ();

                if (meshFilter != null)
                {
                    Mesh mesh = meshFilter.sharedMesh;
                    if (mesh != null && !meshesToSave.Contains(mesh))
                    {
                        ;
                        meshesToSave.Add(mesh);

                        meshCount++;
                    }
                    GameObjectUtility.SetStaticEditorFlags(transform.gameObject, StaticEditorFlags.LightmapStatic);
                }
            }

            AssetDatabase.DeleteAsset(relativePrefabPath);


            // [not sure why this is needed here to correct the filepath, but not in the Library Save dalog...]
            relativePrefabPath = relativePrefabPath.Replace('\\', '/');



            var prefab = PrefabUtility.CreateEmptyPrefab(relativePrefabPath);

            int i = 0;
            foreach (Mesh mesh in meshesToSave)

            /*
             * {
             *      if (string.IsNullOrEmpty(mesh.name))
             *              mesh.name = prefabName+"_"+(i++);
             *      AssetDatabase.DeleteAsset (relativePrefabPath+"/"+mesh.name);
             *      AssetDatabase.AddObjectToAsset(mesh, relativePrefabPath);
             * }
             */
            {             // Compliments of Enoch
                if (string.IsNullOrEmpty(mesh.name))
                {
                    mesh.name = prefabName + "_" + (i++);
                }
                var path = AssetDatabase.GetAssetPath(mesh);

                if (string.IsNullOrEmpty(path))
                {
                    AssetDatabase.AddObjectToAsset(mesh, relativePrefabPath);
                }
            }



            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            PrefabUtility.ReplacePrefab(stampedGO, prefab, ReplacePrefabOptions.ConnectToPrefab);

            stampedGO.name = prefabName;
            //Selection.activeGameObject = stampedGO;

            //buildStatus = BuildStatus.Generated;



            //Close();
        }
    }
    public static void contextMenu(AXParameter p, Vector2 position)
    {
        AXModel model = p.parametricObject.model;

        GenericMenu menu = new GenericMenu();

        //parametricObject.generator.addContextMenuItems(menu);
        menu.AddSeparator("Organizers ...");
        menu.AddItem(new GUIContent("Grouper"), false, () => {
            AXParametricObject npo = AXEditorUtilities.addNodeToCurrentModel("Grouper");
            AXParameter new_p      = npo.addInputMesh();
            new_p.makeDependentOn(p);

            model.isAltered(21);
        });


        menu.AddSeparator(" ");
        menu.AddSeparator("Repeaters ...");
        menu.AddItem(new GUIContent("Instance"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("Instance").getParameter("Input Mesh").makeDependentOn(p);  model.autobuild();
        });
        menu.AddItem(new GUIContent("Replicant"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("Replicant").getParameter("Input Mesh").makeDependentOn(p);  model.autobuild();
        });

        menu.AddItem(new GUIContent("PairRepeater"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("PairRepeater").getPreferredInputParameter().makeDependentOn(p); model.autobuild();
        });

        menu.AddItem(new GUIContent("RadialRepeater"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("RadialRepeater").getPreferredInputParameter().makeDependentOn(p); model.autobuild();
        });


        menu.AddItem(new GUIContent("FloorRepeater (Node)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("FloorRepeater").getParameter("Node Mesh").makeDependentOn(p); model.autobuild();
        });
        menu.AddItem(new GUIContent("FloorRepeater (Node)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("FloorRepeater").getParameter("Story Mesh").makeDependentOn(p); model.autobuild();
        });

        // GRID_REPEATER
        menu.AddItem(new GUIContent("GridRepeater (Node)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("GridRepeater").getParameter("Node Mesh").makeDependentOn(p); model.autobuild();
        });
        menu.AddItem(new GUIContent("GridRepeater (Cell)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("GridRepeater").getParameter("Cell Mesh").makeDependentOn(p); model.autobuild();
        });
        menu.AddItem(new GUIContent("GridRepeater (Span)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("GridRepeater").getParameter("Bay Span").makeDependentOn(p); model.autobuild();
        });

        menu.AddItem(new GUIContent("ShapeRepeater (Node Mesh)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Node Mesh").makeDependentOn(p); model.autobuild();
        });
        menu.AddItem(new GUIContent("ShapeRepeater (Bay Span Mesh)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Bay Span Mesh").makeDependentOn(p); model.autobuild();
        });

        menu.AddItem(new GUIContent("ShapeRepeater (Corner Mesh)"), false, () => {
            AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Corner Mesh").makeDependentOn(p); model.autobuild();
        });


        menu.ShowAsContext();
    }
Example #21
0
 public static void generateModel(AXModel model)
 {
     model.generate();
 }
Example #22
0
        public static void render(AXParametricObject po, bool makeTexture = false)
        {
            AXModel model = po.model;

            if (model == null)
            {
                return;
            }

            model.assertThumnailSupport();


            // THUMBNAIL BACKGROUND COLOR
            if (po.generator != null && makeTexture)
            {
                model.thumbnailCamera.backgroundColor = po.generator.ThumbnailColor;
            }

            // WHY ARE THE THUMNAIL AND RenTex null?

            if (po.renTex == null)
            {
                po.renTex = new RenderTexture(256, 256, 24);
            }

            if (!po.renTex.IsCreated())
            {
                po.renTex.antiAliasing = 8;
                po.renTex.Create();
            }

            // This started giving an error in 5.3 and did not seem to be needed anyway!

            if (makeTexture)
            {
                RenderTexture.active = po.renTex;
            }

            model.thumbnailCamera.targetTexture = po.renTex;



            model.thumbnailCameraGO.transform.position = po.getThumbnailCameraPosition();
            model.thumbnailCameraGO.gameObject.transform.LookAt(po.getThumbnailCameraTarget());



            // USE THIS MATRIX TO DRAW THE PO's MESHES SOMEWHERE FAR, FAR AWAY


            //Debug.Log("RENDER: " + po.Name);

            Material tmpMat = null;

            if (po.generator is MaterialTool)
            {
                if (po.axMat != null && po.axMat.mat != null)
                {
                    tmpMat = po.axMat.mat;
                }
                else if (po.grouper != null && po.grouper.axMat != null && po.grouper.axMat.mat != null)
                {
                    tmpMat = po.grouper.axMat.mat;
                }
                else
                {
                    tmpMat = model.axMat.mat;
                }

                //Debug.Log("RENDER TEXTURETOOL " + model.thumbnailCameraGO.transform.position + " mesh-> " + model.thumbnailMaterialMesh.vertices.Length + " -- " + tmpMat);

                Graphics.DrawMesh(model.thumbnailMaterialMesh, model.remoteThumbnailLocation, tmpMat, 0, model.thumbnailCamera);

                model.thumbnailCamera.Render();
            }
            else
            {
                AXParameter op = po.getParameter("Output Mesh");
                if (op != null)
                {
                    // RE-RENDER
                    // After a save or reload, the RenterTextures are empty
                    if (op.meshes != null)
                    {
                        for (int mi = 0; mi < op.meshes.Count; mi++)
                        {
                            AXMesh axmesh = op.meshes [mi];
                            if (axmesh.mat != null)
                            {
                                tmpMat = axmesh.mat;
                            }
                            else
                            if (po.axMat != null && po.axMat.mat != null)
                            {
                                tmpMat = po.axMat.mat;
                            }
                            else if (po.grouper != null && po.grouper.axMat != null && po.grouper.axMat.mat != null)
                            {
                                tmpMat = po.grouper.axMat.mat;
                            }

                            else
                            {
                                tmpMat = model.axMat.mat;
                            }


                            Graphics.DrawMesh(axmesh.drawMesh, (model.remoteThumbnailLocation * axmesh.transMatrix), tmpMat, 0, model.thumbnailCamera);
                        }
                    }

                    model.thumbnailCamera.Render();
                }
            }

            // write to texture
            if (makeTexture)
            {
                if (po.thumbnail == null)
                {
                    po.thumbnail = new Texture2D(256, 256);
                }

                po.thumbnail.ReadPixels(new Rect(0, 0, po.renTex.width, po.renTex.height), 0, 0);
                po.thumbnail.Apply();
            }
            if (makeTexture)
            {
                RenderTexture.active = null;
            }

            // 3. Set helper objects to inactive
            model.thumbnailLightGO.SetActive(false);
            model.thumbnailCameraGO.SetActive(false);
        }
 public static void generateModel(AXModel model, string caller = "")
 {
     model.generate(caller);
     EditorUtility.SetDirty(model.gameObject);
 }
    public static void processEventCommandKeyDown(Event e, AXModel model)
    {
        switch (e.keyCode)
        {
        case KeyCode.L:
            if (model.selectedPOs != null && model.selectedPOs.Count == 1)
            {
                LibraryEditor.doSave_MenuItem(model.selectedPOs[0]);

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

        case KeyCode.V:
            // this paste waste uncaught by EventType.ExecuteCommand or EventType.ValidateCommand
            // beacuse alt or command were held down
            Undo.RegisterCompleteObjectUndo(model, "Paste");

            if (e.shift)
            {
                if (e.alt)
                {
                    model.duplicateSelectedPOs();
                }
                else
                {
                    model.replicateSelectedPOs();
                }

                model.isAltered(6);


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

            break;

        case KeyCode.D:
            Undo.RegisterCompleteObjectUndo(model, "Duplicate");
            //Debug.Log ("DUPLICATE.....KeyCode.D");
            if (model.selectedPOs.Count > 0)
            {
                AXParametricObject selectedPO = model.selectedPOs[0];
                if (e.shift)
                {
                    replicatePO(selectedPO);
                }
                else if (e.alt)
                {
                    duplicatePO(selectedPO);
                }
                else
                {
                    //Debug.Log ("instancePO");
                    instancePO(selectedPO);
                }
            }

            // "Duplicate" is caught by the validateCommand and processed here in processEventCommand()

            model.isAltered(7);

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

        case KeyCode.Backspace:

            string focusedControlName = GUI.GetNameOfFocusedControl();


            if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))
            {
                Undo.RegisterCompleteObjectUndo(model, "Delete");

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

                model.isAltered(8);
                e.Use();
            }

            break;
        }

        // Update EditorWindow
        ArchimatixEngine.repaintGraphEditorIfExistsAndOpen();
    }
 public static void copySelectedPO(AXModel model)
 {
 }
Example #26
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();
            }
        }
Example #27
0
        public static int OnGUI(AXHandle han, Rect pRect, AXNodeGraphEditorWindow editor)
        {
            int cur_y   = (int)pRect.y;
            int lineHgt = 16;
            int margin  = 24;
            int wid     = (int)pRect.width - margin;


            int gap = 5;

            int indent    = (int)pRect.x + 16;
            int indent2   = indent + 12;
            int indentWid = wid - indent;

            if (han.Name == null || han.Name == "")
            {
                han.Name = "Handle";
            }



            if (han.isEditing)
            {
                if (han.expressions == null)
                {
                    han.expressions = new List <string>();
                }
                GUI.Box(new Rect(pRect.x, cur_y - 4, (pRect.width - 20), ((12 + han.expressions.Count) * lineHgt)), "");

                // TITLE
                GUI.SetNextControlName("HanTitle_Text_" + han.parametricObject.Guid + "_" + han.param);
                han.Name = GUI.TextField(new Rect(pRect.x + 4, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), han.Name);



                cur_y += lineHgt;


                //if (expressions != null)
                //GUI.Box (new Rect(pRect.x, cur_y, wid, lineHgt*(8+expressions.Count)), GUIContent.none);

                // HANDLE_TYPE
                //EditorGUI.PropertyField( new Rect(indent, cur_y, pRect.width-3*lineHgt-14, lineHgt), hProperty.FindPropertyRelative("m_type"), GUIContent.none);

                AXModel model = han.parametricObject.model;

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


                cur_y += gap * 2;



                // HANDLE TYPE
                string[] options = System.Enum.GetNames(typeof(AXHandle.HandleType));

                EditorGUIUtility.labelWidth = wid - 50;
                EditorGUI.BeginChangeCheck();
                han.Type = (AXHandle.HandleType)EditorGUI.Popup(
                    new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt),
                    "",
                    (int)han.Type,
                    options);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(model, "value change for handle type");
                    model.autobuild();
                }


                cur_y += lineHgt + gap;

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



                //  RUNTIME HANDLE: expose in Model interface ------------

                Rect cntlRect = new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt);
                EditorGUI.BeginChangeCheck();
                han.exposeForRuntime = EditorGUI.Toggle(cntlRect, "Runtime", han.exposeForRuntime);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(model, "Runtime Handle");

                    if (han.exposeForRuntime)
                    {
                        //Debug.Log(ArchimatixEngine.RuntimeHandlePrefab_PlanarKnob);

                        //AXHandleRuntimeAlias rtHandleAlias =  model.addHandleRuntimeAlias(han);

                        if (ArchimatixEngine.RuntimeHandlePrefab_PlanarKnob != null)
                        {
                            // CREATE A GAME_OBJECT

                            GameObject tmp = GameObject.Instantiate(ArchimatixEngine.RuntimeHandlePrefab_PlanarKnob);
                            //GameObject tmp = GameObject.Instantiate(model.RuntimeHandlePrefab_PlanarKnob);
                            tmp.name = han.Name;
                            Debug.Log("han.Name=" + han.Name);
                            if (tmp != null)
                            {
                                tmp.transform.parent = model.runtimeHandlesGameObjects.transform;

                                AXRuntimeHandleBehavior rtHandleBehavior = tmp.GetComponent <AXRuntimeHandleBehavior>();

                                rtHandleBehavior.handleGuid = han.Guid;
                                rtHandleBehavior.handle     = han;
                            }
                        }
                    }
                    else
                    {
                        model.removeHandleRuntimeAlias(han);

                        AXRuntimeHandleBehavior[] rhbs = model.runtimeHandlesGameObjects.GetComponentsInChildren <AXRuntimeHandleBehavior> ();
                        for (int j = 0; j < rhbs.Length; j++)
                        {
                            if (rhbs[j] != null && rhbs[j].gameObject != null && rhbs[j].handleGuid == han.Guid)
                            {
                                // This GameObject and all its children...

                                if (Application.isPlaying)
                                {
                                    GameObject.Destroy(rhbs[j].gameObject);
                                }
                                else
                                {
                                    GameObject.DestroyImmediate(rhbs[j].gameObject);
                                }

                                break;
                            }
                        }
                        Resources.UnloadUnusedAssets();
                    }
                }


                cur_y += lineHgt + gap;



                // POSITION HEADER -------
                GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Position", "Use a number, parameter name, or a mathematical expressions to define the handle position"));
                cur_y += lineHgt;

                // X_POS
                GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "X");
                GUI.SetNextControlName("x_Text_" + han.parametricObject.Guid + "_" + han.param);
                han.pos_x = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.pos_x);
                cur_y    += lineHgt;

                // Y_POS
                GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "Y");
                GUI.SetNextControlName("y_Text_" + han.parametricObject.Guid + "_" + han.param);
                han.pos_y = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.pos_y);
                cur_y    += lineHgt;

                // Z_POS
                GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "Z");
                GUI.SetNextControlName("z_Text_" + han.parametricObject.Guid + "_" + han.param);
                han.pos_z = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.pos_z);
                cur_y    += lineHgt + gap;



                if (han.Type == AXHandle.HandleType.Circle)
                {
                    // RADIUS
                    GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Radius", "Use a number, parameter name, or a mathematical expressions to define the handle radius"));
                    cur_y += lineHgt;

                    GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "R");
                    han.radius = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.radius);
                    cur_y     += lineHgt + gap;



                    // TANGENT
                    Color prevColor = Handles.color;
                    Handles.color = Color.cyan;

                    GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Tangent", "Use a number, parameter name, or a mathematical expressions to define the handle tangent"));
                    cur_y += lineHgt;

                    GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "T");
                    han.tangent = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.tangent);
                    cur_y      += lineHgt + gap;

                    /*
                     *      // OFFSET ANGLE
                     *      GUI.Label(new Rect(indent, cur_y, pRect.width-3*lineHgt-14, lineHgt), new GUIContent("Angle", "Use a number, parameter name, or a mathematical expressions to define the handle angle"));
                     *      cur_y += lineHgt;
                     *
                     *      GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "Z");
                     *      angle = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), angle);
                     *      cur_y += lineHgt+gap;
                     */

                    Handles.color = prevColor;
                }


                // EXPRESSIONS HEADER -------
                GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Expressions", "These mathematical expressions interpret the handle's values."));
                cur_y += lineHgt;

                if (han.expressions == null)
                {
                    han.expressions = new List <string>();
                }

                if (han.expressions.Count == 0)
                {
                    han.expressions.Add("");
                }


                for (int i = 0; i < han.expressions.Count; i++)
                {
                    GUI.SetNextControlName("HandleExp_Text_" + han.parametricObject.Guid + "_" + han.param);

                    han.expressions[i] = EditorGUI.TextField(new Rect(indent, cur_y, indentWid, 16), han.expressions[i]);

                    if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y - 1, lineHgt * 1.25f, lineHgt), "-"))
                    {
                        han.expressions.Remove(han.expressions[i]);
                        //p.expressions.RemoveAt(i);
                    }


                    cur_y += lineHgt;
                }
                if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y, lineHgt * 1.25f, lineHgt), new GUIContent("+", "Add an expression to this Handle")))
                {
                    han.expressions.Add("");
                }

                cur_y += gap * 5;
                if (GUI.Button(new Rect(pRect.width - 3 * lineHgt - 5, cur_y, 3 * lineHgt, lineHgt), "Done"))
                {
                    if (han.parametricObject != null)
                    {
                        han.parametricObject.stopEditingAllHandles();
                    }

                    han.isEditing = false;
                }
                cur_y += lineHgt;
            }
            else
            {
                if (GUI.Button(new Rect(pRect.x, pRect.y, wid - 16, 16), new GUIContent(han.Name, "Click to edit this handle.")))
                {
                    han.parametricObject.stopEditingAllHandlesExcept(han);
                    han.isEditing = true;
                }
            }
            if (GUI.Button(new Rect(wid + 6, pRect.y, lineHgt, lineHgt), "-"))
            {
                //Debug.Log ("REMOVE HANDLE...");
                if (han.parametricObject != null)
                {
                    han.parametricObject.removeHandleFromReplicantsControlsWithName(han.Name);
                    han.parametricObject.handles.Remove(han);
                }
            }



            cur_y += lineHgt;


            return(cur_y - (int)pRect.y);
        }
Example #28
0
        // Supports the generation of runtime controllers for AXModels


        public static void createControllerButtonAction(AXModel model)
        {
            GameObject runtimeControllerGO = null;

            foreach (Transform child in model.transform)
            {
                if (child.name == "runtimeController")
                {
                    runtimeControllerGO = child.gameObject;
                    break;
                }
            }

            if (runtimeControllerGO == null)
            {
                // Create one
                runtimeControllerGO = new GameObject("runtimeController");
                runtimeControllerGO.transform.parent = model.gameObject.transform;
            }


            string fullPath = "";

            if (runtimeControllerGO != null)
            {
                AXRuntimeControllerBase runtimeController = runtimeControllerGO.GetComponent <AXRuntimeControllerBase>();


                // 1. GET runctimeController filePath...

                if (runtimeController != null)
                {
                    // 1A. GET FilePath from Component
                    MonoScript ms = MonoScript.FromMonoBehaviour(runtimeController);
                    string     relativeAssetPath = AssetDatabase.GetAssetPath(ms.GetInstanceID());
                    fullPath = ArchimatixUtils.getAbsoluteLibraryPath(relativeAssetPath);
                }
                else
                {
                    // 1B. Since a controller does not exist, we must create one from a tempalte, update it and the
                    //     let AX know that a new class will be available to add to the GameObject after scripts reload.

                    // 1B.1. CREATE file based on a template...
                    fullPath = EditorUtility.SaveFilePanel(
                        "Save New Controller File",
                        ArchimatixUtils.getAbsoluteLibraryPath("Assets"),
                        "MyRuntimeController",
                        "cs");



                    // 1B.2. LOCATE TEMPLATE file AXRuntimeControllerTemplate.cs

                    DirectoryInfo info             = new DirectoryInfo(Application.dataPath);
                    FileInfo[]    files            = info.GetFiles("AXRuntimeControllerTemplate.cs", SearchOption.AllDirectories);
                    string        templateFilePath = "";
                    if (files != null && files.Length > 0)
                    {
                        templateFilePath = files[0].ToString();
                    }


                    // 1B.3. COPY TEMPLATE to fullPath

                    if (!string.IsNullOrEmpty(templateFilePath) && File.Exists(templateFilePath))
                    {
                        File.Copy(templateFilePath, fullPath, true);
                    }


                    // 1B.4. REPLACE the classname
                    string newClassName = System.IO.Path.GetFileNameWithoutExtension(fullPath);
                    File.WriteAllText(fullPath, File.ReadAllText(fullPath).Replace("AXRuntimeControllerTemplate", newClassName));


                    // 1B.5. SET UP TO CONNECT CLASS TO GAMEOBJECT AFTER ALL SCRIPTS RELOAD
                    // ArchimatixEngine will notice this on DidReloadAllScripts and add this class as a component to the runtimeControllerGO
                    EditorPrefs.SetString("AddComponentByGameObjectIDAndClassname", (runtimeControllerGO.GetInstanceID() + "_" + newClassName));
                }


                // 2. REWRITE the auto-generated region of the file
                //    based on the model's exposed runtime parameters.
                if (File.Exists(fullPath))
                {
                    AXRuntimeEditor.updateControllerFile(fullPath, model);
                }


                // 3. Let the user know that this script writing
                //	  starts a Reload of all scripts
                EditorUtility.DisplayDialog("Reloading Scripts",
                                            "This may take a few seconds.",
                                            "Ok");

                // 4. REFRESH DB - This is asynchronous and will reload all scripts.
                AssetDatabase.Refresh();
            }
        }
Example #29
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();
         *
         */
    }
        // return the height of this gui area
        public static void OnGUI(Rect headerRect, AXNodeGraphEditorWindow editor)
        {
            Event e = Event.current;

            AXModel model = editor.model;

            // DO HEADER MENU BAR -- MODEL MENU


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

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

            labelstyle.alignment = TextAnchor.LowerLeft;

            labelstyle.fixedWidth = 150;


            GUILayout.Space(5);


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



            // NEW MODEL
            GUILayout.Space(10);



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


                GenericMenu menu = new GenericMenu();

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


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


                menu.AddSeparator("");

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

                menu.ShowAsContext();
            }



            Color bgc = GUI.backgroundColor;

            GUI.backgroundColor = Color.clear;



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

                    model.selectAllVisibleInGroup(null);

                    float framePadding = 50;

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



                    AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                }



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


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

                        // model button frames



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



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



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



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

                GUI.backgroundColor = Color.cyan;


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

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

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

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

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

                GUILayout.Space(4);
            }


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

            GUI.backgroundColor = bgc;
        }