diff --git a/examples/biorbd/models/double_pendulum.bioMod b/examples/biorbd/models/double_pendulum.bioMod index c764997..05921ea 100644 --- a/examples/biorbd/models/double_pendulum.bioMod +++ b/examples/biorbd/models/double_pendulum.bioMod @@ -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 @@ -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 diff --git a/pyorerun/biorbd_components/model_interface.py b/pyorerun/biorbd_components/model_interface.py index 91eacc7..10a0d5d 100644 --- a/pyorerun/biorbd_components/model_interface.py +++ b/pyorerun/biorbd_components/model_interface.py @@ -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 diff --git a/pyorerun/biorbd_components/model_updapter.py b/pyorerun/biorbd_components/model_updapter.py index bfa882a..4ce923b 100644 --- a/pyorerun/biorbd_components/model_updapter.py +++ b/pyorerun/biorbd_components/model_updapter.py @@ -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)