Skip to content

Commit

Permalink
Merge pull request #40 from Ipuch/main
Browse files Browse the repository at this point in the history
feat: meshrt in biomod
  • Loading branch information
Ipuch authored Jul 11, 2024
2 parents b5e6cb2 + 9dc752c commit c782ee6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/biorbd/models/double_pendulum.bioMod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ segment Seg2
parent Seg1
rotations x
rtinmatrix 0
rt 0 0 0 xyz 0 0 -1
rt -0.1 0 0 xyz 0 0 -1
ranges
-pi/2 pi/2
mass 1
Expand All @@ -42,6 +42,7 @@ segment Seg2
0.0000 -0.0032 0.0090
com -0.0005 0.0688 -0.9542
meshfile mesh/pendulum.STL
meshrt 0.1 0 0 xyz 0 0 0
endsegment

// Marker 3
Expand Down
11 changes: 11 additions & 0 deletions pyorerun/biorbd_components/model_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,14 @@ def meshlines(self) -> list[np.ndarray]:
meshes += [np.array([segment_mesh.point(i).to_array() for i in range(segment_mesh.nbVertex())])]

return meshes

def mesh_homogenous_matrices_in_global(self, q: np.ndarray, segment_index: int) -> np.ndarray:
"""
Returns a list of homogeneous matrices of the mesh in the global reference frame
"""
mesh_rt = (
super(BiorbdModel, self).segments[segment_index].segment.characteristics().mesh().getRotation().to_array()
)
# mesh_rt = self.segments[segment_index].segment.characteristics().mesh().getRotation().to_array()
segment_rt = self.segment_homogeneous_matrices_in_global(q, segment_index=segment_index)
return segment_rt @ mesh_rt
6 changes: 5 additions & 1 deletion pyorerun/biorbd_components/model_updapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ def create_segments_updater(self):
)

if segment.has_mesh:
mesh = TransformableMeshUpdater.from_file(segment_name, segment.mesh_path, transform_callable)
mesh_transform_callable = partial(
self.model.mesh_homogenous_matrices_in_global,
segment_index=segment.id,
)
mesh = TransformableMeshUpdater.from_file(segment_name, segment.mesh_path, mesh_transform_callable)
mesh.set_transparency(self.model.options.transparent_mesh)
mesh.set_color(self.model.options.mesh_color)

Expand Down

0 comments on commit c782ee6

Please sign in to comment.