Virtual Reality Toolbox | ![]() ![]() |
Interacting with a Virtual World
In the life cycle of a vrworld object you can set new values for all the available virtual world nodes and their fields using vrnode object methods. This way, you can change and control the degrees of freedom for the virtual world from within the MATLAB environment.
An object of type vrworld
contains nodes named in the VRML file using the DEF statement. These nodes are of type vrnode
. For more information, see vrworld Object Reference and vrnode Object Reference for the full description of these objects.
After you open a vrworld object, you can get a list of available nodes in the virtual world. This procedure uses the vrworld object myworld
and the virtual world vrmount.wrl
as an example:
View1 (Viewpoint) [My first virtual world] Camera_car (Transform) [My first virtual world] VPfollow (Viewpoint) [My first virtual world] Automobile (Transform) [My first virtual world] Wheel (Shape) [My first virtual world] Tree1 (Group) [My first virtual world] Wood (Group) [My first virtual world] Canal (Shape) [My first virtual world] ElevApp (Appearance) [My first virtual world] River (Shape) [My first virtual world] Bridge (Shape) [My first virtual world] Road (Shape) [My first virtual world] Tunnel (Transform) [My first virtual world]
Now you can get node characteristics and set new values for certain node properties. For example, you can change the position of the automobile by using Automobile, which is the fourth node in the virtual world.
Note that dot notation is the preferred method for accessing the nodes of the vrworld object myworld
.
MATLAB displays the following table.
Field Access TypeSync ----------------------------------------------------------- translation exposedFieldSFVec3foff center exposedFieldSFVec3foff bboxCenter field SFVec3foff children exposedFieldMFNodeoff scale exposedFieldSFVec3foff bboxSize field SFVec3foff removeChildren eventIn MFNodeoff scaleOrientation exposedFieldSFRotationoff rotation exposedFieldSFRotationoff addChildren eventIn MFNodeoff
The Automobile node is of type Transform
. This VRML node allows you to change its position by changing its translation field values. From the list, you can see that translation requires three values, representing the [x y z] coordinates of the object.
It is possible to change the node fields listed by using the function vrnode/setfield
.
![]() | Opening a Virtual World | Closing and Deleting a vrworld Object | ![]() |