AnyBody™ Tutorials
Lesson 3: The Model View Window

The Model View window is the system's graphical representation of the model. You can open a Model View window by the Window->Model View (new) command.

TheModel View displays a special type of model elements that we usually call "Draw Objects". These are the objects you can attach to the segments, muscles, nodes, surfaces and such on the model. Most classes in AnyScript that are related to mechanics in any way have corresponding draw classes, and the library of draw classes is constantly being extended and improved.

In older versions of AnyBody, draw objects were the only objects being displayed in Model View; there was a complete separation between mechanical objects being used in the simulations and draw objects being shown in Model View. However, this has changed in newer versions (from about version 4.1.x) where many objects were equipped with so-called auto-generated draw objects (or default draw objects). These draw objects are virtual, i.e., they do not appear in the Model Tree, but they are (or can be) visible in Model View. Therefore auto-generated draw objects cannot be modified to the same extent as model-defined draw objects, because there are no accessible settings. It should be noticed that many models, even in the AMMR repository is still using model-defined draw objects extensively, for no other than historic reason, but model-defined draw objects are still useful for taking control on what appears in the view.

This lesson looks into the functionality of the Model View, and even though you can probably use it intuitively, you may also pick up a useful trick or two you did not know about. The lesson is divided into the following two sections:

Introduction to the Model View

Working with the Model View contents

In the former, we shall look at the Model View window itself and its functions and in the latter we shall look briefly at the options for modifying the contents of Model View.

Introduction to Model View

When active, the Model View updates the model as the computation proceeds. The update can involve the elements moving on the screen or colors or shapes changing to reflect the state of the model such as, for instance, muscle forces.

If the model is not too big and the computer is not too slow, the computation runs fast enough to create a dynamic animation in real time or close to that. However, for many larger models, the computation is too slow to give you a dynamic impression of the model's movement. The model view then provides the opportunity to save the individual frames for subsequent processing into a video animation that you can play at any speed you like. Many study classes, such as all mechanical studies, is also equipped with a Replay operation. This operation plays back the data from the output data structure, where it was stored during the simulation, to the real objects of the model and Model View will then display the given state of the model again. This is significantly faster than the simulation for large models.

As usual, we need a model to work on. For this tutorial you can pick any model you may have, or you can download the familiar dumbbell example here: demo.arm2d.any . You will also need the accompanying STL file: dumbbell.stl .

Load the model into the AnyBody Modeling System and click Window -> Model View (new). You should get a window looking like this:

  • The model is centered in the window, and you should be able to see all its elements. When you open a new Model View, the window automatically applies a Zoom All function that shrinks the view until all elements are visible.
  • The model is not necessarily assembled correctly. All the segments at load time are positioned where they are defined in the AnyScript model. These positions rarely comply with the kinematical constraints such as joints. In fact, you might want to assemble the model above correctly by selecting and running the SetInitialConditions operation in the ArmStudy at the lower left corner of the screen.

This resolves the kinematical constraints and puts the model into the position defined by its drivers at time step 0. It produces the picture shown below.

Notice that we are looking at the model directly from the side. The default viewing direction is the xy plane. This coincides well with the International Society of Biomechanics standard of letting the saggital plane coincide with the global xy plane.

The Toolbar

The Model View has its own toolbar with following button functions:

  • On/Off: This button switches automatic update of the window on and off. When switched off, the window does not update when the model is moving, and it is not possible to rotate, scale and pan the view. The advantage of switching the update off is that it makes the analysis run faster, especially on computers without a separate graphics processor.
  • Properties : Button that opens the properties window (equivalent to menu item Windows -> GUI Properties). In the properties, you have options for setting properties more specifically. We shall not go into details about these options here, see below.
  • Pan tool: Selecting this tool causes the cursor to change shape to a hand. When you drag the mouse over the screen with the left button down, the picture moves with it.
  • Zoom tool: When this tool is active, the cursor resembles a small magnifying glass. When you drag the mouse over the picture with the left button down, it zooms in or out for upward or downward movements respectively.
  • Spin tool: This tool allows you to spin the model dynamically on the screen by dragging the mouse with the left button down. The function is very intuitive and you will soon get the hang of it. It works like the model is attached to an imaginative sphere centered on the screen. When you hold down the left mouse button, you are grabbing the surface of the sphere and spinning it with the movement of the mouse.
  • Default views: These three buttons represent predefined viewing directions: the xy plane (standard), the yz plane, and the xz plane respectively.
  • Zoom all: This button refits the view to contain all the drawing elements.
  • Record: This button starts video frame capturing explained in more detail below.
  • Frame count: This panel displaying the number of captured frames during a recording.
  • Stop recording: This button stops a video frame capturing session. The function is explained in detail below.

Model View Properties

The Model View properties accessible to the user contain three groups:

  1. View point settings that are also set by the typical interaction with Model View through Pan, Zoom and Spin operations. These settings in the Properties can be set directly or they can be grabbed for use in a camera implemented into your model. The view point definition in the properties of Model View is using the AnyScript class AnyCameraModelView. This is done to enable easy exchange of view point properties between model and Model View. The individual properties are introduced in the AnyScript Reference Manual.
  2. Viewer properties that control viewer behavior.
  3. Scene properties that control general scene properties, such as background color, that are not given in the model definition.

Recording video

You may want to save a video file of your simulation for a presentation or simply to be able to show a large model running in real time. The model view provides the opportunity to save the individual graphics frames for subsequent processing into a video animation that you can play at any speed you like.

The function works much like a video tape recorder in the sense that you can push the red record button any time you like, and what happens in the window is subsequently saved for further processing. Let's see how it works. Try clicking the record button. A file manager will pop up and request you to select a location and a naming of the files you make. The name you select will be appended with _nnn where nnn if the frame number of each image. You can also select the image file type, and jpeg is usually a good choice to limit the size of the images on the disk.

