77from .coacd import do_coacd
88
99
10+
1011def preprocess_mesh_file (filename : str ):
1112 """
1213 Process input mesh file to a SAPIEN supported format
@@ -16,7 +17,7 @@ def preprocess_mesh_file(filename: str):
1617 filename for the generated file or original filename
1718 """
1819
19- from .geometry .usd import convert_usd_to_glb
20+ from sapien . wrapper .geometry .usd import convert_usd_to_glb
2021
2122 if any (filename .lower ().endswith (s ) for s in [".usd" , ".usda" , ".usdc" , ".usdz" ]):
2223 glb_filename = filename + ".sapien.glb"
@@ -62,6 +63,7 @@ class CollisionShapeRecord:
6263 decomposition_params : Union [Dict [str , Any ], None ] = None
6364
6465
66+
6567@dataclass
6668class VisualShapeRecord :
6769 type : Literal ["file" , "plane" , "box" , "capsule" , "sphere" , "cylinder" ]
@@ -97,7 +99,9 @@ def __init__(self):
9799 self ._cmass_local_pose = sapien .Pose ()
98100 self ._inertia = np .zeros (3 )
99101 self ._auto_inertial = True
100-
102+ self .disable_gravity : bool = False
103+ self .linear_damping : float = 0.0
104+ self .angular_damping : float = 0.0
101105 self .initial_pose = sapien .Pose ()
102106
103107 def set_initial_pose (self , pose ):
@@ -132,8 +136,7 @@ def build_render_component(self):
132136 else :
133137 assert r .material is None or isinstance (
134138 r .material , sapien .render .RenderMaterial
135- )
136-
139+ ) # gravity property is temporarily placed here.
137140 if r .type == "plane" :
138141 shape = sapien .render .RenderShapePlane (r .scale , r .material )
139142 elif r .type == "box" :
@@ -168,13 +171,22 @@ def build_physx_component(self, link_parent=None):
168171
169172 if self .physx_body_type == "dynamic" :
170173 component = sapien .physx .PhysxRigidDynamicComponent ()
174+ component .set_linear_damping (self .linear_damping )
175+ component .set_angular_damping (self .angular_damping )
176+ component .set_disable_gravity (self .disable_gravity )
171177 elif self .physx_body_type == "kinematic" :
172178 component = sapien .physx .PhysxRigidDynamicComponent ()
179+ component .set_linear_damping (self .linear_damping )
180+ component .set_angular_damping (self .angular_damping )
181+ component .set_disable_gravity (self .disable_gravity )
173182 component .kinematic = True
174183 elif self .physx_body_type == "static" :
175184 component = sapien .physx .PhysxRigidStaticComponent ()
176185 elif self .physx_body_type == "link" :
177186 component = sapien .physx .PhysxArticulationLinkComponent (link_parent )
187+ component .set_linear_damping (self .linear_damping )
188+ component .set_angular_damping (self .angular_damping )
189+ component .set_disable_gravity (self .disable_gravity )
178190 else :
179191 raise Exception (f"invalid physx body type [{ self .physx_body_type } ]" )
180192
@@ -280,7 +292,7 @@ def build(self, name=None):
280292
281293 entity = self .build_entity ()
282294 entity .name = self .name
283- entity .pose = self .initial_pose # set pose before adding to scene
295+ entity .set_pose ( self .initial_pose ) # set pose before adding to scene
284296 self .scene .add_entity (entity )
285297 return entity
286298
0 commit comments