private static Link.Geometry ExportGeometryMeshData(GameObject geometryObject, double[] urdfSize, bool isCollisionGeometry) { string newFilePath = UrdfMeshExportHandler.CopyOrCreateMesh(geometryObject, isCollisionGeometry); string packagePath = UrdfExportPathHandler.GetPackagePathForMesh(newFilePath); return(new Link.Geometry(null, null, null, new Link.Geometry.Mesh(packagePath, urdfSize))); }
private static Link.Visual.Material.Texture ExportTextureData(Texture texture) { string oldTexturePath = UrdfAssetPathHandler.GetFullAssetPath(RuntimeUrdf.AssetDatabase_GetAssetPath(texture)); string newTexturePath = UrdfExportPathHandler.GetNewResourcePath(Path.GetFileName(oldTexturePath)); if (oldTexturePath != newTexturePath) { File.Copy(oldTexturePath, newTexturePath, true); } string packagePath = UrdfExportPathHandler.GetPackagePathForResource(newTexturePath); return(new Link.Visual.Material.Texture(packagePath)); }
private static string CopyMeshToExportDestination(string prefabPath) { string newPrefabPath = UrdfExportPathHandler.GetNewMeshPath(Path.GetFileName(prefabPath)); if (Path.GetExtension(prefabPath)?.ToLower() == ".dae") { CopyDaeTextureToExportDestination(prefabPath, Path.GetDirectoryName(newPrefabPath)); } prefabPath = UrdfAssetPathHandler.GetFullAssetPath(prefabPath); CopyFileToNewLocation(prefabPath, newPrefabPath); return(newPrefabPath); }
private static string CreateNewStlFile(GameObject geometryObject, bool isCollisionGeometry) { Debug.Log("Did not find an existing STL or DAE file for Geometry Mesh " + geometryObject.name + ". Exporting a new STL file.", geometryObject); string newMeshPath = UrdfExportPathHandler.GetNewMeshPath(geometryObject.name + ".stl"); StlExporter stlExporter = new StlExporter(newMeshPath, geometryObject, isCollisionGeometry); if (!stlExporter.Export()) { Debug.LogWarning("Mesh export for geometry " + geometryObject.name + " failed.", geometryObject); } return(newMeshPath); }
public static void ExportRobotToUrdf(this UrdfRobot urdfRobot, string exportRootFolder, string exportDestination = "") { #if UNITY_EDITOR UrdfExportPathHandler.SetExportPath(exportRootFolder, exportDestination); urdfRobot.FilePath = Path.Combine(UrdfExportPathHandler.GetExportDestination(), urdfRobot.name + ".urdf"); Robot robot = urdfRobot.ExportRobotData(); if (robot == null) { return; } robot.WriteToUrdf(); Debug.Log(robot.name + " was exported to " + UrdfExportPathHandler.GetExportDestination()); UrdfMaterial.Materials.Clear(); UrdfExportPathHandler.Clear(); AssetDatabase.Refresh(); #else Debug.LogError("URDF Export is only available in Editor."); #endif }