AnyLogic
Expand
Font size

3D Window

3D window plays the role of a placeholder for 3D animation. It defines the area on the presentation diagram where 3D animation will be shown at runtime. If you want 3D animation to be displayed for your agent, you must add 3D window onto its diagram.

There can be several 3D windows on one diagram, each one displaying a particular part of the common 3D scene (analogous to several displays on operator’s console showing different views shot by different cameras).

You can configure your 3D window to display a certain part of the 3D scene by default by choosing a camera that will shoot the window’s content. Just direct your camera in the graphical editor at the shapes that you want to see in 3D window on model startup. This option is exceptionally useful since it is easier to position a camera once rather than navigating to the required part of 3D scene every time a model is launched.

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 3D window onto the diagram of an agent

  1. Drag the  3D Window element from the 3D section of the  Presentation palette to the graphical editor.
  2. Grey area will appear in the graphical editor.
  3. Navigate to the Properties view.
  4. If you want a particular part of the presentation to appear in this 3D window on model startup, set up a camera that will “shoot” picture to be displayed in this 3D window. To enable this, first add camera onto the diagram as described in Camera, then type the name of this camera in the Camera field.
  5. 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 option Follow Camera.
  6. Navigate to the Scene section of the window’s properties. Here you can change the background color of the 3D animation scene (using the Background color control), as well as turn on the grid for 3D window (and optionally change its color). The grid is usually turned on to indicate the Z=0 plane at model runtime. By default the grid is turned off (No color is chosen in the Grid color control).
    Changing grid and background color settings affects not only this particular 3D window, but all 3D windows of this agent type, since all of them share common 3D animation scene.

Properties

General

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

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

Camera — Here you can select a camera that will "shoot" pictures for this window, i.e. you define, the part of the presentation that will get into this window.

Follow camera — [Disabled if Camera is Not specified] Here you can choose whether this window should follow the camera while it is moving at the model runtime. If the option is selected, the window will always show the picture that is getting into the moving focus of the camera.

Navigation type — Here you can choose the navigation type that defines the freedom level of camera manipulation via mouse.

  • Full — Navigation is fully allowed. This navigation type works only when the window does not follow a camera.
  • Limited to Z above 0 — Navigation is only allowed above Z=0 plane. This navigation type works only when the window does not follow a camera.
  • Rotation only — The navigation mode in which the user is able to rotate the window only. It can be used when the window follows a camera.
  • None — Navigation is prohibited. It is the default navigation type. The window follows a camera.
Scene

Properties on the Scene page are applied to the whole 3D animation scene (and not to this particular 3D window only) that is common for all 3D windows of this agent. Therefore, if you set the grid to be shown for a 3D window, turn the grid on for all other 3D windows of the same agent type.

Grid color — Grid color of the 3D animation scene. The grid is turned off by default (No color is chosen).

Background color — Background color of the 3D animation scene.

Position and size

X — The x-coordinate of the window’s upper left corner.

Y — The y-coordinate of the window’s upper left corner.

Width — The width of the window (in pixels).

Height — The height of the window (in pixels).

Advanced

Create view area at runtime — If selected, a view area containing this 3D window will be automatically created to enable easy navigation to/from this 3D window at model runtime. This view area will not be visible at design time, you will be able only to navigate to it using common navigation tools. The view area will have the name of the corresponding 3D window defined as its title.

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

Far clipping distance — The distance (in pixels) that regulates the visibility depth of the 3D animation scene (i.e., the distance from the camera at which the scene can be seen). The part of the 3D scene that is located beyond the far clipping distance will not be visible. Refer to the Far clipping distance section for details.

At model runtime, you can navigate through 3D animation scene displayed in the 3D window using the commands that are described in Moving, rotating, and zooming 3D scene at runtime. AnyLogic supports several navigation modes providing various freedom levels of camera manipulation when using the mouse:

  • Full — Navigation is fully allowed. This navigation type works only when the window does not follow a camera.
  • Limited to Z above 0 — Navigation is only allowed above Z=0 plane. This navigation type works only when the window does not follow a camera.
  • Rotation only — Navigation mode in which a user is able to rotate the window only. It can be used when the window follows a camera.
  • None — Navigation is prohibited. It is the default navigation type. The window follows a camera.

Functions

