示例#1
0
        public static Bounds BoundsFromJSON(AX.SimpleJSON.JSONNode jn)
        {
            Bounds b = new Bounds();

            b.center  = new Vector3(jn["center"][0].AsFloat, jn["center"][1].AsFloat, jn["center"][2].AsFloat);
            b.size    = new Vector3(jn["size"][0].AsFloat, jn["size"][1].AsFloat, jn["size"][2].AsFloat);
            b.extents = b.size / 2;
            return(b);
        }
示例#2
0
        public static List <string> StringListFromJSON(AX.SimpleJSON.JSONNode N)
        {
            List <string> list = new List <string>();

            foreach (AX.SimpleJSON.JSONNode jn in N.AsArray)
            {
                list.Add(jn.Value);
            }

            return(list);
        }
示例#3
0
        public static Matrix4x4 Matrix4x4FromJSON(AX.SimpleJSON.JSONNode jn)
        {
            Matrix4x4 m = new Matrix4x4();

            m.SetColumn(0, Vector4FromJSON(jn[0]));
            m.SetColumn(1, Vector4FromJSON(jn[1]));
            m.SetColumn(2, Vector4FromJSON(jn[2]));
            m.SetColumn(3, Vector4FromJSON(jn[3]));

            return(m);
        }
示例#4
0
        public static Curve CurveFromJSON(AX.SimpleJSON.JSONNode N)
        {
            Curve curve = new Curve();

            foreach (AX.SimpleJSON.JSONNode jn in N.AsArray)
            {
                curve.Add(CurvePointFromJSON(jn));
            }

            return(curve);
        }
示例#5
0
        public static AXShape fromJSON(AXParametricObject po, AX.SimpleJSON.JSONNode jn)
        {
            AXShape shape = new AXShape(jn["name"]);

            shape.parametricObject = po;
            shape.ParentNode       = po;
            shape.Parent           = po;

            // parameters

            if (jn["inputs"] != null)
            {
                shape.inputs = new List <AXParameter>();
                foreach (AX.SimpleJSON.JSONNode jn_p in jn["inputs"].AsArray)
                {
                    shape.inputs.Add(AXParameter.fromJSON(jn_p));
                }
            }


            if (jn["difference"] != null)
            {
                shape.difference = AXParameter.fromJSON(jn["difference"]);
            }

            if (jn["differenceRail"] != null)
            {
                shape.differenceRail = AXParameter.fromJSON(jn["differenceRail"]);
            }

            if (jn["intersection"] != null)
            {
                shape.intersection = AXParameter.fromJSON(jn["intersection"]);
            }

            if (jn["intersectionRail"] != null)
            {
                shape.intersectionRail = AXParameter.fromJSON(jn["intersectionRail"]);
            }

            if (jn["union"] != null)
            {
                shape.union = AXParameter.fromJSON(jn["union"]);
            }

            if (jn["grouped"] != null)
            {
                shape.grouped = AXParameter.fromJSON(jn["grouped"]);
            }



            return(shape);
        }
示例#6
0
        public static Keyframe KeyframeFromJSON(AX.SimpleJSON.JSONNode jn)
        {
            Keyframe kf = new Keyframe();

            kf.inTangent  = jn["inTangent"].AsFloat;
            kf.outTangent = jn["outTangent"].AsFloat;
            kf.time       = jn["time"].AsFloat;
            kf.value      = jn["value"].AsFloat;


            return(kf);
        }
示例#7
0
        public static AXCamera AXCameraFromJSON(AX.SimpleJSON.JSONNode jn)
        {
            AXCamera axcam = new AXCamera();


            axcam.alpha          = jn["alpha"].AsFloat;
            axcam.beta           = jn["beta"].AsFloat;
            axcam.radius         = jn["radius"].AsFloat;
            axcam.radiusAdjuster = jn["radiusAdjuster"].AsFloat;

            return(axcam);
        }
