diff --git a/apps/image_to_3d.py b/apps/image_to_3d.py index 3840ebb..14e4931 100644 --- a/apps/image_to_3d.py +++ b/apps/image_to_3d.py @@ -45,8 +45,8 @@ ## ***EmbodiedGen***: Image-to-3D Asset **🔖 Version**: {VERSION}
-
-
-
-
-
-
-
-
+
+
diff --git a/apps/text_to_3d.py b/apps/text_to_3d.py
index ab41e3d..8614b48 100644
--- a/apps/text_to_3d.py
+++ b/apps/text_to_3d.py
@@ -45,8 +45,8 @@
## ***EmbodiedGen***: Text-to-3D Asset
**🔖 Version**: {VERSION}
+
+
diff --git a/apps/texture_edit.py b/apps/texture_edit.py
index d36905e..5c60b73 100644
--- a/apps/texture_edit.py
+++ b/apps/texture_edit.py
@@ -55,8 +55,8 @@ def active_btn_by_content(mesh_content: gr.Model3D, text_content: gr.Textbox):
## ***EmbodiedGen***: Texture Generation
**🔖 Version**: {VERSION}
+
+
diff --git a/apps/visualize_asset.py b/apps/visualize_asset.py
index 85e12dd..4d3257c 100644
--- a/apps/visualize_asset.py
+++ b/apps/visualize_asset.py
@@ -479,8 +479,8 @@ def end_session(req: gr.Request) -> None:
**🔖 Version**: {VERSION}
+
+
diff --git a/embodied_gen/data/asset_converter.py b/embodied_gen/data/asset_converter.py
index f4e1ac6..5499e53 100644
--- a/embodied_gen/data/asset_converter.py
+++ b/embodied_gen/data/asset_converter.py
@@ -488,8 +488,8 @@ class MeshtoUSDConverter(AssetConverterBase):
DEFAULT_BIND_APIS = [
"MaterialBindingAPI",
- # "PhysicsMeshCollisionAPI",
- "PhysxDecompositionCollisionAPI",
+ "PhysicsMeshCollisionAPI",
+ "PhysxConvexDecompositionCollisionAPI",
"PhysicsCollisionAPI",
"PhysxCollisionAPI",
"PhysicsMassAPI",
@@ -515,10 +515,10 @@ def __init__(
if simulation_app is not None:
self.simulation_app = simulation_app
- if "exit_close" in kwargs:
- self.exit_close = kwargs.pop("exit_close")
- else:
- self.exit_close = True
+ self.exit_close = kwargs.pop("exit_close", True)
+ self.physx_max_convex_hulls = kwargs.pop("physx_max_convex_hulls", 32)
+ self.physx_max_vertices = kwargs.pop("physx_max_vertices", 16)
+ self.physx_max_voxel_res = kwargs.pop("physx_max_voxel_res", 10000)
self.usd_parms = dict(
force_usd_conversion=force_usd_conversion,
@@ -548,12 +548,12 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
"""Context manager exit, closes simulation app if created."""
# Close the simulation app if it was created here
- if hasattr(self, "app_launcher") and self.exit_close:
- self.simulation_app.close()
-
if exc_val is not None:
logger.error(f"Exception occurred: {exc_val}.")
+ if hasattr(self, "app_launcher") and self.exit_close:
+ self.simulation_app.close()
+
return False
def convert(self, urdf_path: str, output_file: str):
@@ -601,11 +601,9 @@ def convert(self, urdf_path: str, output_file: str):
# Add convex decomposition collision and set ShrinkWrap.
elif prim.GetName() == "mesh":
- approx_attr = prim.GetAttribute("physics:approximation")
- if not approx_attr:
- approx_attr = prim.CreateAttribute(
- "physics:approximation", Sdf.ValueTypeNames.Token
- )
+ approx_attr = prim.CreateAttribute(
+ "physics:approximation", Sdf.ValueTypeNames.Token
+ )
approx_attr.Set("convexDecomposition")
physx_conv_api = (
@@ -613,6 +611,15 @@ def convert(self, urdf_path: str, output_file: str):
prim
)
)
+ physx_conv_api.GetMaxConvexHullsAttr().Set(
+ self.physx_max_convex_hulls
+ )
+ physx_conv_api.GetHullVertexLimitAttr().Set(
+ self.physx_max_vertices
+ )
+ physx_conv_api.GetVoxelResolutionAttr().Set(
+ self.physx_max_voxel_res
+ )
physx_conv_api.GetShrinkWrapAttr().Set(True)
api_schemas = prim.GetMetadata("apiSchemas")
@@ -639,8 +646,8 @@ class PhysicsUSDAdder(MeshtoUSDConverter):
DEFAULT_BIND_APIS = [
"MaterialBindingAPI",
- # "PhysicsMeshCollisionAPI",
- "PhysxDecompositionCollisionAPI",
+ "PhysicsMeshCollisionAPI",
+ "PhysxConvexDecompositionCollisionAPI",
"PhysicsCollisionAPI",
"PhysxCollisionAPI",
"PhysicsRigidBodyAPI",
@@ -675,18 +682,23 @@ def convert(self, usd_path: str, output_file: str = None):
if "lightfactory" in prim.GetName().lower():
continue
- approx_attr = prim.GetAttribute(
- "physics:approximation"
+ approx_attr = prim.CreateAttribute(
+ "physics:approximation", Sdf.ValueTypeNames.Token
)
- if not approx_attr:
- approx_attr = prim.CreateAttribute(
- "physics:approximation",
- Sdf.ValueTypeNames.Token,
- )
approx_attr.Set("convexDecomposition")
+
physx_conv_api = PhysxSchema.PhysxConvexDecompositionCollisionAPI.Apply(
prim
)
+ physx_conv_api.GetMaxConvexHullsAttr().Set(
+ self.physx_max_convex_hulls
+ )
+ physx_conv_api.GetHullVertexLimitAttr().Set(
+ self.physx_max_vertices
+ )
+ physx_conv_api.GetVoxelResolutionAttr().Set(
+ self.physx_max_voxel_res
+ )
physx_conv_api.GetShrinkWrapAttr().Set(True)
rigid_body_api = UsdPhysics.RigidBodyAPI.Apply(prim)
@@ -790,11 +802,9 @@ def convert(self, urdf_path: str, output_file: str):
with Usd.EditContext(stage, layer):
for prim in stage.Traverse():
if prim.GetName() == "collisions":
- approx_attr = prim.GetAttribute("physics:approximation")
- if not approx_attr:
- approx_attr = prim.CreateAttribute(
- "physics:approximation", Sdf.ValueTypeNames.Token
- )
+ approx_attr = prim.CreateAttribute(
+ "physics:approximation", Sdf.ValueTypeNames.Token
+ )
approx_attr.Set("convexDecomposition")
physx_conv_api = (
@@ -802,6 +812,9 @@ def convert(self, urdf_path: str, output_file: str):
prim
)
)
+ physx_conv_api.GetMaxConvexHullsAttr().Set(32)
+ physx_conv_api.GetHullVertexLimitAttr().Set(16)
+ physx_conv_api.GetVoxelResolutionAttr().Set(10000)
physx_conv_api.GetShrinkWrapAttr().Set(True)
api_schemas = prim.GetMetadata("apiSchemas")