Position
Function Description
double getX() Returns the X coordinate of the shape (namely, the X coordinate of its upper left corner).
double getY() Returns the Y coordinate of the shape (namely, the Y coordinate of its upper left corner).
void setX(double x) Sets the X coordinate of the shape.

x — the new value of X coordinate.
void setY(double y) Sets the Y coordinate of the shape.

y — the new value of Y coordinate.
void setPos(double x, double y) Sets new coordinates for the shape.

x — the new value of x coordinate.
y — the new value of y coordinate.
void setPos(Point p) Sets new coordinates for the shape.

p — the Point object containing coordinates.
Size
Function Description
double getWidth() Returns the width of the shape.
double getHeight() Returns the height of the shape.
void setWidth(double width) Sets the width of the shape equal to width.
void setHeight(double height) Sets the height of the shape equal to height.
double getScaleX()
double getScaleY()
Returns the scale of the shape along X (Y) axis.
void setScaleX(double sx)
void setScaleY(double sy)
Sets the scale of the shape along X (Y) axis.

sx — the new value of scale along X axis. *
sy — the new value of scale along Y axis. *
void setScale(double sx, double sy) Sets the scales of the shape along both axes.

sx — the new value of scale along X axis. *
sy — the new value of scale along Y axis. *
void setScale(double s) Sets the same scale of the shape along both axes.
s — the new value of scale along both axis. *
* Set to 1 to keep the original size.
Camera
Function Description
void setCamera(Camera3D camera) Sets the 3D window to the given camera and optionally starts following it.

camera — the camera for the 3D window.
void setCamera(Camera3D camera, boolean follow) Sets the 3D window to the given camera and optionally starts following it.

camera — the camera for the 3D window.
follow — if true this 3D window will track camera movements. “Follow” mode supports only 2 navigation modes: NAVIGATION_NONE and NAVIGATION_ROTATION_ONLY. If navigation mode is not supported, it will be set to NAVIGATION_NONE.
void setCamera(Camera3D camera, boolean follow, long transitionTimeout) Sets the 3D window to the given camera and optionally starts following it.

camera — the camera for the 3D window.
follow — if true this 3D window will track camera movements. “Follow” mode supports only 2 navigation modes: NAVIGATION_NONE and NAVIGATION_ROTATION_ONLY. If navigation mode is not supported, it will be set to NAVIGATION_NONE.
transitionTimeout — if non-zero, then the current camera position and orientation will evolve to the given camera during the given timeout of real milliseconds (not model time units).
Navigation mode
Function Description
void setNavigationMode(Navigation3DType mode) Sets the navigation mode (the freedom level of camera manipulation using mouse). If the 3D window is linked with a camera and navigation mode is not supported, the latter will be set to NAVIGATION_NONE.

mode — the navigation mode.
Valid values:
NAVIGATION_FULL — works only when the 3D window is not linked with a camera
NAVIGATION_LIMITED_TO_Z_ABOVE_ZERO — works only when the 3D window is not linked with a camera
NAVIGATION_ROTATION_ONLY
NAVIGATION_NONE
Rotation
Function Description
double getRotation() Returns the rotation of the shape in radians, clockwise.
void setRotation(double r) Sets the rotation of the shape.

r — the new value of rotation in radians.
Visibility
Function Description
boolean isVisible() Checks the visibility of the 3D window. If the 3D window is visible, returns true, otherwise returns false.
void setVisible(boolean v) Sets the visibility of the 3D window.

v — visibility: if true — the 3D window is set to be visible, if false — not visible.
Level
Function Description
Level getLevel() Returns the level, where this 3D window is located.
Group
Function Description
ShapeGroup getGroup() Returns the group containing this 3D window.
Points inside the shape
Function Description
boolean contains(double px, double py) Test if the shape contains the point with the given coordinates (relative to this shape’s container, i.e. in the same system with the coordinates of this shape, x and y). Returns true if the shape contains the point with the given coordinates.

px — the x coordinate relative to this shape’s container.
py — the y coordinate relative to this shape’s container.
Point randomPointInside() Returns the randomly chosen point inside the shape area.
This function utilizes Random Number Generator of the Presentable object containing this shape. (Will throw an exception if the shape has been created from code and has not been added to any group, — in this case use randomPointInside(Random rng)).
Point randomPointInside(java.util.Random rng) Returns the randomly chosen point inside the shape area. This function utilizes the given Random Number Generator.

rng — the random number generator.
How can we improve this article?