< Back to News & Blog

Dymola tips and tricks series (II)

Johan Andreasson March 25, 2015

The animation view in Dymola displays models that have some kind of 3D representation. This is quite useful for debugging or when you want to visualize your results. In this post I will show how you can get the most out of the animation view.

Part II: Mastering the Dymola animation view

First, let’s run a simulation with the default settings. In this post I have used a vehicle that by default will be seen from above.

1. Positioning the camera

There are two ways to visualize the vehicle from another angle. One you will find by looking in the menus for “3D view control”. It pops up a dialog box that lets you manipulate the view using sliders.

This may be useful the first time you use the animation window, but it can quickly get frustrating. Instead, use these short commands:

  • Tilt (rotate around horizontal/X-axis): Press CTRL and use arrow up/down, or press CRTL and the left mouse button while sliding the mouse up or down.
  • Pan (rotate around vertical/Y-axis): Press CTRL and use arrow left/right or press CRTL and the left mouse button while sliding the mouse left or right.
  • Roll (rotate around out-of-plane/Z-axis): Press SHIFT CTRL and use the arrow keys or press SHIFT CRTL and the left mouse button while sliding the mouse.
  • Zoom: Press SHIFT and use arrow up/down, press SHIFT and the left mouse button and slide the mouse up/down, or use the mouse wheel

Notice how the cursor changes shape when you press SHIFT (magnifying glass), CTRL (arc arrow around in-plane axes) or SHIFT CTRL (arc arrow around out-of-plane axis).

In the Vehicle Dynamics Library (VDL) there are predefined angles to speed up the workflow even more (more about that later).

We have now reached a nice angle for viewing the vehicle, but the vehicle appearance still needs improvement.

2. Modifying object properties

Before we look into how to make the animation nicer, I want to point out some features that can be accessed using the mouse. Select the body of the car (you can select any component that you have in your model) and right-click. You will then get the pop-up menu as in the next figure.

In this case we have a body covering the contents of the vehicle that you might want to make transparent. The option Transparent will give the body 50% transparency. If you want another value, use Set Transparency.

The option Follow makes the animation view follow the selected body. Set Rotation Center allows you to define around what point the body should rotate in the animation view, both when you are changing the view angle and when the body is moving in the simulation playback.

3. Shaping up the look #1: anti-aliasing

Now it is time to shape up the look. First enable anti-aliasing. Under Animation | Setup select Anti-alias and see how the appearance is improved.

4. Shaping up the look #2: Perspective view

Now check the Perspective view box in the Animation Setup dialog and you’ll see how the perspective adds a more distinct 3D feeling. But, when you zoom in, the perspective turns into a fish-eye.

This is because Dymola by default changes the focal length of the camera as you approach the object. As a result there is too much distortion. To avoid this, zoom back out and then press CTRL-1. Now we see that Dymola has three “zoom-modes”:

  • CTRL-0: Move closer and change focal length (default)
  • CTRL-1: Magnify
  • CTRL-2: Move the cut planes

The cut planes define a corridor where components should be visible, and everything outside this corridor is not rendered. So pressing CTRL-2 and then using SHIFT and arrow keys allow you to do this:

5. Reusing your favorite settings

Once you have found good settings for your model, you probably want to reuse them. One way is to select File | Generate script…, which allows you to save the settings in a script.

I prefer to have my settings together with my models and I want to be able to have modifiable inputs to the settings, so I make functions instead. You can easily access the definition of the current animation window by typing animationSetup() in the command window:

Now simply copy and paste the output in the algorithm section of a function or cherry-pick what settings you want to define in your function. Say for example you want to have a function that only changes position and focal length of the camera. In that case, copy the animationView call. This is what we have done for the default views in VDL. Here is the function that was executed by the Display isometric view above.

As you can see, there are also inputs that allow you to modify the settings. These allow you to reuse the same function, regardless of the size of the vehicle.

6. Shaping up the look #3: Rendering of primitive objects

Let’s zoom in on a tire. As you can see, the tire looks a bit jagged.

This is because Dymola renders the cylinder using segments. So to make a cylinder smoother (or any other graphical primitive for that matter) you need to call the animationSubdivision function.

From the output above you can see that by default this is set to:
animationSubdivisions(subdivision = {16, 8, 16, 1, 1, 64, 1, 1, 12, 12, 6, 12, 1});

If we change the third input from 16 to 64: animationSubdivisions(subdivision = {16, 8, 64, 1, 1, 64, 1, 1, 12, 12, 6, 12, 1})we’ll get a much smoother look for all cylinders.

7. Explore!

I have explained the keys to mastering the Dymola animation view, but there are other features to explore. If you are curious, I suggest you look at the experiment with the output from animationSetup().

You may want to check out trace object, vectors and history frames found. These are accessible either through animationSetup() or through Animation | Setup, and they render output like this:

Contact Us

Request Information

  • *Field required