public void ExportGeometryData_MeshUnityDecomposer_DefaultGeometry() { // Force runtime mode to set testing package root RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/"); RuntimeUrdf.runtimeModeEnabled = false; UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings(); UrdfRobotExtensions.importsettings.convexMethod = ImportSettings.convexDecomposer.unity; var parent = new GameObject("Parent").transform; string path = "package://meshes/cube.stl"; var meshGeometry = new Geometry(mesh: new Mesh(path, new double[] { 1, 1, 1 })); UrdfCollisionExtensions.Create(parent, new Collision(meshGeometry)); UrdfExportPathHandler.SetExportPath("Assets"); var t = parent.GetComponentInChildren <UrdfCollision>().transform.GetChild(0); var export = UrdfGeometry.ExportGeometryData(GeometryTypes.Mesh, t); Assert.IsNotNull(export); Object.DestroyImmediate(parent.gameObject); List <string> outFailedPaths = new List <string>(); AssetDatabase.DeleteAssets(new string[] { "Assets/meshes" }, outFailedPaths); }
public static void ExportRobotToUrdf(this UrdfRobot urdfRobot, string exportRootFolder, string exportDestination) { UrdfExportPathHandler.SetExportPath(exportRootFolder, exportDestination); urdfRobot.FilePath = Path.Combine(UrdfExportPathHandler.GetExportDestination(), urdfRobot.name + ".urdf"); Robot robot = urdfRobot.ExportRobotData(); if (robot == null) { return; } robot.WriteToUrdf(); UnityEngine.Debug.Log(robot.name + " was exported to " + UrdfExportPathHandler.GetExportDestination()); UrdfMaterial.Materials.Clear(); UrdfExportPathHandler.Clear(); AssetDatabase.Refresh(); }