示例#8
0
        public void saveToFile()
        {
            if (!string.IsNullOrEmpty(readIntoLibraryFromRelativeAXOBJPath))
            {
                string filepath = ArchimatixUtils.getAbsoluteLibraryPath(readIntoLibraryFromRelativeAXOBJPath);

                if (File.Exists(filepath))
                {
                    AX.SimpleJSON.JSONNode jn = AX.SimpleJSON.JSON.Parse(File.ReadAllText(filepath));

                    AX.SimpleJSON.JSONNode pon = jn[0];

                    if (jn ["parametric_objects"] != null)
                    {
                        pon = jn ["parametric_objects"] [0];
                    }

                    pon["name"] = Name;
                    pon["includeInSidebarMenu"] = includeInSidebarMenu.ToString();
                    pon["description"]          = description;

                    if (!string.IsNullOrEmpty(author))
                    {
                        pon["author"] = author;
                    }

                    if (!string.IsNullOrEmpty(tags))
                    {
                        pon["tags"] = tags;
                    }

                    if (!string.IsNullOrEmpty(documentationURL))
                    {
                        pon["documentationURL"] = documentationURL;
                    }

                    if (!string.IsNullOrEmpty(readIntoLibraryFromRelativeAXOBJPath))
                    {
                        pon["readIntoLibraryFromRelativeAXOBJPath"] = readIntoLibraryFromRelativeAXOBJPath;
                    }

                    // resave

                    File.WriteAllText(filepath, jn.ToString().Replace("\\", ""));

                    //Debug.Log(jn.ToString().Replace("\\",""));
                }
            }
        }
示例#9
0
        public static AnimationCurve AnimationCurveFromJSON(AX.SimpleJSON.JSONNode N)
        {
            AnimationCurve curve = new AnimationCurve();

            curve.keys = new Keyframe[N.AsArray.Count];

            for (int i = 0; i < N.AsArray.Count; i++)
            {
                AX.SimpleJSON.JSONNode jn = N.AsArray [i];
                Keyframe k = KeyframeFromJSON(jn);
                curve.AddKey(k);
            }

            return(curve);
        }
示例#10
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);
            }
        }
示例#11
0
        public static AXRelation fromJSON(AX.SimpleJSON.JSONNode jn)
        {
            AXRelation r = new AXRelation();

            r.pA_guid = jn["pA_guid"];
            r.pB_guid = jn["pB_guid"];

            r.expression_AB = jn["expression_AB"];
            r.expression_BA = jn["expression_BA"];

            r.expression_AB_prev = jn["expression_AB_prev"];
            r.expression_BA_prev = jn["expression_BA_prev"];


            return(r);
        }
示例#12
0
        public void saveParametricObjectMetadata(AXParametricObject head_po)
        {
            //Debug.Log("SAVING head_po.author="+head_po.author);

            AX.SimpleJSON.JSONNode hn = AX.SimpleJSON.JSON.Parse(JSONSerializersAX.ParametricObjectAsJSON(head_po));

            string filename = ArchimatixUtils.getAbsoluteLibraryPath(head_po.readIntoLibraryFromRelativeAXOBJPath);

            AX.SimpleJSON.JSONNode jn = AX.SimpleJSON.JSON.Parse(File.ReadAllText(filename));

            jn["parametric_objects"][0] = hn;

            File.WriteAllText(filename, jn.ToString());

            rebuildTagListsFromExistingPOs();
        }
示例#13
0
        public static CurvePoint CurvePointFromJSON(AX.SimpleJSON.JSONNode jn)
        {
            CurvePoint cp = new CurvePoint(Vector2FromJSON(jn["position"]));

            cp.curvePointType = (CurvePointType)jn["curvePointType"].AsInt;

            if (jn["localHandleA"] != null && string.IsNullOrEmpty(jn["localHandleA"]))
            {
                cp.localHandleA = Vector2FromJSON(jn["localHandleA"]);
            }
            if (jn["localHandleB"] != null && string.IsNullOrEmpty(jn["localHandleB"]))
            {
                cp.localHandleB = Vector2FromJSON(jn["localHandleB"]);
            }


            return(cp);
        }
示例#14
0
        public void init()
        {
            Debug.Log("LIB INIT");
            categories = new Dictionary <string, List <string> >();

            string filename = getLibraryPath() + "data.json";



            if (File.Exists(filename))
            {
                string json_string = File.ReadAllText(filename);
                Debug.Log(json_string);

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

                foreach (AX.SimpleJSON.JSONNode jn_cat in jn.AsArray)
                {
                    Debug.Log(jn_cat.GetHashCode());
                }
            }
        }
