Interact with Actors and Virtual World
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 virtual world with actors. An actor is any object in the virtual world that can move and rotate to support 3D transformations. Build actors and view the virtual world 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 virtual world. The sim3d.Actor
object
and functions create actor objects and builds appearance for actor in virtual world.
In Simulink, use the Simulation 3D Scene Configuration block to implement the 3D simulation environment and view the virtual world. The Simulation 3D Actor block creates actor objects and builds appearance for actor in virtual world.
For an example showing how to create a virtual world, build an actor, and view the virtual world using MATLAB or Simulink, see Build Actor from 3D Graphic Primitives.
You can interact with the actors and the virtual world during simulation in the Simulation 3D Viewer window. A virtual camera displays the virtual world scene. You can navigate in the virtual world using keyboard shortcuts and mouse controls to change the location of the virtual camera. In Simulink, you can interact and navigate in virtual world when the simulation is paused.
Open Simulation 3D Viewer
View a virtual world in the Simulation 3D Viewer window. During simulation, right-click the actor or the virtual world to display a context menu that lists options to interact with the corresponding actor or virtual world. 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.
The table summarizes the options in the context menu.
Actor Option | Description |
---|---|
Remove | Remove actor from the virtual world. To add the actor back to the virtual world, run the simulation again. |
Standard Views | List the standard views of the actor.
|
Save as MAT file | Save the actor properties in a MAT file. |
Send to Console | Display the actor properties in the MATLAB Command Window. |
Show Actor Origin | Display the axes of the default coordinate system at world origin. |
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 |
Interact with Virtual World
During simulation, right-click the virtual world to display the context menu for the world.
The table lists the options for virtual world.
World Options | Description |
---|---|
Save as MAT file | Save the virtual world as a MAT file, including all the actors in the world. |
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. |
Navigate in Virtual World
During simulation, a virtual camera displays the virtual world 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 virtual world with the Scene view
parameter of the Simulation 3D Scene
Configuration block. When viewing the virtual world 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 virtual world, use these keyboard shortcuts.
Keyboard Shortcut | Camera 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 |
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. |
For more examples of how to create a virtual world with actors, see Get Started Creating Virtual World with Actors
See Also
sim3d.World
| sim3d.Actor
| Simulation 3D Scene
Configuration | Simulation 3D
Actor