@@ -61,28 +61,47 @@ public static ZOSimDocumentRoot Import(XmlDocument xmlDocument) {
6161 XmlNode [ ] xmlVisuals = xmlLink . GetChildrenByName ( "visual" ) ;
6262
6363 foreach ( XmlNode xmlVisual in xmlVisuals ) {
64+
65+
6466 XmlNode [ ] xmlGeometries = xmlVisual . GetChildrenByName ( "geometry" ) ;
6567
6668 foreach ( XmlNode xmlGeom in xmlGeometries ) {
67- XmlNode xmlBox = xmlGeom . GetChildByName ( "box" ) ;
69+
6870 GameObject visualGeo = null ;
71+
72+ XmlNode xmlBox = xmlGeom . GetChildByName ( "box" ) ;
6973 if ( xmlBox != null ) {
7074 visualGeo = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
75+ Vector3 size = xmlBox . Attributes [ "size" ] . Value . FromURDFStringToVector3 ( ) ;
76+
77+ visualGeo . transform . localScale = size . Ros2UnityScale ( ) ;
7178 }
79+
7280 XmlNode xmlCylinder = xmlGeom . GetChildByName ( "cylinder" ) ;
7381 if ( xmlCylinder != null ) {
7482 visualGeo = GameObject . CreatePrimitive ( PrimitiveType . Cylinder ) ;
83+ float radius = float . Parse ( xmlCylinder . Attributes [ "radius" ] . Value ) ;
84+ float length = float . Parse ( xmlCylinder . Attributes [ "length" ] . Value ) ;
85+ visualGeo . transform . localScale = new Vector3 ( radius * 2.0f , length * 0.5f , radius * 2.0f ) ;
7586 }
87+
7688 XmlNode xmlSphere = xmlGeom . GetChildByName ( "sphere" ) ;
7789 if ( xmlSphere != null ) {
7890 visualGeo = GameObject . CreatePrimitive ( PrimitiveType . Sphere ) ;
91+ float radius = float . Parse ( xmlSphere . Attributes [ "radius" ] . Value ) ;
92+ visualGeo . transform . localScale = new Vector3 ( radius * 2.0f , radius * 2.0f , radius * 2.0f ) ;
7993 }
94+
8095 XmlNode xmlMesh = xmlGeom . GetChildByName ( "mesh" ) ;
8196 if ( xmlMesh != null ) {
8297 // TODO
8398 }
8499 if ( visualGeo != null ) {
85100 visualGeo . transform . SetParent ( goVisualsEmpty . transform ) ;
101+ string visualName = xmlVisual . Attributes [ "name" ] . Value ;
102+ if ( visualName != null ) {
103+ visualGeo . name = visualName ;
104+ }
86105 }
87106
88107 }
0 commit comments