Replies: 3 comments 3 replies
-
|
@WenchaoHuang can you please comment on this? |
Beta Was this translation helpful? Give feedback.
-
|
@mdeth Thanks for your feedback! As far as I know, the current for i in range(self.model.body_count):
shape_indices = self.model.body_shapes[i]
for shape_idx in shape_indices:
if isinstance(self.model.shape_source[shape_idx], newton.Mesh):
if self.shape_flags[shape_idx] & 1 == 0:
continue
@wp.kernel
def transform_vertices_kernel(
shape_index: wp.int32,
scale: float,
shape_body: wp.array(dtype=int),
vertices_in: wp.array(dtype=wp.vec3),
scaling3d: wp.array(dtype=wp.vec3),
transforms0: wp.array(dtype=wp.transform),
transforms1: wp.array(dtype=wp.transform),
vertices_out: wp.array(dtype=wp.vec3),
):
tid = wp.tid()
scaling = scaling3d[shape_index] * scale
new_pos = wp.transform_point(transforms0[shape_index], vertices_in[tid])
new_pos = wp.transform_point(transforms1[shape_body[shape_index]], new_pos)
new_pos[0] *= scaling[0]
new_pos[1] *= scaling[1]
new_pos[2] *= scaling[2]
vertices_out[tid] = new_pos
shape_vertices = wp.array(self.model.shape_source[shape_idx].vertices, dtype=wp.vec3)
shape_indices = wp.array(self.model.shape_source[shape_idx].indices.flatten(), dtype=int)
wp.launch(
transform_vertices_kernel,
dim=len(shape_vertices),
inputs=[
shape_idx,
1.0,
self.model.shape_body,
shape_vertices,
self.model.shape_scale,
self.model.shape_transform,
self.state.body_q,
],
outputs=[shape_vertices],
)
self.viewer.log_mesh(
f"/model/triangles_{self.model.shape_key[shape_idx]}", shape_vertices, shape_indices
)This approach is a bit complicated and not recommended, but it works. Getting back to your requirement. Based on my experience, directly updating the collider's position every frame won't produce good collision results — unless the timestep is extremely small or the motion is very slow. This is because the velocity information between frames is lost in this approach. A more robust solution would be to properly develop new functionality that supports collision respond for such externally-driven meshes. So, your question suggests a new feature: collision support for externally-driven meshes. I think this is quite a common and feasible requirement. Noted — I’ll record this request and let you know when there’s any development progress. : ) |
Beta Was this translation helpful? Give feedback.
-
|
@WenchaoHuang thanks a lot for the suggestion and excuse my late reply. I did try what you proposed, and did indeed see the changes rendered. However, the mesh also kept rotating around the x or y axis by steps of 90 degrees. I see a new example in master using a humanoid robot. Could I change it to have my animated mesh instead of the robot colliding with the cloth? Also, can you elaborate why the velocity information is lost? Is it reset somewhere or is it due the solver not knowing about the mesh animation? How could handle this properly in the Style3d solver? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi team, I am trying to change the vertex positions of the currently static mesh representing a human during the simulation in the example cloth_style3d.
To test this, I currently simply scale it like this at the beginning of simulate():
self.model.shape_source[0].mesh.points *= scale
self.model.shape_source[0].mesh..refit()
The cloth actually seems to be colliding with something becoming increasingly different from the human, but the static human mesh remains static. How can I adjust the static mesh to show the scaled vertices?
Also, how could I copy custom vertex positions for each frame to the human mesh instead of just scaling?
Beta Was this translation helpful? Give feedback.
All reactions