Watch the video tutorial on using meshes

If you want to create professional looking simulations then you will need to learn how to use meshes. Luckily, using meshes in version 2 is much, much simpler than in version 1 of AnimatLab. Version 2 supports almost all the major 3D file types, so you should be able to just download the mesh from somewhere on the internet, or create your own, and then import it directly into AnimatLab to use. Version 2 (V2) also gives you a lot more flexibility in how you use the meshes. Typically, you will want to only use meshes for the graphics system so the simulation looks nice, but still uses basic geometric shapes for the actual physics engine. The reason for this is that meshes are much more expensive to simulate in the physics engine than using the basic shapes of box, cylinder, and sphere. Notice that I left out cone, toroid, and ellipsoid from that list. This is because internally they are actually created as very simple meshes. AnimatLab actually creates the mesh geometry for them on the fly and uses that for the parts. So they are going to be much faster than a complex mesh off the web with thousands of polygons, but they will still be a good bit slower than the three basic geometric shapes that are supported. The good thing is that V2 now gives you the ability to build a complex rigid body by gluing together several of these basic shapes using the static joint, and then allowing the user to only see the graphics mesh during the simulation. This is considerably faster than just using the mesh for the collisions.

However, if you really need mesh collisions you can still do that as well. As in V1 you can have a convex collision mesh where your mesh is not allowed to have indentations, or concave portions. You can also have a triangle mesh that attempts to use the mesh exactly as it is for the collisions. The convex mesh will be faster than the triangle mesh because it allows the system to make some simplifying assumptions in the collision detection. Also, the convex mesh is typically optimized and has many fewer polygons to deal with during the simulation. Using a convex mesh is actually very simple, and does not require any extra work on your part. You simply point the application to the regular mesh you downloaded off the internet, or created, and it will automatically run it through an optimizer that will remove any concavities and minimize the number of polygons and then save it out as a separate mesh file to use during the simulation.

How to get meshes

So one of the first problems you will need to think about if you want to uses meshes in your simulation is how do you actually get them? Creating meshes by hand has always been a very difficult, and time consuming process. Even trying to download meshes created by others and use them in something like AnimatLab was often very difficult because the mesh of an organism like a crayfish or cat would often need to be broken out into specific limb components and then used separately for each rigid body part. This required you to use some of the 3-D authoring tools like 3DS Max, or the popular and free Blender tool. However, using these tools is not at all easy and they have a very steep learning curve to get to the point where you can really use them successfully. This all changed with the introduction of Google's free Sketchup application. Google wanted to make a 3-D authoring tool that could be used by anyone to make really nice 3-D models. Their goal was to make the system so intuitive and easy to use that anyone could be up and creating/modifying meshes in no-time flat, and they succeeded in that. After watching just a few of the free tutorials on youtube I was creating my own meshes. (Just google Sketchup on I personally prefer the tutorials for the Sketchup For Dummies book.) The intuitive interface also makes it very easy to chop up a mesh into parts so you can use them individually, especially if the mesh was created with different mesh components in the first place. If you get lucky and that is the case with your mesh then it really just a matter of selecting the parts of it that you want and saving them out into a separate mesh file. 

Another really cool thing about Sketchup is the free 3-D warehouse that has thousands of meshes built by people all over the world that you can just download and uses for free. Almost all of the 3-D models that I have used have come from Google's 3-D warehouse. This makes it really easy to try and find some meshes that you can use for your simulation. However, one problem with the free version of Sketchup is that it only allows you to export Collada files, and this is not one of the file types that are natively supported in OpenSceneGraph (OSG) that is used by AnimatLab. Luckily, there is a free SketchupToOSG plug-in that will convert any of your files into the standard OSG format so you can use them in AnimatLab simulations. To use this plug-in you will need to download it and install it, but once you do you will be able to export any of the meshes in the 3-D warehouse directly into a format that can be loaded into Animatlab.

