public static Link.Collision ExportCollisionData(this UrdfCollision urdfCollision) { UrdfGeometry.CheckForUrdfCompatibility(urdfCollision.transform, urdfCollision.geometryType); Link.Geometry geometry = UrdfGeometry.ExportGeometryData(urdfCollision.geometryType, urdfCollision.transform, true); string collisionName = urdfCollision.name == "unnamed" ? null : urdfCollision.name; return(new Link.Collision(geometry, collisionName, UrdfOrigin.ExportOriginData(urdfCollision.transform))); }
public static void Create(Transform parent, Link.Collision collision) { GameObject collisionObject = new GameObject("unnamed"); collisionObject.transform.SetParentAndAlign(parent); UrdfCollision urdfCollision = collisionObject.AddComponent <UrdfCollision>(); urdfCollision.geometryType = UrdfGeometry.GetGeometryType(collision.geometry); UrdfGeometryCollision.Create(collisionObject.transform, urdfCollision.geometryType, collision.geometry); UrdfOrigin.ImportOriginData(collisionObject.transform, collision.origin); }
public static void Create(Transform parent, Link.Visual visual) { GameObject visualObject = new GameObject(visual.name ?? "unnamed"); visualObject.transform.SetParentAndAlign(parent); UrdfVisual urdfVisual = visualObject.AddComponent <UrdfVisual>(); urdfVisual.GeometryType = UrdfGeometry.GetGeometryType(visual.geometry); UrdfGeometryVisual.Create(visualObject.transform, urdfVisual.GeometryType, visual.geometry); UrdfMaterial.SetUrdfMaterial(visualObject, visual.material); UrdfOrigin.ImportOriginData(visualObject.transform, visual.origin); }
public static Link.Visual ExportVisualData(this UrdfVisual urdfVisual) { UrdfGeometry.CheckForUrdfCompatibility(urdfVisual.transform, urdfVisual.geometryType); Link.Geometry geometry = UrdfGeometry.ExportGeometryData(urdfVisual.geometryType, urdfVisual.transform); Link.Visual.Material material = null; if ((geometry.mesh != null)) { material = UrdfMaterial.ExportMaterialData(urdfVisual.GetComponentInChildren <MeshRenderer>().sharedMaterial); } string visualName = urdfVisual.name == "unnamed" ? null : urdfVisual.name; return(new Link.Visual(geometry, visualName, UrdfOrigin.ExportOriginData(urdfVisual.transform), material)); }
public static void Create(Transform parent, Link.Collision collision) { if (String.IsNullOrEmpty(collision.name)) { collision.name = collision.GenerateNonReferenceID(); } if (parent.FindChildOrCreateWithComponent(collision.name, out GameObject collisionObject, out UrdfCollision urdfCollision)) { urdfCollision.geometryType = UrdfGeometry.GetGeometryType(collision.geometry); UrdfGeometryCollision.Create(collisionObject.transform, urdfCollision.geometryType, collision.geometry); UrdfOrigin.ImportOriginData(collisionObject.transform, collision.origin); } }
public static Link.Visual ExportVisualData(this UrdfVisual urdfVisual) { UrdfGeometry.CheckForUrdfCompatibility(urdfVisual.transform, urdfVisual.GeometryType); Link.Geometry geometry = UrdfGeometry.ExportGeometryData(urdfVisual.GeometryType, urdfVisual.transform); Link.Visual.Material material = null; if (!(geometry.mesh != null && geometry.mesh.filename.ToLower().EndsWith(".dae"))) //Collada files contain their own materials { material = UrdfMaterial.ExportMaterialData(urdfVisual.GetComponentInChildren <MeshRenderer>().sharedMaterial); } string visualName = urdfVisual.name == "unnamed" ? null : urdfVisual.name; return(new Link.Visual(geometry, visualName, UrdfOrigin.ExportOriginData(urdfVisual.transform), material)); }
public static void Create(Transform parent, Link.Visual visual) { if (String.IsNullOrEmpty(visual.name)) { visual.name = visual.GenerateNonReferenceID(); } if (parent.FindChildOrCreateWithComponent <UrdfVisual>(visual.name, out GameObject visualObject, out UrdfVisual urdfVisual)) { //only create these visuals if the gameobject had to be created itself urdfVisual.GeometryType = UrdfGeometry.GetGeometryType(visual.geometry); UrdfGeometryVisual.Create(visualObject.transform, urdfVisual.GeometryType, visual.geometry); } //update these values every time UrdfMaterial.SetUrdfMaterial(visualObject, visual.material); UrdfOrigin.ImportOriginData(visualObject.transform, visual.origin); }
private void DisplayWarnings() { if (!urdfVisual.transform.HasExactlyOneChild()) { GUILayout.Space(5); EditorGUILayout.HelpBox("Visual element must have one and only one child Geometry element.", MessageType.Error); } else if (UrdfGeometry.IsTransformed(urdfVisual.transform.GetChild(0), urdfVisual.GeometryType)) { GUILayout.Space(5); EditorGUILayout.HelpBox("Changes to the transform of the child Geometry element cannot be exported to URDF. " + "Make any translation, rotation, or scale changes to this Visual object instead.", MessageType.Error); if (GUILayout.Button("Fix transformations")) { bool transferRotation = urdfVisual.GeometryType != GeometryTypes.Mesh; urdfVisual.transform.MoveChildTransformToParent(transferRotation); } } }