3. Use the Mesh Importer#
In this tutorial, we will be using the mesh importer feature of OpenSim Creator to create a double pendulum:
The mesh importer is âlooserâ than the main osim
editor. This can make placing and orienting bodies/joints easier. However, its disadvantage is that it doesnât directly edit an osim
file. Rather, it edits a simplified âmodelâ that can be exported to the (more complex) osim
format. For this reason, the mesh importer is recommended as a first-step utility that helps set up the top-level osim
model in preparation for the osim
editor to tackle the things like adding/editing forces, contact surfaces, etc.
Although the model we will make in this tutorial is effectively an extension of Make a Pendulum, the approach used is different. Here, we will be using the mesh importer feature of OpenSim Creator to create the model, rather than building the model directly in the OpenSim model (.osim
) editor.
3.1. Prerequisites#
This tutorial assumes the reader knows a little bit more about OpenSim, bodies, joints, etc. Because of that, each step here will require moreâbut hopefully, by now, familiarâactions. Youâre getting faster âĄ!
3.2. Topics Covered by this Tutorial#
Using the mesh importer to create a basic OpenSim model
UI features and shortcuts in the mesh importer
Exporting + simulating the model created by the mesh importer
3.3. Open the Mesh Importer#
The mesh importer is a separate UI from the main osim
editor. It creates/manipulates a free-form 3D scene that can be exported to an osim
model. You can open the mesh importer from the home tab through either the main menu, the +
button on the tab bar, or the green button in the center of the home tab:s
Once opened, you will be greeted with a new mesh importer scene, which will be used for the next few steps of this tutorial:
3.4. Add Bodies & PinJoints#
Note
In the mesh importer, bodies are added into the scene by either right-clicking somewhere in the 3D scene and clicking Add Other > Body
or by using the dropdown button at the top of the scene: Add Other > Body
.
Joints are added by right-clicking on a body in the scene and clicking Join to
or Add > Joint
, followed by selecting what to join to. The body that was initially right-clicked will become the jointâs child, the thing being joined to becomes the jointâs parent.
All scene elements in the mesh importer can be edited by right-clicking them. Feel free to experiment with the available menus/actions đ©âđŹ. Accidents can always be reversed with undo (Ctrl+Z
or Edit > Undo
).
To add the various bodies + joints into the model, you will need to complete the following sub-steps:
3.4.1. Create the body of the top pendulum#
Add a body into the scene.
Name it
pendulum_head
.Translate it to where the top pendulum head should be (recommended:
(0.0, 0.5, 0.0)
).
3.4.2. Create the body of the bottom pendulum#
Add another body into the scene.
Name it
pendulum_head_2
.Translate it to where the bottom pendulum head should be (recommended:
(0.0, 0.25, 0.0)
)
3.4.3. Join the two pendulums with a PinJoint#
Right-click the bottom pendulum (
pendulum_head_2
), clickJoin to
, followed by clicking the top pendulum to create a new joint between them.Name it
pendulum_head_2_to_pendulum_head
.Translate it to the location of the top pendulum (i.e. the pivot point, either type in
pendulum_head
âs translation, or useTranslate > to parent
, to move it).Change its joint type to
PinJoint
through the right-click menu.
3.4.4. Join the top pendulum to ground with a PinJoint#
Right-click the top pendulum (
pendulum_head
), clickJoin to
, followed by clicking ground to create a new joint between the top pendulum and ground.Name it
pendulum_head_to_ground
Translate it to the location of the âceilingâ in this model, recommended:
(0.0, 0.75, 0.0)
)Change its joint type to
PinJoint
through the right-click menu.
The above steps set up all the bodies + joints in the model. You should have something that looks like this:
3.4.5. Convert the scene to an osim (for testing)#
Next, you will temporarily convert the mesh importer scene into an OpenSim model (osim
) so that you can test whether your model is correct. Conversion is a one-way process, but your progress in the mesh importer will be not be lost.
To convert the mesh importer scene into an osim
(for testing), you will need to:
Convert your scene into an OpenSim model. Click the green
Convert to OpenSim Model
button. This will convert your scene to anosim
and open it in anosim
editor tab. You can then see how the free-form scene was converted into an OpenSim model.Try simulating the todel. Adjust the pin joint coordinates (
pendulum_head_to_ground_rz
andpendulum_head_2_to_pendulum_head_rz
) to start the pendulum off at an angle. Start simulating the model (Ctrl+R
) to see it swinging. Confirm that both bodies swing like a double pendulum. If they donât, close the simulation (and editor), then reopen the mesh importer tab and start fixing things đ§.Save the model as an .osim. After conversion, you can then save your model to disk and use external tooling (e.g. XML editors, OpenSim GUI) to further modify it.
3.5. Add Decorative Geometry#
Note
These next steps are performed in the mesh importer (converting to an osim was purely for testing). You can close the editor (& simulator) tabs and return to the mesh importer tab for these next steps.
Although the previous steps create a functionally complete model, the model doesnât look like a particularly convincing pendulum. These steps add decorative geometry to fix that.
The mesh importer has the ability to add meshes into the scene, freely move/rotate them, and attach them to bodies/ground. This is in contrast to Make a Pendulum and Make a Bouncing Block, where we had to manually place offset frames wherever we wanted decorations. Internally, the mesh importer is performing similar steps, but automates them.
To decorate the model, complete the following sub-steps:
3.5.1. Attach a cube mesh to ground (the ceiling)#
Right-click in an empty space in the scene, use the
Add Other > Meshes
menu to open the mesh file import popupIn the popup, browse to OpenSim Creatorâs install directory, which contains a
resources/geometry
subdirectorySelect
block.vtp
from that directory. This is a pre-made block mesh file.Rename the block mesh to
ceiling_decoration
Move the mesh to the location of the highest pin joint (
pendulum_head_to_ground
). The easiest way to do this is to right-click the mesh and useTranslate > To (select something)
.Rescale the mesh so that itâs displayed as a thin âceilingâ cuboid the pendulum hangs from, rather than a cube. To do this, use scale property in the meshâs context menu (right-click it) or the scaling gizmo (press
S
or change the manipulation dropdown at the top of the screen fromtranslate
toscale
). Recommended scale factors:(5.0, 0.1, 5.0)
.
3.5.2. Attach a cube mesh to the top pendulum#
Right-click the body of the top pendulum (
pendulum_head
) and use theAdd > Meshes
to open the mesh file import popupSelect the same (as above)
block.vtp
mesh fileRename it to
pendulum_head_decoration
Move (
G
), Rotate (R
), or Scale (S
) the mesh however you like (recommended: leave it as-is) by either using the in-UI draggable gizmos or typing values into the context menu.
3.5.3. Attach a cube mesh to the bottom pendulum#
As above, but right-click the bottom pendulum body (
pendulum_head_2
) and name itpendulum_head_2_decoration
.
3.5.4. Attach a cube mesh between the top pendulum and the ceiling (a strut)#
This step adds another
block.vtp
mesh into the scene. This one will act as a strut between the top pendulum and the ceiling.It will move whenever the pendulum moves, so it should also be attached to the highest pendulum body (
pendulum_head
).As in previous steps, you can attach it by right-clicking the pendulum body (
pendulum_head
) followed byAdd > Meshes
.However, the pendulum body might now be occluded by the cube you added in the previous step (
pendulum_head_decoration
). To work around this, you can either:Right-click
pendulum_head
in the navigator panel, which will show the same menu as right-clicking it in the 3D viewer.Temporarily make meshes invisible (in the
Visibility
menu).Temporarily exclude meshes from being clickable (in the
Interactivity
menu).Combine approaches by changing the color of the meshes to be semi-transparent (see
Colors
menu) and disable their interactivity.Initially import the mesh by attaching it to ground, move it into place,
Reassign Connection
to thependulum_head
body.The âbestâ approach depends on what kind of model you are working on.
Once the mesh is attached, move it between the
pendulum_head
andpendulum_head_to_ground
(right-click,Translate > Between Two Scene Elements
or set translation to(0.0, 0.625. 0.0)
.Rename it to
pendulum_head_strut_decoration
Rescale (
S
) it to make a long, thin, pendulum strut (recommended:(0.2, 2.5, 0.2
)).
3.5.5. Attach a cube mesh between the bottom and top pendulums#
As above, but this strut will track along with the bottom pendulum (
pendulum_head_2
), so make sure the mesh is attached to that. Name itpendulum_head_2_strut_decoration
.This mesh needs to be between the bottom pendulum and the top pendulum.
This should result in a fully-decorated pendulum model:
3.6. Export and Simulate#
Now that we have created a fully modelled and decorated pendulum, we can export it to an osim
and simulate it. To do that:
Convert the model to an osim. Click the green
Convert to OpenSim Model
button in the mesh importer.Tilt a pendulum head slightly. Use the
coordinates
panel to change one of the jointâs rotationalvalue
, so that the pendulum is tilted slightly.Request a pendulum headâs velocity is plotted. Right-click a pendulum head in the 3D viewer, go to
Watch Output > pendulum_head > linear velocity
and clickmagnitude
.Simulate the model. Press
Ctrl+R
(run simulation) to start running a forward-dynamic simulation. This should show the pendulum swinging.View outputs. Ensure the
Outputs
panel is showing (Window > Outputs
should be enabled). The requested output (magnitude oflinear velocity
) should show a basic data plot of a pendulum headâs linear velocity.
Et voilĂ , you have created a functioning OpenSim model by mostly using the free-form mesh importer and got some useful data out of it đ. Youâre getting good at this.
3.7. (Optional) Extra Exercises#
Now that you have played with both the mesh importer and osim
editor a little bit, here are some extra things you can explore:
Create more complex joint topologies: Try a triple pendulum, attach the pendulum to ground with a
SliderJoint
, rather than aPinJoint
and watch it slide around. Look up some basic mechanical devices on Google and see if you can roughly get them simulating by placing a few joints + bodies in the mesh importer, followed by adding a few springs and contact surfaces in theosim
editor (see Make a Bouncing Block).Try attaching more complex meshes: Swinging cubes are cool, but swinging skulls are even cooler đ. Instead of a cuboid strut, why not join the pendulum pieces together with a finger bone mesh. Think about how you can use these simple techniques to âleapâ from building simple mechanisms (pendulums) to more complex ones (human biomechanics).
3.8. Next Steps#
This tutorial mostly focused on using the mesh importer to accelerate the earliest parts of the model building process. The benefit of knowing this approach in addition to the approaches covered in Make a Pendulum and Make a Bouncing Block is that itâs easier to place/rotate bodies/joints in the mesh importer.
Now that weâve introduced OpenSim Creatorâs general toolset (specifically, the mesh importer, osim
editor, and simulator), we are going to start increasing the complexity of the models we work on. Make an Arm focuses on using the techniques weâve covered to build something more complex.