You will notice that the frame counter lights up, the "Rec" letters flashes, the record button becomes inactive indicating that you cannot push it twice, and the stop button becomes active indicating that you can push it.

Everything that takes place in the window will now be recorded. Try spinning the model around a little with the mouse and notice how the frame counter adds up. Notice that the system is intelligent enough to not record anything when nothing is happening. This means that you are in no hurry when you have pushed the Record button. The system only grabs frames when the picture actually changes. This happens either when you manipulate the picture manually as you did here, or when an analysis is running and producing new pictures as it proceeds. If you record an analysis with 100 time steps, then you will get 100 frames saved.

When you have 50-100 frames, push the "Stop recording" button. The system will ask you whether you really want to save the frames. If you answer no, they will be erased. If you save the frames you will be left with a bunch of image files like this:

The AnyBody Modeling System does not provide a video editing facility to process these files into an AVI, MPEG or similar video file format. However, many really good and cheap utilities are available for this purpose. We at AnyBody Technology use a very good and inexpensive tool called VideoMach available from www.Gromada.com .

Size matters

Regardless of how videos are processed, they are rather data intensive, and it is a really good idea to plan the recording well. Depending a little on the image format, the size of the frames you are saving is proportional to the area of the Model View. This means that it is more rational (and usually gives a better result) to resize the shape of the Model View to the animation you want in the end, than it is to change the size or crop the video afterwards.

Working with the Model View contents

We have already mentioned that Model View shows draw objects in the model and that there are two types of this kind of objects

Auto-generated draw objects

Model-defined draw objects

Basically, you can say the auto-generated draw objects serve to provide a picture of the model while building and working with it on a fundamental level, whereas model-defined draw objects serve to make the best possible views that suit your particular purposes of communication.

All draw objects can be appear in the following states:

Visible or invisible

Transparent

Selected

These states you can control while the model is loaded, either directly from Model View or from the Model Tree. We shall return to this in a moment.

By default draw objects may be either visible or invisible. This implies that you will normally not see all draw objects, since it would make the Model View too congested and messy to be useful. In the system, there is a definition on what to make appear by default. This is still a young feature, so it may change in the coming versions, but some basic lines are that

Model-defined objects overrule auto-generated objects (i.e. make then invisible, but they are still there)

The more important auto-generated draw objects, such as segments, will be visible by default when no model-defined drawing objects are defined for the corresponding mechanical object, whereas others serve more to provide further details of the model, such as kinematic measures, and are therefore invisible by default.

Model View State Actions

Let us take a look at how you can interact with the Model View states of the draw objects. Right-clicking the Model View will bring up its context menu and from here you can apply Model View state actions on the objects. If you hit an object during the right-click command, you get the context menu related to this object.

From here you can show, hide, make transparent, etc. Reset means to bring the object back to its original state (loading time), which can be both visible and invisible depending on the object.

The lower part of the menu shows you part of the Model Tree (as menu items), i.e. the entire tree related to the draw object you have hit. This provides you with the possibility to interact with an object higher in the Model Tree; for instance you may want to interact with the segment you are looking at, even though you have actually hit the draw object of the segment. In another situation, you may actually want to interact with the draw object, if you are not studying the mechanics of the model but the view of it.

You can unfold one deeper level of the context menu for any model item in the lower part of the menu. This action will reveal the same menu for any object:

From here you can interact with the object in many ways, either the object itself (This object) alone or if it is a folder containing other draw-able objects, with these as well. Folder contents can be interacted with either 1 folder level down or all levels down the folder tree, or you can do with certain practical class filters such as segments, muscles, etc. The predefined filtered interaction options always affect all objects of the selected type in the folder tree from the selected starting point and down. No matter which selection you make at this menu level, you have the same options for invoking Model View state actions to the objects. The image below shows these options in the final level of the context menu.

If you right-click the background, you will only find Main, i.e. the root folder of the model. On this you have the same options as on other folders in the model tree. This can be powerful for cleaning up your view before making specific setting or for making sure that you see all objects of a certain type, e.g. all segments or all muscles.

Selections in the Model View

Graphical objects in the Model View can be selected by single-clicking them with the left mouse button. Doing so will visually mark the object as selected by turning it into a reddish-pink color. Multiple objects can be selected by left-clicking the objects sequentially. Left-clicking a selected object again will remove it from the current selection. The currently selected objects can be deselected by either left-clicking somewhere on the background, or by using the Deselect all option in the right-click context menu.

When right-clicking a selected object, the resulting context menu will give a number of state actions for the selection instead of the normal right-click context menu. These state actions will apply to the entire Model View selection and not only the right-clicked object.

Model View State Actions from the Model Tree

The context menu options for setting Model View state action for draw objects is also available from the Model Tree. The context menu in the Model Tree has a Model View item, which holds exactly the same sub-menu we looked at above, please see the image below.

This provides another intuitive tool manipulating the contents of Model View.

Draw groups

We should now mention a special class for assisting you in applying the state actions you want on the model. It is the draw group with class name AnyDrawGroup. A draw-group object can refer (with object-pointers) to a set of objects in the model. When you perform any of the Model View actions explain above on a draw-group, the group object will transfer the action to all objects it refers to.

The object-pointers in the draw group can be established in the model using search functions of your choice, so it provides a powerful tool for preparing your model for special Model View state actions. Please refer to the class AnyDrawGroup for more details and in Lesson 8 , you can find an example of their usage.

The next lesson deals with the two different Chart Views for investigating analysis results.

AnyBody Technology A/S · Niels Jernes vej 10 · DK-9220 Aalborg Ø · Denmark · Tel. +45 9635 4286 · Fax. +45 9635 4599            Sitemap