Create World and Actor
This example shows how to create an actor in a virtual world to display in the Simulation 3D Viewer window using Simulink® or 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 actor, see Build Actor from 3D Graphic Primitives.
Create Virtual World with Actor Using Simulink
Open the Simulink model.
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.
The Simulation 3D Actor block adds an actor to the virtual world. 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 virtual world.
Simulate the model and view the virtual world in the Simulation 3D Viewer.
Close the Simulink model.
Create Virtual World with Actor Using MATLAB
Create a world scene.
world = sim3d.World();
Add an actor to the world.
Run a simulation set for
10 seconds with a sample time of
Delete the world object.