示例#15
0
        public static AXHandle fromJSON(AX.SimpleJSON.JSONNode jn)
        {
            AXHandle h = new AXHandle();

            h.Name = jn["name"].Value;

            h.Type = (AXHandle.HandleType)jn["type"].AsInt;

            h.pos_x   = jn["pos_x"].Value;
            h.pos_y   = jn["pos_y"].Value;
            h.pos_z   = jn["pos_z"].Value;
            h.radius  = jn["radius"].Value;
            h.tangent = jn["tangent"].Value;

            h.angle = jn["angle"].Value;
            h.len   = jn["len"].Value;

            if (jn["expressions"] != null)
            {
                h.expressions = AXJson.StringListFromJSON(jn["expressions"]);
            }

            return(h);
        }
示例#16
0
 public virtual void Add(string aKey, JSONNode aItem)
 {
 }
示例#17
0
 public override void Add(string aKey, JSONNode aItem)
 {
     m_List.Add(aItem);
 }
示例#18
0
 public override JSONNode Remove(JSONNode aNode)
 {
     m_List.Remove(aNode);
     return(aNode);
 }
示例#19
0
 public virtual void Add(JSONNode aItem)
 {
     Add("", aItem);
 }
示例#20
0
 public static Color ColorFromJSON(AX.SimpleJSON.JSONNode jn)
 {
     return(new Color(jn[0].AsFloat, jn[1].AsFloat, jn[2].AsFloat, jn[3].AsFloat));
 }
示例#21
0
 public static Rect RectFromJSON(AX.SimpleJSON.JSONNode jn)
 {
     return(new Rect(jn[0].AsFloat, jn[1].AsFloat, jn[2].AsFloat, jn[3].AsFloat));
 }
示例#22
0
 public static Vector4 Vector4FromJSON(AX.SimpleJSON.JSONNode jn)
 {
     return(new Vector4(jn[0].AsFloat, jn[1].AsFloat, jn[2].AsFloat, jn[3].AsFloat));
 }
示例#23
0
 public static Vector2 Vector2FromJSON(AX.SimpleJSON.JSONNode jn)
 {
     return(new Vector2(jn[0].AsFloat, jn[1].AsFloat));
 }
