User`s guide
5 Build Virtual Reality Worlds
5-42
1
From the vrlib library, insert a VR Sink block into your Simulink model.
2
Double-click the VR Sink block to open the block parameters dialog, where you can
define the virtual world. Enter the name of the scene's VRML file in Source file, or
click Browse to select the file interactively. Click Apply to load the selected VRML
scene.
3
For smooth visualization of the movement, it is sometimes necessary to change
the block's Sample time. For example, to update the virtual world 25 times per
simulation second, set the Sample time to 0.04. Be careful when using the
inherited sample time for the VR Sink block. Depending on the solver used, using
inherited sample time might result in nonequidistant (in simulation time) updating
of the virtual world, giving the user a false impression of system dynamics.
4
In VRML Tree in the right side of the dialog box, expand the main object's
Transform branch, and, in the scene object hierarchy, locate all parts you want to
control from Simulink according to their names as given in “Add DEF Names”. Each
part is represented by named Transform nodes, and you select the check box next
to its rotation and position fields. These selections tell the VR Sink block that you
want to control the rotation and position of these parts. You can also select other
properties of virtual world objects, such as color, but rotations and positions are the
ones most frequently controlled.
5
Click OK. For each selected field, the VR Sink block creates an input port. Increase
the VR Sink block size as appropriate to the number of input ports.
After the VR Sink block is associated with a virtual world, you can double-click it to open
the Simulink 3D Animation viewer. Block parameters are available through the menu
Simulation > Block Properties in the viewer.
VR Sink inputs take signals of the type corresponding to their VRML representation.
Position inputs are of type SFVec3f, which is the position represented in [x y z]
coordinates. Rotation inputs are of type SFRotation, the four-element vector defining
rotation as [axis angle], using the coordinate system described in “Coordinate System
Used” on page 5-34, where the angle value is in radians.
The user has to match the coordinate system used by the Simulink model to that of the
virtual world. If the two systems are not identical, some kind of axes transformation is
necessary.
While object positions are usually available in the form required by VRML (Cartesian
coordinates), rotations usually have to be converted from some other representation.
In many cases, object rotations are defined using the rotation matrix representation.