Skip to content

Commit fb637f9

Browse files
authored
refactor(convert): Add physx_max_convex_hulls, max_vertices, max_voxel_res to MeshtoUSDConverter. (#57)
1 parent a256674 commit fb637f9

5 files changed

Lines changed: 49 additions & 36 deletions

File tree

apps/image_to_3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
## ***EmbodiedGen***: Image-to-3D Asset
4646
**🔖 Version**: {VERSION}
4747
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
48-
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
49-
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
48+
<a href="https://horizonrobotics.github.io/EmbodiedGen">
49+
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
5050
</a>
5151
<a href="https://arxiv.org/abs/2506.10600">
5252
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">

apps/text_to_3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
## ***EmbodiedGen***: Text-to-3D Asset
4646
**🔖 Version**: {VERSION}
4747
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
48-
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
49-
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
48+
<a href="https://horizonrobotics.github.io/EmbodiedGen">
49+
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
5050
</a>
5151
<a href="https://arxiv.org/abs/2506.10600">
5252
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">

apps/texture_edit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def active_btn_by_content(mesh_content: gr.Model3D, text_content: gr.Textbox):
5555
## ***EmbodiedGen***: Texture Generation
5656
**🔖 Version**: {VERSION}
5757
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
58-
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
59-
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
58+
<a href="https://horizonrobotics.github.io/EmbodiedGen">
59+
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
6060
</a>
6161
<a href="https://arxiv.org/abs/2506.10600">
6262
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">

apps/visualize_asset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ def end_session(req: gr.Request) -> None:
479479
480480
**🔖 Version**: {VERSION}
481481
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
482-
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
483-
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
482+
<a href="https://horizonrobotics.github.io/EmbodiedGen">
483+
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
484484
</a>
485485
<a href="https://arxiv.org/abs/2506.10600">
486486
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">

embodied_gen/data/asset_converter.py

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ class MeshtoUSDConverter(AssetConverterBase):
488488

489489
DEFAULT_BIND_APIS = [
490490
"MaterialBindingAPI",
491-
# "PhysicsMeshCollisionAPI",
492-
"PhysxDecompositionCollisionAPI",
491+
"PhysicsMeshCollisionAPI",
492+
"PhysxConvexDecompositionCollisionAPI",
493493
"PhysicsCollisionAPI",
494494
"PhysxCollisionAPI",
495495
"PhysicsMassAPI",
@@ -515,10 +515,10 @@ def __init__(
515515
if simulation_app is not None:
516516
self.simulation_app = simulation_app
517517

518-
if "exit_close" in kwargs:
519-
self.exit_close = kwargs.pop("exit_close")
520-
else:
521-
self.exit_close = True
518+
self.exit_close = kwargs.pop("exit_close", True)
519+
self.physx_max_convex_hulls = kwargs.pop("physx_max_convex_hulls", 32)
520+
self.physx_max_vertices = kwargs.pop("physx_max_vertices", 16)
521+
self.physx_max_voxel_res = kwargs.pop("physx_max_voxel_res", 10000)
522522

523523
self.usd_parms = dict(
524524
force_usd_conversion=force_usd_conversion,
@@ -548,12 +548,12 @@ def __enter__(self):
548548
def __exit__(self, exc_type, exc_val, exc_tb):
549549
"""Context manager exit, closes simulation app if created."""
550550
# Close the simulation app if it was created here
551-
if hasattr(self, "app_launcher") and self.exit_close:
552-
self.simulation_app.close()
553-
554551
if exc_val is not None:
555552
logger.error(f"Exception occurred: {exc_val}.")
556553

554+
if hasattr(self, "app_launcher") and self.exit_close:
555+
self.simulation_app.close()
556+
557557
return False
558558

559559
def convert(self, urdf_path: str, output_file: str):
@@ -601,18 +601,25 @@ def convert(self, urdf_path: str, output_file: str):
601601

602602
# Add convex decomposition collision and set ShrinkWrap.
603603
elif prim.GetName() == "mesh":
604-
approx_attr = prim.GetAttribute("physics:approximation")
605-
if not approx_attr:
606-
approx_attr = prim.CreateAttribute(
607-
"physics:approximation", Sdf.ValueTypeNames.Token
608-
)
604+
approx_attr = prim.CreateAttribute(
605+
"physics:approximation", Sdf.ValueTypeNames.Token
606+
)
609607
approx_attr.Set("convexDecomposition")
610608

611609
physx_conv_api = (
612610
PhysxSchema.PhysxConvexDecompositionCollisionAPI.Apply(
613611
prim
614612
)
615613
)
614+
physx_conv_api.GetMaxConvexHullsAttr().Set(
615+
self.physx_max_convex_hulls
616+
)
617+
physx_conv_api.GetHullVertexLimitAttr().Set(
618+
self.physx_max_vertices
619+
)
620+
physx_conv_api.GetVoxelResolutionAttr().Set(
621+
self.physx_max_voxel_res
622+
)
616623
physx_conv_api.GetShrinkWrapAttr().Set(True)
617624

618625
api_schemas = prim.GetMetadata("apiSchemas")
@@ -639,8 +646,8 @@ class PhysicsUSDAdder(MeshtoUSDConverter):
639646

640647
DEFAULT_BIND_APIS = [
641648
"MaterialBindingAPI",
642-
# "PhysicsMeshCollisionAPI",
643-
"PhysxDecompositionCollisionAPI",
649+
"PhysicsMeshCollisionAPI",
650+
"PhysxConvexDecompositionCollisionAPI",
644651
"PhysicsCollisionAPI",
645652
"PhysxCollisionAPI",
646653
"PhysicsRigidBodyAPI",
@@ -675,18 +682,23 @@ def convert(self, usd_path: str, output_file: str = None):
675682
if "lightfactory" in prim.GetName().lower():
676683
continue
677684

678-
approx_attr = prim.GetAttribute(
679-
"physics:approximation"
685+
approx_attr = prim.CreateAttribute(
686+
"physics:approximation", Sdf.ValueTypeNames.Token
680687
)
681-
if not approx_attr:
682-
approx_attr = prim.CreateAttribute(
683-
"physics:approximation",
684-
Sdf.ValueTypeNames.Token,
685-
)
686688
approx_attr.Set("convexDecomposition")
689+
687690
physx_conv_api = PhysxSchema.PhysxConvexDecompositionCollisionAPI.Apply(
688691
prim
689692
)
693+
physx_conv_api.GetMaxConvexHullsAttr().Set(
694+
self.physx_max_convex_hulls
695+
)
696+
physx_conv_api.GetHullVertexLimitAttr().Set(
697+
self.physx_max_vertices
698+
)
699+
physx_conv_api.GetVoxelResolutionAttr().Set(
700+
self.physx_max_voxel_res
701+
)
690702
physx_conv_api.GetShrinkWrapAttr().Set(True)
691703

692704
rigid_body_api = UsdPhysics.RigidBodyAPI.Apply(prim)
@@ -790,18 +802,19 @@ def convert(self, urdf_path: str, output_file: str):
790802
with Usd.EditContext(stage, layer):
791803
for prim in stage.Traverse():
792804
if prim.GetName() == "collisions":
793-
approx_attr = prim.GetAttribute("physics:approximation")
794-
if not approx_attr:
795-
approx_attr = prim.CreateAttribute(
796-
"physics:approximation", Sdf.ValueTypeNames.Token
797-
)
805+
approx_attr = prim.CreateAttribute(
806+
"physics:approximation", Sdf.ValueTypeNames.Token
807+
)
798808
approx_attr.Set("convexDecomposition")
799809

800810
physx_conv_api = (
801811
PhysxSchema.PhysxConvexDecompositionCollisionAPI.Apply(
802812
prim
803813
)
804814
)
815+
physx_conv_api.GetMaxConvexHullsAttr().Set(32)
816+
physx_conv_api.GetHullVertexLimitAttr().Set(16)
817+
physx_conv_api.GetVoxelResolutionAttr().Set(10000)
805818
physx_conv_api.GetShrinkWrapAttr().Set(True)
806819

807820
api_schemas = prim.GetMetadata("apiSchemas")

0 commit comments

Comments
 (0)