Build and Use Virtual Worlds
Virtual Reality World Models of Dynamic Systems
The Simulink® 3D Animation™ product is a solution for interacting with virtual reality world models of dynamic systems over time. It extends the capabilities of your virtual world and Simulink, Simscape™ Multibody™, and MATLAB® software into the world of virtual reality graphics. The product provides a complete authoring, development, and working environment for carrying out 3-D visual simulations.
To use virtual reality worlds to visualize dynamic system simulations, perform the following tasks:
As you refine your visualization, you often perform some of these tasks iteratively.
To work through an example that illustrates the building, linking, and viewing a virtual world, see Build and Connect a Virtual World.
Set Up Your Working Environment
Install the Simulink 3D Animation software in your MATLAB environment to build virtual reality worlds and to visualize dynamic simulations modeled in MATLAB, Simulink, or Simscape Multibody. If your computer does not already have a graphics card with hardware 3-D acceleration, consider installing such a card to enhance graphics performance.
You build and view the virtual reality world models using VRML (Virtual Reality Modeling Language) or X3D (Xtensible 3D).
In addition to the installed 3D World Editor (the default editor), you can configure your environment to use:
The Ligos® V-Realm Builder, which is included in the Simulink 3D Animation software for Windows® platforms.
Any third-party virtual world editor
The MATLAB editor or a third-party text editor
In addition to the installed Simulink 3D Animation viewer (the default), you can use one of these viewers to display your virtual reality worlds:
Simulink 3D Animation Web Viewer
Orbisnap, on a client computer
To help decide which 3D virtual world editor and viewer to use, see Choose a Virtual World Editor and Virtual World Viewers.
Use joystick and space mouse input devices to provide input for dynamic simulation visualizations.
3D Animation product uses a TCP/IP connection to a virtual reality world client for
communicating with the Simulink
3D Animation Viewer, as well as connecting to an HTML5-enabled web browser. You can
verify the TCP/IP connection between the host and client computers by using the
ping command from a command-line prompt. If there are problems, fix
the TCP/IP protocol settings according to the documentation for your operating
LD_LIBRARY_PATH Environment Variable for UNIX
If your system does not have the OpenGL® software properly installed when you run the Simulink 3D Animation Viewer, you can see a MATLAB error message like the following:
Invalid MEX-file 'matlab/toolbox/sl3d/sl3d/vrsfunc.mexglx': libGL.so: cannot open shared object file
If you see an error like this, set the
LD_LIBRARY_PATH environment variable already exists, use a
line similar to this code to add the new path to the existing one:
setenv LD_LIBRARY_PATH matlabroot/sys/opengl/lib/<PLATFORM>:$LD_LIBRARY_PATH
LD_LIBRARY_PATH environment variable does not already exist,
use a line similar to this code:
setenv LD_LIBRARY_PATH matlabroot/sys/opengl/lib/<PLATFORM>
In both cases,
<PLATFORM> is the UNIX® platform you are using.
Build a Virtual Reality World
Use the virtual world editor or other editor to build a virtual reality world. A non-VRML or non-X3D CAD model created with another tool can be a good basis for a virtual reality world to use with Simulink 3D Animation. You can convert some CAD models to a VRML or X3D model.
You can use advanced features of the Simulink 3D Animation product such as:
Viewpoints, to highlight points of interest for quick browsing of a virtual reality world
Sensors, to input virtual reality world values to Simulink models
For an overview of VRML and details about supported VRML features, see Virtual Reality Modeling Language (VRML). You can also use X3D, which provides several extensions, including additional nodes, fields, encoding, scene access interfaces, additional rendering control, and geospatial support. For details, see X3D Support.
As you add nodes with the 3D World Editor, you can use the viewer pane to see the virtual world that you are creating.
For a step-by-step example of building a virtual reality world with the 3D World Editor, see Build and Connect a Virtual World.
Link to a Virtual Reality World
To use a dynamic system simulation to drive a virtual reality world, connect the virtual world to one of these systems or objects:
Simscape Multibody model
MATLAB virtual world object
Connect to Simulink Model
The Simulink 3D Animation library provides blocks to connect Simulink signals to virtual worlds. This connection lets you visualize your model as a three-dimensional animation. Simulink provides communication for control and manipulation of virtual reality objects, using Simulink 3D Animation blocks. For details, see Connect Virtual Worlds and Models.
After you include these blocks in a Simulink diagram, you can select a virtual world and connect Simulink signals to the virtual world. The software automatically scans a virtual world for available nodes that the Simulink software can drive.
All the node properties are listed in a hierarchical tree-style viewer. You select the degrees of freedom to control from within the Simulink interface. After you close a Block Parameters dialog box, the Simulink software updates the block with the inputs and outputs corresponding to selected nodes in the virtual world. After connecting these inputs to appropriate Simulink signals, you can view the simulation with a virtual world viewer.
Connect to Simscape Multibody Model
You can use the Simulink 3D Animation product to view the behavior of a model created with the Simscape Multibody software. First, build a model of a machine in the Simulink interface using Simscape Multibody blocks. Then create a detailed picture of your machine in a virtual world. Connect this world to the Simscape Multibody body sensor outputs and view the behavior of the bodies in a virtual world viewer. For details, see Link to Simulink and Simscape Multibody Models.
Connect to MATLAB Virtual World Object
Simulink 3D Animation software provides a flexible MATLAB interface to virtual reality worlds. After creating MATLAB objects and associating them with a virtual world, you can control the virtual world by using functions and methods. MATLAB provides communication for control and manipulation of virtual reality objects using MATLAB objects. For details about interacting between MATLAB and virtual reality worlds, see Interact with Virtual Reality Worlds.
In MATLAB, you can set positions and properties of virtual world objects, create callbacks from graphical interfaces, and map data to virtual world objects. You can also view the virtual world with a viewer, determine its structure, and assign new values to all available nodes and their fields.
The software includes functions for retrieving and changing the virtual world properties and for saving the virtual world 3D files corresponding to the actual structure of a virtual world.
View Dynamic System Simulations
After you connect the virtual world to the model, use a virtual world viewer to view the virtual world representation of the dynamic system simulation.
In Simulink and Simscape Multibody, simulate the model that is connected to the virtual reality world.
In MATLAB, use the view function to view a
vrworldobject that the MATLAB code updates with data values.
While running a simulation, you can change the positions and properties of virtual world objects.
For information about using virtual world viewers to navigate a virtual reality world, see View Dynamic System Simulations.
Share Dynamic System Simulation Visualizations
You can share dynamic system simulation results with others.
Capture animation frame snapshots or record animations for video viewing. See Capture Frames and Share Visualizations.
Use a client-server configuration. In addition to the single computer configuration (when MATLAB, Simulink, and the virtual reality representations run on the same host computer). In a client-server configuration, an Orbisnap viewer on a remote client can connect to the server host on which Simulink 3D Animation software is running. This configuration allows others to view an animated virtual world remotely. Multiple clients can connect to one server. See Orbisnap Viewer.
Use the MATLAB Compiler™ to take MATLAB files as input and generate redistributable, standalone applications that include Simulink 3D Animation functionality, including the Simulink 3D Animation Viewer. See MATLAB Compiler Support