SimMechanics | ![]() ![]() |
Creating Virtual Worlds for SimMechanics Models
The Virtual Reality Toolbox User's Guide and VRML books such as Marrin and Campbell [9] explain how to create virtual objects and assemble them into virtual worlds. This section highlights the special requirements to make a virtual world usable as a visualization for a SimMechanics model.
As you create a virtual world populated by virtual bodies, you must create each component body, then plan and implement the geometry of the machine's initial state. Doing this yourself is a major difference from the SimMechanics virtual reality visualization, where the bodies are created, placed, and oriented automatically. Use a VRML authoring tool that can read VRML as a native format to create and edit virtual reality .wrl
files. If you are familiar with raw VRML source code, you can use a plain text editor or the MATLAB editor to edit the files.
You represent each body by a virtual object encoded in a .wrl
file.You also create a master .wrl
file to represent the virtual world that refers to body .wrl
files, placing and orienting these body in the larger scene. You can define a body's position and orientation with respect to:
You can nest body references to other bodies in VRML hierarchies, but you must define at least one body's position and orientation with respect to the overall virtual world. Place and orient the bodies in their initial states, corresponding with the initial state of the SimMechanics simulation.
Each body's .wrl
file contains a hierarchical tree starting with the Transform node. Among Transform's fields must be translation and rotation fields to specify the body's position and orientation in space. If a body is nested below another body, its position and orientation are defined with respect to the next body up the hierarchy.
Creating your own virtual world gives you great flexibility in representing your machine:
Example: Viewing Custom External VRML Files for the Conveyor Loader
The demo model mech_conveyor_vr
is a modified version of the original conveyor model mech_conveyor
and comes with external VRML files containing static renderings of the machine parts in their initial positions. This example uses the V-Realm Builder® VRML authoring tool in the Virtual Reality Toolbox to view the files.
\toolbox\physmod\mech\mechdemos\
directory, open these files:
convmech.wrl
that refers to the six VRML files representing each component body:
New World
.
![]() | Creating a Custom Machine Visualization | Interfacing SimMechanics with Virtual Worlds | ![]() |