示例#24
0
        public static AXParametricObject pasteParametricObjectFromString(String json_string)
        {
            if (string.IsNullOrEmpty(json_string))
            {
                json_string = EditorGUIUtility.systemCopyBuffer;
            }

            if (string.IsNullOrEmpty(json_string))
            {
                return(null);
            }

            AXModel model = null;

            // 1. First choice is to use a selected model....
            if (ArchimatixEngine.currentModel != null)
            {
                model = ArchimatixEngine.currentModel;
            }

            bool doInstantiation = true;

            if (model == null)
            {
                // ok, are there other models in the scene that the user doesn't realize arene't selected?
                AXModel[] axModels = GameObject.FindObjectsOfType(typeof(AXModel)) as AXModel[];

                if (axModels != null)
                {
                    if (axModels.Length == 1)
                    {
                        // Offer this model as a button,  but also give opportunity to create a new one...
                        int option = EditorUtility.DisplayDialogComplex("Instantiating Library Item", "There is no AX model currently selected", "Cancel", "Add to " + axModels[0], "Create a new Model");


                        switch (option)
                        {
                        // Save Scene
                        case 0:
                            doInstantiation = false;
                            break;

                        // Save and Quit.
                        case 1:
                            model = axModels[0];
                            break;

                        case 2:
                            GameObject axgo = AXEditorUtilities.createNewModel();
                            model           = axgo.GetComponent <AXModel>();
                            doInstantiation = false;
                            break;

                        default:
                            doInstantiation = false;
                            break;
                        }
                    }

                    else if (axModels.Length > 1)
                    {
                        // Throw up a dialog to see if use wants to go select one of the existing models or create a new one.

                        if (EditorUtility.DisplayDialog("Instantiating Library Item", "There is no AX model currently selected", "Select and Existing Model", "Create a new Model"))
                        {
                            return(null);
                        }
                    }
                }
            }


            if (!doInstantiation)
            {
                return(null);
            }



            if (model == null)
            {                   // Well, then, we tried everything....
                GameObject axgo = AXEditorUtilities.createNewModel();
                model = axgo.GetComponent <AXModel>();
            }



            List <AXParametricObject> poList       = new List <AXParametricObject>();
            List <AXRelation>         relationList = new List <AXRelation>();

            AX.SimpleJSON.JSONNode json = null;
            try
            {
                json = AX.SimpleJSON.JSON.Parse(json_string);
            }
            catch
            {
                return(null);
            }
            if (json == null)
            {
                return(null);
            }

            if (json["parametric_objects"] != null)
            {
                foreach (AX.SimpleJSON.JSONNode poNode in json["parametric_objects"].AsArray)
                {
                    poList.Add(JSONSerializersAX.ParametricObjectFromJSON(poNode));
                }
            }

            foreach (AX.SimpleJSON.JSONNode rNode in json["relations"].AsArray)
            {
                relationList.Add(AXRelation.fromJSON(rNode));
            }

            //Debug.Log (rNode);



            // make sure there is a game object ready to instantiate this on



            if (model == null)
            {
                // check if the user really wants to create a new model...

                GameObject axgo = AXEditorUtilities.createNewModel();
                model = axgo.GetComponent <AXModel>();
            }

            Undo.RegisterCompleteObjectUndo(model, "Add Library Object");

            AXParametricObject head_po = poList[0];



            if (model.currentWorkingGroupPO != null && model.currentWorkingGroupPO.Name != head_po.Name)
            {
                head_po.grouperKey = model.currentWorkingGroupPO.Guid;
            }
            else
            {
                head_po.grouperKey = null;
            }



            // ADD AND RIGUP
            // !!! Actually add the library item (as a list of PO's and Relations) to the model
            model.addAndRigUp(poList, relationList);



            head_po.startStowInputs();
            //if (poList[0].is2D() && ArchimatixEngine.workingAxis != (int) Axis.NONE)
            //	poList[0].intValue ("Axis", ArchimatixEngine.workingAxis);


            model.setRenderMode(AXModel.RenderMode.GameObjects);
            model.generate();

            ArchimatixEngine.currentModel = model;
            Selection.activeGameObject    = model.gameObject;


            model.selectOnlyPO(head_po);
            head_po.focusMe = true;


            //AXParametricObject mostRecentPO = model.recentlySelectedPO;
            AXParametricObject mostRecentPO = model.recentlySelectedPO;            //getPOSelectedBefore(head_po);



            //Debug.Log ("model.focusPointInGraphEditor="+model.focusPointInGraphEditor);

            float pos_x = (model.focusPointInGraphEditor.x) + 100;          // + UnityEngine.Random.Range(-100, 300);
            float pos_y = (model.focusPointInGraphEditor.y - 250) + UnityEngine.Random.Range(-10, 0);

            if (mostRecentPO != null)
            {
                //pos_x =  mostRecentPO.rect.x + 200;
                //pos_y =  mostRecentPO.rect.y;
            }

            //Debug.Log (new Rect(pos_x, pos_y, 150, 100));
            head_po.rect = new Rect(pos_x, pos_y, 150, 500);


            //Debug.Log ("OK "+po.Name+".focusMe = " + po.focusMe);
            // make sure it is in view in the editor window....

            //model.startPanningToRect(head_po.rect);


            //model.cleanGraph();
            model.autobuild();
            head_po.generator.adjustWorldMatrices();


            model.selectOnlyPO(head_po);



            // Paste inside grouper?
            if (model.currentWorkingGroupPO != null && model.currentWorkingGroupPO.Name != head_po.Name)
            {
                model.currentWorkingGroupPO.addGroupee(head_po);
            }


            if (model.currentWorkingGroupPO != null && model.currentWorkingGroupPO.Name == head_po.Name)
            {
                model.currentWorkingGroupPO = model.currentWorkingGroupPO.grouper;
            }


            //model.beginPanningToRect(head_po.rect);
            //AXNodeGraphEditorWindow.zoomToRectIfOpen(head_po.rect);

            //Debug.Log(" 1 model.selectedPOs.Count="+model.selectedPOs.Count + " " + model.selectedPOs[0].Name );
            // EDITOR WINDOW
            ArchimatixEngine.repaintGraphEditorIfExistsAndOpen();



            // SCENEVIEW
            if (SceneView.lastActiveSceneView != null)
            {
                //Debug.Log("REPAINT");
                SceneView.lastActiveSceneView.Repaint();
            }

            //Debug.Log("--> ArchimatixEngine.currentModel=" + ArchimatixEngine.currentModel);


            return(head_po);
        }
