Main Content

Build Actor from Imported 3D File Using Simulink

This example shows how to build an actor from an imported 3D file using Simulink®. If you have a custom actor defined in a supported 3D file, you can import the file. You can import 3D file formats including FBX, STL, and URDF.

To build an actor from an imported 3D file using MATLAB®, see Build Actor from Imported 3D File Using MATLAB.

You can use Simulation 3D Actor block and Simulation 3D Scene Configuration block to create and build an actor in a 3D environment from an imported 3D file.

Open Model

Open the Simulink model.

open_system("CreateActorFromImport");

Simulink model with Simulation 3D Actor block named rotor and a Simulation 3D Scene Configuration block.

Explore Model Components

The model includes a Simulation 3D Actor block and a Simulation 3D Scene Configuration 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. For more details, see Operating Modes. Specify the STL file in the Path to source file parameter to import a 3D file. On the Transform tab, set the initial position and rotation of the actor in the 3D environment.

The block parameter dialog box of the Simulation 3D Actor block named rotor shows parameters and the file name in the path to the source file.

Simulate Model

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

sim("CreateActorFromImport");

Imported 3D actor in the virtual world.

Close Model

Close the Simulink model.

close_system("CreateActorFromImport");

See Also

|

Related Topics