AnyLogic
Expand
Font size

Camera

Camera defines the part of the presentation that will be shown in 3D window. It “shoots” the picture that is “shown” in 3D animation window (analogous to a display on operator’s console).

If you want certain presentation shapes to be shown in 3D window on model startup, we recommend you to to define the onlooker’s location (and his eye direction) when using the camera, rather than to navigate to the required shapes on each model run.

You can define several cameras directed either at different parts of 3D scene, or at the same objects but from different points and easily switch between these cameras at runtime.

Camera may move at model runtime and 3D window can be set to follow its camera, showing the current picture shot by the camera. This feature is very useful if you have a moving object in your model and you want to constantly keep an eye on it.

Demo model: Multiple 3D Windows and Cameras Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

To add a camera

  1. Drag the  Camera element from the 3D section of the  Presentation palette into the graphical editor. You will see the camera icon in the graphical editor:

  2. Direct the camera at the presentation shapes that you want to see in the 3D window at model runtime (positioning is described below in details).
  3. Now you can set this camera as the camera shooting the picture for the 3D window. Select the 3D window and type the name of this camera in its Camera property. If you plan to move your camera at model runtime, and you want your 3D window to follow the camera and show the picture that currently gets into its focus, choose the Follow Camera option.

Properties

General

Name — The name of the camera. It is used to identify the camera and to access it from code.

Show name — If selected, the name of the camera will be displayed on the presentation diagram.

Ignore — If selected, the camera will be excluded from the model.

Paste coordinates from clipboard — Click the button to paste camera settings (X, Y, Rotation X and Rotation Z) from the clipboard.

Rotation X — The angle that camera’s direction composes with YZ plane (starting from inverted Y axis, clockwise, in degrees).

Rotation Z — The angle that camera’s direction composes with XY plane (starting from inverted Y axis, clockwise, in degrees).

Position

Level — Level to which this camera belongs.

X — The x-coordinate of the center of the camera.

Y — The y-coordinate of the center of the camera.

Z — The z-coordinate of the center of the camera.

Positioning the camera

When adding a camera onto diagram of your agent, you should direct your camera on those presentation shapes that you want to be “shot” by this camera.

To direct the camera at the required presentation shapes

  1. Direct the camera at the presentation shapes that you want to see in 3D window (we recommend you to place the camera at a certain distance from them, as it is shown in the figure below):
  2. Rotate the camera so that it is directed at the required shapes (to fit all of the shapes into the camera focus). Select the camera in the graphical editor. You will see a blue circle drawn around its icon and an arrow pointing from the icon’s center. This arrow shows the direction of the camera in the XY-plane.
  3. To rotate the camera in the plane XY (Rotation Z), pull the end of the arrow in a circle:
  4. Pay attention to the length of the arrow — it indicates the angle that the camera’s direction composes with YZ plane (Rotation X). The shorter the arrow is, the greater the angle is. If you cannot see the arrow it means that this camera is currently directed at the right angle to the XY-plane — towards us or in the backward direction. You can change this angle by dragging the end of the arrow closer to, or farther away from the center of the camera icon. But let’s leave this rotation angle unchanged, we will modify it on the next step.
  5. Run the model and adjust your camera precisely. You might need to zoom in (out of) the window contents, move it or rotate it — all these operations are described in details in Moving, rotating, and zooming 3D scene at runtime.
  6. When finished with positioning your camera, right-click (macOS: Ctrl + click) in the 3D window area and choose Copy camera's location from the context menu. This command will copy the current camera settings (location and rotation) to the clipboard.
  7. To apply the copied settings to your camera, select the camera in the graphical editor and click Paste coordinates from clipboard in its properties. The camera will be automatically moved and rotated according to new location settings.

Functions

Location
Function Description
double getX() Returns the X coordinate of the camera.
double getY() Returns the Y coordinate of the camera.
double getZ() Returns the Z coordinate of the camera.
void setX(double x) Sets x as the new X coordinate of the camera.
void setY(double y) Sets y as the new Y coordinate of the camera.
void setZ(double z) Sets z as the new Z coordinate of the camera.
void setPos(double x, double y, double z) Sets new coordinates for the camera.

x — the new value of x coordinate.
y — the new value of y coordinate.
z — the new value of z coordinate.
Rotation
Function Description
double getRotationX() Returns the rotation of the camera around X axis (CW, from Y to Z). Zero rotation value corresponds to horizontal orientation of the camera (parallel with XY-plane).
double getRotationZ() Returns the rotation of the camera in radians around Z axis (CW from X to Y).
void setRotationX(double rotationX) Sets the rotation of the camera around X axis (CW, from Y to Z). Zero rotation value corresponds to horizontal orientation of the camera (parallel with XY-plane).

rotationX — the new value of rotation around X axis (CW, from Y to Z), in radians.
void setRotationZ(double rotationZ) Sets the rotation of the camera in radians around Z axis (CW from X to Y).

rotationZ — the new value of rotation in radians around Z axis (CW from X to Y).
Level
Function Description
Level getLevel() Returns the level, where this camera is located.
Copying camera position to the clipboard
Function Description
String copyToClipboard() Copies camera settings to the system clipboard in the format supported by AnyLogic IDE.
To paste the camera settings in the AnyLogic, select the camera and click the Paste From Clipboard button in the General section of its properties.
How can we improve this article?