MATLAB Transition Workflow
Transition your code to the sim3d
interface to complete these
tasks.
Task | vr Functionality | sim3d Functionality | 3D Environment Description |
---|---|---|---|
Create world. Load world. |
world = vrworld('file.x3d');
open(world) |
world = sim3d.World(Output=@OutputImpl);
load(world,'file.x3d'); | Create the 3D environment using the The world object creates a default viewpoint to view the 3D environment. Load the VRML file in the world object. |
Access actors. |
car = vrnode(world,'Automobile'); |
car = world.Actors.Automobile; | The actors in the scene are stored in a structure and can be accessed
using the Actors property in sim3d.World
object. |
Edit actor properties. |
car.translation = [3 0 0.25]; |
car.Translation = [3 0.25 0]; | The default coordinate system of the 3D environment is the world coordinate system. For more information on coordinate systems, see Coordinate Systems in Simulink 3D Animation. For more information on the |
View world. |
view(world,'-internal'); |
view(world); | Open and display the 3D environment in the Simulation 3D Viewer window. |
Animate actor and view 3D simulation. |
for i=1:length(x1) car.translation = car.translation ... + [0.1 0 0.1]; vrdrawnow; pause(0.1); end |
sampletime = 0.02; stoptime = 2; run(world,sampletime,stoptime); function OutputImpl(world) world.Actors.Automobile.Translation = ... world.Actors.Automobile.Translation ... + [0.1 0.1 0]; end | The
The |