While Google's 3-D warehouse is great for finding meshes, it sometimes does not have items with enough quality for the work that needs to be done. So you may have to break down and buy a mesh if you want something that looks really good. There are a number of sites were you can do this. Here are a few of my favorite sites for finding free meshes, or meshes for purchase:,,, You will need to search through these to find something that will meet your needs, and if you want high quality you will probably end up having to pay for it. Also, once you get your mesh you will still almost certainly have to use Sketchup to break the mesh they give you up into component parts to use in AnimatLab.

Adding meshes to your simulation

We will start by showing how to add a simple graphics mesh to your part since this should be the most common way to use meshes. First, add one of the standard geometric shapes as a collision part. Be sure to click off the "Add Default Graphics" checkbox because we will be adding a graphic later. When you close that dialog you will see a new one that asks you to specify the location of the mesh. Once you have the new body part you should go to the transparency section and set it up so it is 100% transparent in simulation mode, and then size and position the part how you want it. Now add child part. When you get the Add Body Part dialog choose mesh and click on the option for "Graphics Object". This will add a new graphics mesh that is tied to the basic collision geometry shape that you previously added. You can then scale the mesh using its Scale properties to get it to the size that you need and move it so that it is position correctly relative to the parent part. Now when you run the simulation you will see the mesh, but the collisions and dynamics will be determined by the much simpler geometric part underneath it. If you would like to see the collision object while in the simulation mode then you simply need to change the transparencies for that part.

Figure 1. Add Graphics Mesh Dialog

You can follow these same steps, but add additional collision objects to the parent part using a static joint to build complex dynamic shapes to match your mesh. In V1 the static part was not really static. It was actually a relative position-relative orientation joint that tried to keep the part at the same position and orientation to the parent part. This added computations to the simulation and also meant that the joint could not always handle the forces applied to it so it would deform. In V2 this is no longer a problem with the static joint. It truly makes the connected parts as if they are one piece instead of having a joint between them. This means they will not deform no matter what forces are applied, and it eliminates the extra joint calculations. If you have complex mesh structure you simulation will be significantly faster if you use the mesh solely for graphics and use a combination of simple geometric parts combined together using static joints to model the collisions instead of using complex collision meshes.

Sometimes you will need something more than just a collection of basic shapes for the realism of your simulation. In that case you will need to make the decision to trade off simulation speed for more realism. You can use collision meshes in that instance. Collision meshes are added just like you do any other body part. Select Mesh in the body parts dialog. If necessary you will then be asked for a joint type. However, after that you will get a new dialog box that allows you to fill in the details of the mesh. You can specify whether you want a convex collision mesh or a triangle mesh. You can also specify the location of the mesh file. If you clicked the "Add default graphics" checkbox then after you hit ok you will be asked to specify the location for the graphics mesh attached to this collision object.

Figure 2. Configure Graphics Mesh Dialog

Figure 3. Convex collision mesh with a graphics mesh

Figure 3 above shows a convex collision mesh that is created for the graphics mesh of a locust thorax. As you can see it removes all of the concave sections between the antenna and creates an optimized, convex mesh. However, in a case like this that may not be what you actually want. Here for example, if you were to use this convex mesh this will lead to an incorrect redistribution of the mass that is far forward of where it is in the real animal. This leaves you with two options. First you can split the graphics mesh up to remove the antenna and add them in separately, and just create a convex mesh with the remaining part. Second, you can choose to use a triangle mesh instead. For speed purposes the first choice should be the correct one since a convex mesh will be much faster than a triangle mesh. If you are going to use a triangle mesh though, then you would add one the same way we did previously, but choose triangle mesh instead of convex. A triangle mesh with a graphics mesh are shown in figure 4 below.

Figure 4. Triangle collision mesh with a graphics mesh

This covers the basics of adding and using meshes within AnimatLab. Please post any questions you have onto the forum.