示例#25
0
 public static JSONNode Parse(string aJSON)
 {
     return(JSONNode.Parse(aJSON));
 }
示例#26
0
        /* READ_LIBRARY FROM FILES
         * If the cache is there, use it.
         * Otherwise...
         * Parse all the files in the Library data folder
         * and, using the head object, extract meta data and build indices.
         */
        public void readLibraryFromFiles()
        {
            //Debug.Log("read library");
            //StopWatch sw = new StopWatch();

            /* Maintain a live list of all the files found
             * as head POs
             *
             */
            parametricObjects = new List <AXParametricObject>();
            libraryItems      = new List <LibraryItem>();

            DirectoryInfo info = new DirectoryInfo(Application.dataPath);

            FileInfo[] files = info.GetFiles("*.axobj", SearchOption.AllDirectories);

            //Debug.Log ("LIBRARY READ " + files.Length);

            try
            {
                //foreach (var filepathname in files)
                for (int i = 0; i < files.Length; i++)
                {
                    //Debug.Log ("file: " + files[i].ToString());
                    string filepathname = files[i].ToString();

                    AX.SimpleJSON.JSONNode jn = AX.SimpleJSON.JSON.Parse(File.ReadAllText(filepathname));


                    AXParametricObject head_po = null;


                    if (jn ["parametric_objects"] != null)
                    {
                        head_po = JSONSerializersAX.ParametricObjectFromJSON(jn ["parametric_objects"] [0]);
                    }
                    else
                    {
                        head_po = JSONSerializersAX.ParametricObjectFromJSON(jn [0]);
                    }

                    //head_po.readIntoLibraryFromPathname = filepathname;
                    head_po.readIntoLibraryFromRelativeAXOBJPath = ArchimatixUtils.getRelativeFilePath(filepathname);



                    parametricObjects.Add(head_po);


                    libraryItems.Add(new LibraryItem(head_po));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }



            rebuildTagListsFromExistingPOs();



            cacheLibraryItems();


            //Debug.Log ("LIBRARY READ IN "+sw.stop()+" MILLISECONDS " + parametricObjects.Count + " items.");
        }
示例#27
0
        public static JSONNode Parse(string aJSON)
        {
            Stack <JSONNode> stack = new Stack <JSONNode>();
            JSONNode         ctx   = null;
            int    i         = 0;
            string Token     = "";
            string TokenName = "";
            bool   QuoteMode = false;

            while (i < aJSON.Length)
            {
                switch (aJSON[i])
                {
                case '{':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    stack.Push(new JSONClass());
                    if (ctx != null)
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(stack.Peek());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, stack.Peek());
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    ctx       = stack.Peek();
                    break;

                case '[':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }

                    stack.Push(new JSONArray());
                    if (ctx != null)
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(stack.Peek());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, stack.Peek());
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    ctx       = stack.Peek();
                    break;

                case '}':
                case ']':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    if (stack.Count == 0)
                    {
                        throw new Exception("JSON Parse: Too many closing brackets");
                    }

                    stack.Pop();
                    if (Token != "")
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(Token);
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, Token);
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    if (stack.Count > 0)
                    {
                        ctx = stack.Peek();
                    }
                    break;

                case ':':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    TokenName = Token;
                    Token     = "";
                    break;

                case '"':
                    QuoteMode ^= true;
                    break;

                case ',':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    if (Token != "")
                    {
                        if (ctx is JSONArray)
                        {
                            ctx.Add(Token);
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, Token);
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    break;

                case '\r':
                case '\n':
                    break;

                case ' ':
                case '\t':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                    }
                    break;

                case '\\':
                    ++i;
                    if (QuoteMode)
                    {
                        char C = aJSON[i];
                        switch (C)
                        {
                        case 't': Token += '\t'; break;

                        case 'r': Token += '\r'; break;

                        case 'n': Token += '\n'; break;

                        case 'b': Token += '\b'; break;

                        case 'f': Token += '\f'; break;

                        case 'u':
                        {
                            string s = aJSON.Substring(i + 1, 4);
                            Token += (char)int.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier);
                            i     += 4;
                            break;
                        }

                        default: Token += C; break;
                        }
                    }
                    break;

                default:
                    Token += aJSON[i];
                    break;
                }
                ++i;
            }
            if (QuoteMode)
            {
                throw new Exception("JSON Parse: Quotation marks seems to be messed up.");
            }
            return(ctx);
        }
