Documentation

Interact with Virtual Reality Worlds

Create and interact with MATLAB®virtual world objects, input virtual world data to Simulink®models

You can use MATLAB functions and classes to interact with virtual reality worlds. Create a virtual world object (vrobject) and node objects (vrnode) to represent a virtual world that you create withSimulink 3D Animation™. Change and control the degrees of freedom for the virtual world from within the MATLAB environment by setting values for the available virtual world nodes and their fields usingvrnodeobject methods.

Virtual reality scenes can contain sensors, which are nodes that generate events and output values depending on time, navigation, and actions and distance changes in the scene. These nodes add interactivity to the virtual world. You can useSimulink 3D Animationfunctions to read sensor field values into simulation models and control simulation based on the user interaction with the virtual scene. You can write an S-function or aMATLAB Functionblock that reads the sensor output.

Functions

vrworld Create new vrworld object associated with virtual world
vrdrawnow Update virtual world
vrnode Create node or handle to existing node
vr.canvas Create virtual reality canvas
vrclear Remove all closed virtual worlds from memory
vrwho List virtual worlds in memory
vrwhos List details about virtual worlds in memory
vrfigure Create virtual reality figure
vrfigure.capture Capture virtual reality figure image
vrfigure.close Close virtual reality figure
vrfigure.get Return property value of vrfigure object
vrfigure.isvalid Check validity of vrfigure object handles
vrfigure.set Set property values of vrfigure object
vrgcf Handle for active virtual reality figure
vrgcbf Current callback vrfigure object
vrclose Close virtual reality figure windows
vr.utils.stereo3d Stereoscopic vision settings for vr.canvas and vr.figure objects
vrdir2ori Convert viewpoint direction to orientation
vrori2dir Convert viewpoint orientation to direction
vrrotvec Calculate rotation between two vectors
vrrotmat2vec Convert rotation from matrix to axis-angle representation
vrrotvec2mat Convert rotation from axis-angle to matrix representation
vrifs2patch 把虚拟世界IndexedFaceSet MATL节点AB patches
vrpatch2ifs Convert MATLAB patches to IndexedFaceSet nodes
vrjoystick Create joystick object
vrspacemouse Create space mouse object

Blocks

VR Source Read data from virtual world to Simulink model

MATLAB Interaction

Virtual Reality World and Dynamic System Examples

Use virtual worlds that interface to Simulink block diagrams and to MATLAB objects and functions.

Create vrworld Object for a Virtual World

Connect MATLAB to a virtual world and interact with that virtual world through the MATLAB command-line interface by creating vrworld and vrnode objects.

Open a Virtual World with MATLAB

Open a virtual world to view the virtual world in a virtual world viewer, scan its structure, and change virtual world properties from the MATLAB Command Window.

Interact with a Virtual World with MATLAB

Interact with virtual world by using vrnode object methods to set vrworld object property values for all the available virtual world nodes and their fields.

关闭和删除一个vrworld对象

Close virtual worlds and remove them from memory.

Virtual World Data Types

Explore the data types used by nodes for defining objects and the types of data that can appear in the node fields and events.

VRML Sensor Input to Models

Add Sensors to Virtual Worlds

Set up an interface between a Simulink model and sensors in a virtual reality scene.

Modify Remote Virtual World Via Sensor Events

Interactive mode allows clients to modify a remote virtual world via events from sensor nodes defined in the virtual world.

Read Sensor Values

Read a value of a readable field (either exposedField or eventOut), by synchronizing that field with the vrnode/sync method. After synchronization, each time the field changes, the field value updates on the host and you can read its value.

Detect Object Collisions

You can use collision detection to model physical constraints of objects in the real world accurately, to avoid having two objects in the same place at the same time.

Source Block Input to Models

Connect Virtual Worlds and Models

Associate a Simulink model with a virtual world and connect signals from the Simulink model to the virtual world.

Was this topic helpful?