Main Content

Transition Aero.VirtualRealityAnimation to Unreal Engine 3D Environment

Classic Virtual Reality World is being replaced with a new 3D environment using Unreal Engine®  from Epic Games®. The functions and blocks that allow you to build virtual reality worlds, import models, and link virtual reality worlds using VRML format to MATLAB® and Simulink® will be removed in a future release. Instead, use the sim3d classes and Simulation 3D blocks to create, interact with, and link 3D environments with MATLAB and Simulink.

To update your code and interface with the new 3D environment, you must use the sim3d.World class. While there are no direct replacements for the Aero.VirtualRealityAnimation functions, you can achieve similar tasks with the sim3d classes.

The table outlines the old functions and their equivalent new functions to achieve the same task.

Old FunctionalityNew FunctionalityDescription of New FunctionalityMore Information
Aero.VirtualRealityAnimation sim3d.World (Simulink 3D Animation)Create a 3D environment and co-simulate with the Unreal Engine simulation environment.
addNodesim3d.Actor (Simulink 3D Animation)Create or import actor objects into the 3D environment.
add (Simulink 3D Animation)

Add actor to 3D environment

load (Simulink 3D Animation)

Load 3D models or actors into 3D environment

addRouteParent

Use the Parent property to set any actor in the 3D environment as the parent actor of a sim3d.Actor (Simulink 3D Animation) object.

  • The default parent actor is the Scene Origin at (0,0,0).

  • Actor Translation and Rotation properties are with respect to their parent.

delete

delete

Create actor object in the 3D environment.

Build actor from an imported 3D file.

 
initialize

Not required

Delete the sim3d.World or sim3d.Actor object.

 
addViewpointcreateViewport (Simulink 3D Animation)

Set the relative rotation of the actor object.

Use createViewport (Simulink 3D Animation) to define the main game viewer window.

createViewpoint (Simulink 3D Animation)

Create custom view of 3D environment.

Obtain additional view windows with sensors such as Ideal Camera.

setView (Simulink 3D Animation)

Set view of 3D environment.

Interact with 3D Simulation Environment.

nodeInfoworld.Actors (Simulink 3D Animation)

List all of the sim3d.Actor (Simulink 3D Animation) in the sim3d.World (Simulink 3D Animation).

World.Actors is a structure containing the properties for each actor.

playview (Simulink 3D Animation)

Open the Simulation 3D Viewer window and display the 3D environment.

run (Simulink 3D Animation)

Start the co-simulation with the Unreal Engine and update the Simulation 3D Viewer window at each time step.

pause (Simulink 3D Animation)

Pause co-simulation with 3D simulation engine.

resume (Simulink 3D Animation)

Resume co-simulation with 3D simulation engine.

close (Simulink 3D Animation)

Resume co-simulation with 3D simulation engine.

wait (Simulink 3D Animation)

Wait for co-simulation to complete.

play (Simulink 3D Animation)

Play and interact with the recorded 3D animation data.

removeNoderemove (Simulink 3D Animation)

Remove actor added to world or remove all actors in world.

 
removeViewpointdeleteViewport (Simulink 3D Animation)

Delete viewport from 3D environment.

 
deleteViewpoint (Simulink 3D Animation)

Delete viewpoint from 3D environment.

 
saveassave (Simulink 3D Animation)Save world object to MAT file. 
updateNodes

Not required

Not applicable

 

Use these sim3d functions to achieve your 3D tasks.

TaskAero.VirtualRealityAnimation FunctionalityUse This Instead3D Environment Description

Create world

h = Aero.VirtualRealityAnimation;
world = sim3d.World(Output=@OutputImpl);

Create 3D environment using sim3d.World (Simulink 3D Animation) class and optionally use Output (Simulink 3D Animation) argument to specify a user-defined local function. The output function updates the 3D environment data during simulation. The output function is included in the task to animate actor and view 3D simulation.

The world object creates a default view point to view the 3D environment.

Load world

h.VRWorldFilename = “asttkoff.wrl”;
load(world,'asttkoff.wrl');

Load the VRML file in the world object.

View World

h.initialize();
h.initialize(); 

Initialization is not necessary.

Use world.View to open and display the 3D environment in the Simulation 3D Viewer window.

Access actors

[~, idxPlane] = find(strcmp('Plane', h.nodeInfo)); 
plane = world.Actors.Plane; 

The actors in the scene are stored in a structure and can be accessed using the Actors (Simulink 3D Animation) property in sim3d.World (Simulink 3D Animation) object.

Edit actor properties

load takeoffdata; 

h.Nodes{idxPlane}.TimeseriesSource = takeoffData; 

h.Nodes{idxPlane}.TimeseriesSourceType = 'StructureWithTime';
plane.Translation = [0 0 0];

The default coordinate system of the 3D environment is the world coordinate system. For more information on the coordinate systems, see Coordinate Systems in Simulink 3D Animation (Simulink 3D Animation).

For more information on the sim3d.Actor (Simulink 3D Animation) object properties, see Properties (Simulink 3D Animation).

Animate actor and view 3D simulation

h.play(); 
h.wait(); 
sampletime = 0.02; 

stoptime = 2; 

run(world,sampletime,stoptime); 

function OutputImpl(world) 

world.Actors.Plane.Translation = ... 
world.Actors.Plane.Translation ... 
    + [0.1 0.1 0]; 

end

These executions are done by the run (Simulink 3D Animation) function.

Opens and displays the 3D environment in the Simulation 3D Viewer window.

Starts the co-simulation with the Unreal Engine.

The OutputImpl function sends MATLAB® the data about the actor from the Unreal Engine environment. The run function updates the 3D environment data at each time step of the simulation using the data from the output function.

See Visualize Aircraft Takeoff via Unreal Engine 3D Environment for an example of how to transform actors using timeseries data.

See Also

Topics