Main Content

Create World and Actor Using Simulink

This example shows how to create a 3D environment with an empty actor and view in the Simulation 3D Viewer window using Simulink®. You can use the Simulation 3D Scene Configuration block to create a 3D environment and the Simulation 3D Actor block to create an empty actor. You can then view the 3D environment in the Simulation 3D Viewer window. For an example that shows how to create a 3D environment with an actor using MATLAB®, see Create World and Actor Using MATLAB.

This process does not build an appearance for the actor, so the Simulation 3D Viewer does not render a visualization of the actor. For an example that shows how to build an appearance for an empty actor, see Build Actor from 3D Graphic Primitives Using Simulink.

Open Model

Open the Simulink model.

open_system("CreateWorld");

Simulink model with Simulation 3D Actor block and Simulation 3D Scene Configuration block

Explore Model Components

The model includes a Simulation 3D Scene Configuration block and a Simulation 3D Actor block. The Simulation 3D Scene Configuration block implements a 3D simulation environment. Double-click the Simulation 3D Scene Configuration block to open the Block Parameters dialog box. Set a view in the scene with the Scene view parameter. You can also set a custom viewpoint with this parameter. You must include the configuration block when building Simulink models with Simulation 3D Actor blocks.

Block parameter dialog box of Simulation 3D Scene Configuration block

The Simulation 3D Actor block adds an actor to the 3D environment. Double-click the Simulation 3D Actor block to open the Block Parameters dialog box. To create an actor before simulation starts, on the Main tab, set the Operation parameter to Create at setup. The block first creates an empty actor with the name specified in the Actor name parameter. You can use any name for the actor. Then, the block loads the source file, if any is present, and runs the Initialization script to build an appearance for the actor. For more details, see Operating Modes. For this example, the block does not build an appearance for the actor in the 3D environment.

Parameters of Simulation 3D Actor block

Simulate Model

Simulate the model and view the 3D environment in the Simulation 3D Viewer.

sim("CreateWorld");

Empty virtual world scene

Close Model

Close the Simulink model.

close_system("CreateWorld");

See Also

|

Related Topics