public void Search(XmlNodeList node) { foreach (XmlNode child in node) { foreach (XmlNode child1 in child) { Debug.Log("노드 : " + child1.Name); //Debug.Log("root name : " + child1.Name); //<Transform> root의 transform 값 받아오는 처리 if (child1.Name.Equals("Transform") == true) { for (int i = 0; i < child1.Attributes.Count; ++i) { if (child1.Attributes[i].Name.Equals("translation") == true) { C_translation = child1.Attributes[i].Value; //Debug.Log("translation : " + C_translation); SC_translation = C_translation.Split(sp); } if (child1.Attributes[i].Name.Equals("scale") == true) { C_scale = child1.Attributes[i].Value; Debug.Log("scale" + C_scale); SC_scale = C_scale.Split(sp); } if (child1.Attributes[i].Name.Equals("rotation") == true) { C_rotation = child1.Attributes[i].Value; Debug.Log("rotation : " + C_rotation); SC_rotation = C_rotation.Split(sp); } if (child1.Attributes[i].Name.Equals("DEF") == true) { C_DEF = child1.Attributes[i].Value; Debug.Log("DEF : " + C_DEF); } } } //<Coorrinate> root경우의 속성값 받아오는 처리 if (child1.Name.Equals("Coordinate") == true) { for (int i = 0; i < child1.Attributes.Count; ++i) { if (child1.Attributes[i].Name.Equals("point") == true) { C_point = child1.Attributes[i].Value; } } //_Vertex 리스트에 값 대입 string[] SC_point = C_point.Split(sp); //Position 값들 for (int i = 0; i < SC_point.Length; i += 3) { if (i + 1 >= SC_point.Length || i + 2 >= SC_point.Length) { continue; } SC_point[i] = SC_point[i].Replace(",", ""); SC_point[i + 1] = SC_point[i + 1].Replace(",", ""); SC_point[i + 2] = SC_point[i + 2].Replace(",", ""); _Vertex.Add(new Vector3( System.Convert.ToSingle(SC_point[i]), System.Convert.ToSingle(SC_point[i + 1]), System.Convert.ToSingle(SC_point[i + 2]))); } Debug.Log("Vertex 값 : " + C_point); } //<IndexedFaceSet> root경우의 속성값 받아오는 처리 if (child1.Name.Equals("IndexedFaceSet") == true) { shapeType = "Face"; //Debug.Log("Type : IndexedFaceSet "); for (int i = 0; i < child1.Attributes.Count; ++i) { if (child1.Attributes[i].Name.Equals("coordIndex") == true) { C_index = child1.Attributes[i].Value; Debug.Log("coordIndex : " + C_index); } } //_Tri 리스트에 값 대입 string[] SC_index = C_index.Split(sp); int nResult = 0; for (int i = 0; i < SC_index.Length; i++) { if (int.TryParse(SC_index[i], out nResult) == true) { if (int.Parse(SC_index[i]) == -1) { continue; } _Tri.Add(int.Parse(SC_index[i])); } } } //<Box> root경우의 속성값 받아오는 처리 if (child1.Name.Equals("Box") == true) { Debug.Log("Type : Box "); shapeType = "Box"; for (int i = 0; i < child1.Attributes.Count; ++i) { if (child1.Attributes[i].Name.Equals("size") == true) { Debug.Log("X Y Z : " + child1.Attributes[i].Value); C_xyz = child1.Attributes[i].Value; } } //string으로 받아넨 xyz를 공백문자(sp)로 잘라 각각의 값으로 변환 string[] SC_xyz = C_xyz.Split(sp); //Box_Size 구조체에 float 형변환 후 대입 size.x = System.Convert.ToSingle(SC_xyz[0]); size.y = System.Convert.ToSingle(SC_xyz[1]); size.z = System.Convert.ToSingle(SC_xyz[2]); } //<Cone> root경우의 속성값 받아오는 처리 if (child1.Name.Equals("Cone") == true) { shapeType = "Cone"; Debug.Log("Type : Cone "); for (int i = 0; i < child1.Attributes.Count; ++i) { if (child1.Attributes[i].Name.Equals("bottom") == true) { C_V.bottom = child1.Attributes[i].Value; Debug.Log("Bottom : " + child1.Attributes[i].Value); } else if (child1.Attributes[i].Name.Equals("bottomRadius") == true) { C_V.bottomRadius = System.Convert.ToSingle(child1.Attributes[i].Value); Debug.Log("bottomRadius : " + child1.Attributes[i].Value); } else if (child1.Attributes[i].Name.Equals("height") == true) { C_V.height = System.Convert.ToSingle(child1.Attributes[i].Value); Debug.Log("height : " + child1.Attributes[i].Value); } else if (child1.Attributes[i].Name.Equals("side") == true) { C_V.side = child1.Attributes[i].Value; Debug.Log("side : " + child1.Attributes[i].Value); } } } //<Sphere> root경우의 속성값 받아오는 처리 if (child1.Name.Equals("Sphere") == true) { shapeType = "Sphere"; Debug.Log("Type : Sphere "); } //<Cylinder> root경우의 속성값 받아오는 처리 if (child1.Name.Equals("Cylinder") == true) { shapeType = "Cylinder"; Debug.Log("Type : Cylinder"); for (int i = 0; i < child1.Attributes.Count; ++i) { if (child1.Attributes[i].Name.Equals("bottom") == true) { Cl_V.bottom = child1.Attributes[i].Value; Debug.Log("bottom : " + child1.Attributes[i].Value); } else if (child1.Attributes[i].Name.Equals("radius") == true) { Cl_V.radius = System.Convert.ToSingle(child1.Attributes[i].Value); Debug.Log("radius : " + child1.Attributes[i].Value); } else if (child1.Attributes[i].Name.Equals("side") == true) { Cl_V.side = child1.Attributes[i].Value; Debug.Log("side : " + child1.Attributes[i].Value); } else if (child1.Attributes[i].Name.Equals("top") == true) { Cl_V.top = child1.Attributes[i].Value; Debug.Log("top : " + child1.Attributes[i].Value); } } } //재귀호출 부분 if (child1.HasChildNodes) { XmlNodeList childNodeList = child1.SelectNodes("."); Search(childNodeList); } } } }
IEnumerator LoadCo_type(string url) { Debug.Log("Load co 실행"); Debug.Log(url); NumberT = 1; WWWForm form = new WWWForm(); form.AddField("f_name", FileName); form.AddField("numberT", NumberT); UnityWebRequest uwr = UnityWebRequest.Post(url, form); yield return(uwr.SendWebRequest()); if (uwr.isNetworkError) { Debug.Log("로딩실패: " + uwr.error); } shapeType = uwr.downloadHandler.text; Debug.Log("shapeType : " + shapeType); //디버깅용 //shapeType = "Face"; //세부 사항 로드 시작 //Primitv 케이스 일때 세부사항 읽어오기 if (shapeType.Equals("Box") == true || shapeType.Equals("Sphere") == true || shapeType.Equals("Cylinder") == true) { NumberT = 2; Debug.Log("프리미티브 함수 실행"); WWWForm form2 = new WWWForm(); form2.AddField("f_name", FileName); form2.AddField("numberT", NumberT); form2.AddField("shapeType", shapeType); UnityWebRequest uwr2 = UnityWebRequest.Post(url, form2); yield return(uwr2.SendWebRequest()); if (uwr2.isNetworkError) { Debug.Log("로딩실패: " + uwr2.error); } else { Debug.Log("Received: " + uwr2.downloadHandler.text); } C_xyz = uwr2.downloadHandler.text; Debug.Log("C_xyz : " + C_xyz); string[] SC_xyz = C_xyz.Split(sp); //Box_Size 구조체에 float 형변환 후 대입 size.x = System.Convert.ToSingle(SC_xyz[0]); size.y = System.Convert.ToSingle(SC_xyz[1]); size.z = System.Convert.ToSingle(SC_xyz[2]); RTD = 1; } if (shapeType.Equals("Face")) { NumberT = 3; Debug.Log("폴리곤(페이스) 함수 실행"); WWWForm form3 = new WWWForm(); form3.AddField("f_name", FileName); form3.AddField("numberT", NumberT); form3.AddField("shapeType", shapeType); UnityWebRequest uwr3 = UnityWebRequest.Post(url, form3); yield return(uwr3.SendWebRequest()); if (uwr3.isNetworkError) { Debug.Log("로딩실패: " + uwr3.error); } else { Debug.Log("Received: " + uwr3.downloadHandler.text); } cashString = uwr3.downloadHandler.text; cashArrayString = cashString.Split('&'); C_point = cashArrayString[0]; C_index = cashArrayString[1]; Debug.Log("Indexedface : " + C_index); Debug.Log("coordinatepoint : " + C_point); //_Vertex 리스트에 값 대입 string[] SC_point = C_point.Split(sp); //Position 값들 for (int i = 0; i < SC_point.Length; i += 3) { if (i + 1 >= SC_point.Length || i + 2 >= SC_point.Length) { continue; } SC_point[i] = SC_point[i].Replace(",", ""); SC_point[i + 1] = SC_point[i + 1].Replace(",", ""); SC_point[i + 2] = SC_point[i + 2].Replace(",", ""); _Vertex.Add(new Vector3( System.Convert.ToSingle(SC_point[i]), System.Convert.ToSingle(SC_point[i + 1]), System.Convert.ToSingle(SC_point[i + 2]))); } //_Tri 리스트에 값 대입 string[] SC_index = C_index.Split(sp); int nResult = 0; for (int i = 0; i < SC_index.Length; i++) { if (int.TryParse(SC_index[i], out nResult) == true) { if (int.Parse(SC_index[i]) == -1) { continue; } _Tri.Add(int.Parse(SC_index[i])); } } Debug.Log("_Vertex 값 : " + _Vertex); Debug.Log("_Tri 값 : " + _Tri); RTD = 1; } }