Font size

Phase 3. Creating 3D animation

You’ve now seen many of the features that help make AnyLogic such a powerful modeling tool. But there are others you haven’t touched, and one of the most exciting is 3D animation.

Introducing Camera objects

 Camera objects of AnyLogic allow you to define the view that displays in the  3D Window. In essence, the camera object “shoots” the picture that you see.

You can also create several camera objects to show different areas of the same 3D scene or to show a single object from different points of view. If you use more than one camera object, you can easily switch from one view to another at runtime.

  1. On the   Presentation palette palette, drag the   Camera object on to the   Main diagram so it faces the job shop layout.
  2. Drag the   3D Window element on to the Main diagram, and then place it below the process flowchart.

    3D Window

    In addition to having the option to add several cameras to your model, you can also add several 3D windows that will each display the same 3D scene from a different point of view.

  3. Let the camera “shoot” the picture for the   3D Window. In the   3D Window   Properties view, click camera in the Camera list.
  4. Prevent the camera from shooting the picture from under the floor by selecting the option Limited to Z above 0 from the Navigation type list.

  5. Run the model.
    When you create a 3D window, AnyLogic adds a  View Area that allows you to easily navigate to the 3D view at runtime. To switch to this 3D view while the model is running, open the developer panel by clicking the   Debug button control in the right corner of the control panel. In the developer panel, expand the  select view area to navigate list and select [window3d] from the list.

  6. The view area expands the 3D animation scene to the model window’s full size.
    Do one or more of the following to navigate in 3D at runtime:
    • To move the camera left, right, forward or backward, drag the mouse in the selected direction.
    • To move the camera closer to or further from the scene’s center, rotate the mouse’s wheel.
    • To rotate the scene relative to the camera, drag the mouse while you press and hold Alt (Mac OS X: Option key) and the left mouse button.
  7. Choose the view you want to display at runtime, right-click (Mac OS X: Ctrl + click) inside the 3D scene, and then click Copy the camera’s location.

  8. Close the model’s window.
  9. On the camera’s   Properties view, apply the camera location you selected during the previous step by clicking Paste coordinates from clipboard.

    If you can’t locate the camera, you can use the   Projects view. It will display camera under the   Main agent’s Presentation branch.
  10. Run the model to view the 3D view from the new camera position, and then close the model window.
  11. Expand the Pedestrian area on the   Space Markup palette and then double-click the  Wall element’s icon to enable wall drawing mode.

  12. Do the following to draw walls around the job shop layout’s working area:
    • Click the position in the graphical editor where you want to start drawing the wall.
    • Move the pointer in any direction to draw a straight line, and then click at any point where you want to change direction.
    • Double-click at the point where you want to stop drawing the wall.

  13. Do the following to change the wall’s fill color and texture:
    • In the   Properties view of the wall, expand the Appearance section.
    • In the color menu, click Other colors.
    • In the Colors dialog, select the color that you want to apply to the wall from the palette or the spectrum.
      You can also set a transparency level (use Transparency slider in the Colors dialog) or customize the wall with any provided texture (click the Textures… item in the colors menu).
    In this section, we’re using walls to decorate our model. In the pedestrian “Airport” tutorial you’ll see how walls can also be obstacles.
  14. Go to the wall’s Position and size section and change the Z-Height to 40.
    AnyLogic automatically sets the shape’s height to 20 pixels to ensure it has volume in a 3D view, but we’ve now increased its height to 40 pixels.
  15. Draw another wall between the exits and then change the settings in the second wall’s   Properties view to match the first wall.

  16. Run the model and view the 3D animation.
    You’ll see that our model’s animation uses cylinder shapes to represent pallets, but we’ll correct the problem by creating an agent type that defines a custom animation for pallets.
  17. In the sourcePallets block’s   Properties view, under the New agent list, click create a custom type.

  18. In the New agent wizard, do the following:
    • In the Agent type name field, type Pallet.
    • Click Next.

    • On the next page of the wizard, expand the Warehouses and Container Terminals section in the list on the left, and then click the 3D animation figure Pallet.
    • Click Finish.

    AnyLogic creates the Pallet agent type and opens the Pallet diagram that will display the animation that we selected in the wizard. Our next step will be to add product animation on top of the pallet animation, but we’ll first enlarge the view to give us a closer look at the pallet.

  19. Using the Zoom toolbar, enlarge the Pallet diagram to 500%, and then move the canvas to the right and down to view the axis’ origin point and pallet animation shape.

    Enlarging or reducing the view

    AnyLogic’s Zoom toolbar lets you enlarge or reduce the view of a graphical diagram:

  20. Do the following to start adding product animation on top of the pallet animation.
    • On the   3D Objects palette, expand the Boxes area.
    • Drag the Box 1 Closed object on to the pallet’s upper-left corner.

  21. Since this box appears to be too large when compared to the pallet, let’s change the box’s Scale to 75%.

  22. In the box’s   Properties view, expand the Position section, and then change the box’s Z coordinate to 2.
    Our change reflects the fact that we want to place boxes on the pallets and each pallet’s height is about 2 pixels.
  23. Add three boxes by copying the first box three times. To copy the box, select it and then press and hold Ctrl as you drag the box.
    Our pallet now has four closed boxes, and you can now change the zoom level back to 100% by clicking the toolbar’s Zoom to 100%  button.

  24. Return to the   Main diagram.
    If you open the sourcePallets block’s   Properties view, you’ll see Pallet is selected as New agent. This block will generate agents of the Pallet type.
  25. Run the model.
    You’ll see pallet shapes have replaced the multicolored cylinders. However, if you zoom in the 3D scene, you’ll notice that the forklift trucks aren’t transporting pallets. We’ll correct this problem by moving our model’s pallet animation in a way that allows the forklift trucks to pick up the pallets.

  26. In the   Projects view, double-click the ForkliftTruck agent type to open its diagram and then move the forkliftWithWorker figure one cell to the right.
    The animation shape is now in the correct location and our model’s pallets are aligned with the forklift trucks’ forks.

  27. Open   Main diagram, and in the pallet rack’s   Properties view, in the Number of levels box, type 2.
    Remember that your first click will select the network and your second click will select the network element.
  28. In the storeRawMaterial flowchart block’s   Properties view, set the Elevation time per level parameter to 30 seconds.
  29. In the pickRawMaterial block’s   Properties view, set the Drop time per level parameter to 30 seconds.
  30. Run the model and you’ll see a pallet rack with two levels.

How can we improve this article?