Main Content

Interact with 3D Simulation Environment

The Simulink® 3D Animation™ provides an interface to a simulation environment that is visualized using the Unreal Engine® from Epic Games®. Within this environment, you can create a 3D environment with actors. An actor is any object in the 3D environment that can move and rotate to support 3D transformations. Build actors and view the 3D environment in the Simulation 3D Viewer through the MATLAB® and Simulink interfaces of the Simulink 3D Animation.

In MATLAB, use the sim3d.World object and functions to create and view a 3D environment. The sim3d.Actor object and functions create actor objects and builds appearance for actor in 3D environment.

In Simulink, use the Simulation 3D Scene Configuration block to implement the 3D simulation environment and view the 3D environment. The Simulation 3D Actor block creates actor objects and builds appearance for actor in 3D environment.

For an example showing how to create a 3D environment, build an actor, and view the 3D environment using MATLAB, see Build Actor from 3D Graphic Primitives Using MATLAB. For a Simulink example, see Build Actor from 3D Graphic Primitives Using Simulink.

You can interact with the actors and the 3D environment during simulation in the Simulation 3D Viewer window. A virtual camera displays a scene in the 3D environment. You can navigate in the 3D environment using keyboard shortcuts and mouse controls to change the location of the virtual camera. You can also interact and navigate in 3D environment when the simulation is paused.

Open Simulation 3D Viewer

View a 3D environment in the Simulation 3D Viewer window. During simulation, right-click the actor or the 3D environment to display a context menu that lists options to interact with the corresponding actor or 3D environment. You can also double-click an actor to zoom in with a best fit-to-screen view and attach the virtual camera to the actor.

Interact with Actor

During simulation, right-click the actor to display the context menu for actor and world.

Actor with context menu.

The table summarizes the options in the context menu.

Actor OptionDescription

Edit Properties

Open the Actor Editor to view or modify actor properties during simulation.

Right-click the actor and select Properties to display the Actor Editor on the right side of the Simulation 3D Viewer. The Actor Editor displays the actor name and its properties. You can edit the actor properties using the sliders and check boxes. For the slider to work, pause on the box to display a double-headed arrow, then click and drag to change the value. Alternatively, you can also click the box to set the property value. For more details on actor properties, see Properties of sim3d.Actor.

Actor editor user interface with actor properties.

Standard Views

List the standard views of the actor.

  • Left

  • Right

  • Front

  • Back

  • Top

  • Bottom

  • Perspective

Show Actor Origin

Display the axes of the default coordinate system at world origin.

Hide Actor Origin

Hide the coordinate axes of the actor.

Send to Console

Display the actor properties in the MATLAB Command Window.

Save as MAT file

Save the actor properties in a MAT file.

Remove

Remove actor from the 3D environment. To add the actor back to the 3D environment, run the simulation again.

Interact with 3D environment

During simulation, right-click the 3D environment to display the context menu for the world.

Actor in 3D environment with context menu of world.

The table lists the options for 3D environment.

World OptionDescription

Show Actor Hierarchy

Open the Actor Hierarchy to view the hierarchical structure of the actors in the 3D environment during simulation. You can click on the actor name to display the perspective view of the actor and attach the virtual camera to the actor. You can also right-click on the actor name to display the context menu for actor and world.

Actor hierarchy with names of all actors in the 3D environment

Show World Origin

Display the axes of the default coordinate system at world origin.

Hide All Origins

Hide the coordinate axes of all actors and world origin.

Save as MAT file

Save the 3D environment as a MAT file, including all the actors in the world.

Navigate in 3D environment

During simulation, a virtual camera displays the 3D environment scene in the Simulation 3D Viewer window. You can place the virtual camera at any location to display the corresponding viewpoint at the start of the simulation. In MATLAB, to set the initial viewpoint, use the createViewport function of the sim3d.World object with the Translation and Rotation properties in Viewports. In Simulink, you can set the initial viewpoint of 3D environment with the Scene view parameter of the Simulation 3D Scene Configuration block. When viewing the 3D environment in the Simulation 3D Viewer, you can change the location of the camera during simulation using keyboard shortcuts and mouse controls. You can also record nine camera viewpoints and access the stored viewpoints using keyboard shortcuts.

To navigate in 3D environment, use these keyboard shortcuts.

Keyboard ShortcutCamera Control

W

Move forward.

Shift+W

Move faster in the forward direction.

S

Move backward.

Shift+S

Move faster in reverse direction.

A

Move left.

Shift+A

Move faster toward left.

D

Move right.

Shift+D

Move faster toward right.

Q

Move up.

Shift+Q

Move faster in the upward direction.

E

Move down.

Shift+E

Move faster in the downward direction.

Mouse scroll wheel

Control the camera distance from the cursor point.

Shift+mouse scroll wheel

Camera moves faster.

Mouse right-click and drag

Orbit around the cursor point.

O

Attach camera to actor under the cursor point.

Mouse left-click and drag

Orbit around the actor after camera attaches to the actor.

P

Detach camera from the actor.

L

Record the current viewpoint and display Location saved on the scene.

1 to 9

Access the stored viewpoints, if available.

Tab

Cycle the view between all vehicles in the scene and the viewpoint at the start of the simulation, in the forward direction.

Shift+Tab

Cycle the view between all vehicles in the scene and the viewpoint at the start of the simulation, in the reverse direction.

I

Display the keyboard shortcuts on the screen.

For more examples on creating 3D simulations, see Create 3D Simulations in Unreal Engine Environment

See Also

| | |

Related Topics