示例#28
0
 public virtual JSONNode Remove(JSONNode aNode)
 {
     return(aNode);
 }
示例#29
0
 public JSONLazyCreator(JSONNode aNode, string aKey)
 {
     m_Node = aNode;
     m_Key  = aKey;
 }
示例#30
0
        public static AXParametricObject ParametricObjectFromJSON(AX.SimpleJSON.JSONNode jn)
        {
            AXParametricObject po = new AXParametricObject(jn["type"], jn["name"]);


            po.Guid = jn["guid"].Value;

            po.basedOnAssetWithGUID = jn["basedOnAssetWithGUID"].Value;

            po.description      = jn["description"].Value;
            po.author           = jn["author"].Value;
            po.tags             = jn["tags"].Value;
            po.documentationURL = jn["documentationURL"].Value;

            if (jn["includeInSidebarMenu"] != null)
            {
                po.includeInSidebarMenu = jn["includeInSidebarMenu"].AsBool;
            }
            else
            {
                po.includeInSidebarMenu = true;
            }

            po.isInitialized = jn["isInitialized"].AsBool;


            po.grouperKey = jn["grouperKey"].Value;

            if (jn["sortval"] != null)
            {
                po.sortval = jn["sortval"].AsFloat;
            }

            po.curve = AXJson.CurveFromJSON(jn["curve"]);

            po.rect        = AXJson.RectFromJSON(jn["rect"]);
            po.bounds      = AXJson.BoundsFromJSON(jn["bounds"]);
            po.transMatrix = AXJson.Matrix4x4FromJSON(jn["transMatrix"]);

            po.combineMeshes = jn["combineMeshes"].AsBool;
            po.isRigidbody   = jn["isRigidbody"].AsBool;
            po.colliderType  = (AXGeometryTools.ColliderType)jn["colliderType"].AsInt;

            po.axStaticEditorFlags = (AXStaticEditorFlags)jn["axStaticEditorFlags"].AsInt;

            //Debug.Log(po.Name + " " + po.grouperKey);

            // material
            // look to see if there is a material matching this name....
                        #if UNITY_EDITOR
            if (jn["material_assetGUID"] != null)
            {
                string path = AssetDatabase.GUIDToAssetPath(jn["material_assetGUID"].Value);

                //Debug.Log("AssetDatabase.GUIDToAssetPath("+jn["material_assetGUID"].Value+") has path: "  + path);


                // REDO
                if (path != null)
                {
                    //Debug.Log(jn["Name"] + ": path="+path);
                    Material matter = (Material)AssetDatabase.LoadAssetAtPath(path, typeof(Material));

                    //Debug.Log("..."+matter);
                    //po.axMat.mat = (Material) AssetDatabase.LoadAssetAtPath(path, typeof(Material)) ;
                    if (po.axMat == null)
                    {
                        po.axMat = new AXMaterial();
                    }
                    po.axMat.mat = matter;
                }
            }
                        #endif



            // code
            if (jn["code"] != null)
            {
                po.code = jn["code"].Value.Replace(";", "\n");
            }
            // parameters

            if (jn["parameters"] != null)
            {
                po.parameters = new List <AXParameter>();

                foreach (AX.SimpleJSON.JSONNode jn_p in jn["parameters"].AsArray)
                {
                    po.addParameter(AXParameter.fromJSON(jn_p));
                }
            }
            // shapes
            if (jn["shapes"] != null)
            {
                po.shapes = new List <AXShape>();
                foreach (AX.SimpleJSON.JSONNode jn_p in jn["shapes"].AsArray)
                {
                    po.shapes.Add(AXShape.fromJSON(po, jn_p));
                }
            }



            // handles
            if (jn["handles"] != null)
            {
                po.handles = new List <AXHandle>();
                foreach (AX.SimpleJSON.JSONNode jn_h in jn["handles"].AsArray)
                {
                    po.handles.Add(AXHandle.fromJSON(jn_h));
                }
            }

            // cameraSettings
            if (jn["cameraSettings"] != null)
            {
                po.cameraSettings = JSONSerializersAX.AXCameraFromJSON(jn["cameraSettings"]);
                po.cameraSettings.setPosition();
            }


            // make the generator for this po
            po.instantiateGenerator();

            return(po);
        }