1、MATLAB Virtual Reality Toolbox Installing a VRML Plug-In (Windows) When you install the Virtual Reality Toolbox, the Virtual Reality Toolbox viewer is set as the default viewer. If you want to use a Web browser as a VRML viewer, use the following procedure to install the blaxxun Contact plug-in. Y
2、ou can use this plug-in with either Microsoft Internet Explorer or Netscape Navigator. The blaxxun Contact plug-in is the only supported VRML plug-in. Note The blaxxun Contact installer installs the plug-in for the current default browser only. If you change the default browser, you need to comp
3、lete the install procedure a second time. The blaxxun Contact executable files are located at C:\
4、ity Toolbox. You can download blaxxun Contact 4.4 from If you have the MATLAB Web Server installed on your machine, make sure that the Web Server is stopped before you install the blaxxun Contact plug-in. Also, verify that you are connected to the Internet before starting this installation procedu
5、re: 1.Start MATLAB. 2.In the MATLAB Command Window, type :vrinstall -install viewer MATLAB displays the message :Do you want to use OpenGL or Direct3d acceleration? (o/d) 3.Check the graphic card manual to determine the acceleration method to select. If you are not sure, select Direct 3d by typ
6、ing :d The blaxxun installer starts running and displays the following dialog box. 4.Follow the instructions on the remaining screens. 5.In the MATLAB Command Window, type :vrinstall -check If the viewer installation was successful,MATLAB displays the following message: VRML viewer: installed
7、 If the viewer installation was unsuccessful, MATLAB displays the message:VRML viewer: not installed Known Issue with the blaxxun Contact Plug-In The blaxxun Contact VRML plug-in can fail to update the virtual scene when used with the Virtual Reality Toolbox 3.0 and Microsoft Internet Explorer 5.
8、5 and above. Netscape users do not experience this problem. If you are using Internet Explorer 5.5 or above, you must manually change a network security setting before you can use blaxxun Contact 4.4 with the Virtual Reality Toolbox Version 3.0. Upgrading your version of blaxxun Contact does not re
9、solve this problem. Changing the Default Network Security Setting You must change your default network security setting before using the blaxxun Contact plug-in with Internet Explorer 5.5 and above to ensure that the virtual scene is updated appropriately: 1.Open Internet Explorer. 2.From the T
10、ools menu, choose Internet Options. The Internet Options dialog box opens. 3.Click the Security tab. 4.Select the Custom Level button. The Security Settings dialog box opens. 5.Scroll down until you see Microsoft VM. The first subheading is Java permissions. 6.Select Custom. The Java Custom
11、Settings button appears in the lower left of the Security Settings dialog box. 7.Click Java Custom Settings. The Local intranet dialog box opens. 8.Click the Edit Permissions tab. 9.Scan the main headings and subheadings (marked with a lock icon) until you see Access to all Network Addresses.
12、 10.Under Access to all Network Addresses, select Enable. 11.Click OK. The Local intranet dialog box closes. 12.In the Security Settings dialog box, click OK. You are asked if you want to change the security settings for this zone. 13.Select Yes. 14.In the Internet Options dialog box, selec
13、t OK. Setting the Default Viewer of Virtual Scenes If you install a VRML plug-in in your Web browser, it is possible to view virtual scenes with either the Virtual Reality Toolbox viewer or your Web browser. You determine the viewer used to display your scene using the vrsetpref and vrgetpref com
14、mands. The following procedure assumes that you are working on a PC platform: 1.At the MATLAB command prompt, type :vrinstall -check to determine whether blaxxun Contact is installed. MATLAB displays: VRML viewer: installed VRML editor: installed The viewer and editor are installed. If t
15、he viewer is not installed, see Installing a VRML Plug-In (Windows). 2.Determine your default viewer by typing :vrgetpref MATLAB displays :ans = DefaultFigurePosition: [5 25 400 320] DefaultPanelMode: 'halfbar' DefaultViewer: 'internal' Editor:
16、 [1x60 char] HttpPort: 8123 TransportBuffer: 5 VrPort: 8124 The DefaultViewer property is set to 'internal'. The Virtual Reality Toolbox viewer is the default viewer for viewing virtual scenes. Any virtual scenes that you open are displayed in the vi
17、ewer. 3.For example, at the MATLAB command prompt, type :vrbounce The Bouncing Ball demo is loaded and the virtual scene is displayed in the Virtual Reality Toolbox viewer. 4.Change the default viewer to your Web browser by typing : vrsetpref('DefaultViewer','web') The default Windows system VRM
18、L plug-in is used. The blaxxun Contact VRML plug-in sets itself as the default VRML plug-in during its installation. 5.At the MATLAB command prompt, type: vrbounce The Bouncing Ball demo is loaded and the virtual scene is displayed in your Web browser. 6.Reset the Virtual Reality Toolbox viewer
19、 as your default viewer by typing vrsetpref('DefaultViewer','factory') 7.All virtual scenes are displayed by the Virtual Reality Toolbox viewer. In the vrbounce model window, double-click the VR Sink block. A Block Parameters dialog box opens. The target of the View button is determined by t
20、he DefaultViewer property. If the DefaultViewer property is set to 'internal', clicking the View button opens the virtual world in the Virtual Reality Toolbox viewer. If the DefaultViewer property is set to 'web', clicking the View button opens the virtual world in your Web browser. Installing VRM
21、L Editor (Windows) When you install the Virtual Reality Toolbox, files are copied to your hard drive for V-Realm Builder, but the installation is not complete. Installing the VRML editor writes a key to the Windows registry, making extra library files in V-Realm Builder available for you to use,
22、and it associates the Edit button in Virtual Reality Toolbox blocks with this editor: 1.Start MATLAB. 2.In the MATLAB Command Window, type: vrinstall -install editor or type :vrinstall('-install','editor') MATAB displays the following messages: Starting editor installation... Done. 3.Type :vr
23、install -check If the editor installation was successful, MATLAB displays the following message: VRML editor: installed Setting the Default Editor of Virtual Scenes You can edit virtual scenes with a VRML authoring tool, such as V-Realm Builder, or with any text editor, as the VRML language
24、is written in text files. You determine the editor that is used to edit your scene by using the vrsetpref and vrgetpref commands. The following procedure demonstrates how to change your editor from V-Realm Builder to a text editor. It assumes that you are working on a PC platform: 1.At the MATLAB
25、 command prompt, type: vrinstall -check to determine whether V-Realm Builder is installed. MATLAB displays:VRML viewer: installed VRML editor: installed The viewer and editor are installed. If the editor is not installed, see Installing VRML Editor (Windows). 2.Determine your default edi
26、tor by typing :a = vrgetpref MATLAB displays :a = DefaultFigurePosition: [5 25 400 320] DefaultPanelMode: 'halfbar' DefaultViewer: 'web' Editor: [1x60 char] HttpPort: 8123 TransportBuffer: 5 VrPort: 8124 Th
27、e variable a is a structure array. You need to index into it to determine the Editor property. 3.To determine your default editor, type :a.Editor MATLAB displays :ans ="%matlabroot\toolbox\vr\vrealm\program\vrbuild2.exe" "%file" This is the path to the V-Realm Builder executable file. V-Realm Bu
28、ilder is the current VRML editor. 4.Verify that V-Realm Builder is your default editor. At the MATLAB command prompt, type:vrpend The Inverted Pendulum demo loads and the pendulum is visible in the viewer. 5.In the vrpend model window, double-click the VR Sink block. The Block Parameters dialog
29、box opens. 6.Click Edit. The vrpend model opens in the V-Realm Builder authoring tool. 7.Change the default editor to the MATLAB editor by typing vrsetpref('Editor','%matlabroot\bin\win32\meditor.exe %file') You can set your editor to any text editor you want to use by specifying the path to
30、the executable of the text editor. 8.Within the vrpend demo, open the VR Sink Block Parameters dialog box. 9.Click the Edit button. The MATLAB editor opens and is now set as your default VRML editor. 10.To reset the V-Realm Builder authoring tool as your default VRML editor, type : vrsetpre
31、f('Editor','factory') Clicking the Edit button now launches V-Realm Builder. What Is the Virtual Reality Toolbox? The Virtual Reality Toolbox is a solution for viewing and interacting with dynamic systems in a three-dimensional virtual reality environment. It extends the capabilities of MATLAB an
32、d Simulink into the world of virtual reality graphics. l Virtual worlds -- Create virtual worlds or three-dimensional scenes using standard Virtual Reality Modeling Language (VRML) technology. l Dynamic systems -- Create and define dynamic systems with MATLAB and Simulink. l Animation -- View m
33、oving three-dimensional scenes driven by signals from the Simulink environment. l Manipulation -- Change the position and properties of objects in a virtual world, or change parameters in your Simulink model while running a simulation. To provide a complete working environment, the Virtual Reali
34、ty Toolbox includes additional components: l VRML viewer -- Use either the Virtual Reality Toolbox viewer or, for PC platforms, the blaxxun Contact plug-in for Web browsers to display your virtual worlds. l VRML editor -- For PC platforms, use V-Realm Builder to create and edit VRML code. For UNI
35、X or Linux platforms, use the MATLAB text editor to write VRML code to create virtual worlds. Associating a Virtual World with Simulink With the Virtual Reality Toolbox you can interface a Simulink block diagram with a virtual world. The example in this section explains how to display a simulated
36、 virtual world on a host computer. This is the recommended way to view associated virtual worlds on the host computer.This section includes the following topics: l Adding a Virtual Reality Toolbox Block -- Connect a Simulink model to a virtual world l Changing the Virtual World Associated with a
37、Simulink Block -- Change the virtual world associated with a Simulink model, and change the signals passed between Simulink and the virtual world Adding a Virtual Reality Toolbox Block Simulating a Simulink model generates signal data for a dynamic system. By connecting the Simulink model to a vi
38、rtual world, you can use this data to control and animate the virtual world. After you create a virtual world and a Simulink model, you can connect the two with Virtual Reality Toolbox blocks. The example in this procedure simulates a plane taking off and lets you view it in a virtual world: 1.In
39、 the MATLAB Command Window, type :vrtut2 A Simulink model opens without a Virtual Reality Toolbox block that connects the model to a virtual world. 2.From the Simulation menu, select Normal, then click Start. Observe the results of the simulation in the scope windows. 3.In the MATLAB Command
40、Window, type :vrlib The Virtual Reality Toolbox library opens. 4.From the Library window, drag and drop the VR Sink block to the Simulink diagram. You can then close the Library: vrlib window. Now you are ready to select a virtual world for the visualization of your simulation. A simple virtual
41、world with a runway and a plane is in the VRML file vrtkoff.wrl. 5.In the Simulink model, double-click the block labeled VR Sink. The Block Parameters: VR Sink dialog box opens. 6.In the Description text box, enter a brief description of the model. This description appears on the list of availa
42、ble worlds served by the Virtual Reality Toolbox server. For example, type :VR Plane taking off
7.Click the Browse button. The Select World dialog box opens. Find the directory
43、 box, click Apply. A VRML tree appears on the right side, showing the structure of the associated virtual reality scene. 9.Select Show node types. On the left of the Plane Transform node, click the + square. The Plane Transform tree expands. Now you can see what characteristics of the plane ca
44、n be driven from Simulink. This model computes the position and the pitch of the plane. 10.In the Plane Transform tree, select the translation and rotation fields The selected fields are marked with checks. These fields represent the position (translation) and the pitch (rotation) of the plane.
45、 11.Click OK. In the Simulink diagram, the VR Sink block is updated with two inputs. The first input is Plane rotation. The rotation is defined by a four-element vector. The first three numbers define the axis of rotation. In this example, it should be [1 0 0] for the x-axis. The pitch of the plan
46、e is expressed by the rotation about the x-axis. The last number is the rotation angle around the x-axis, in radians. 12.In the Simulink model, connect the line going to the Scope block labeled Display Pitch to the Plane rotation input. The second input is Plane translation. This input describes
47、 the plane's position in the virtual world. This position consists of three coordinates, x, y, z. The connected vector must have three values. In this example, the runway is in the x-z plane. The y-axis defines the altitude of the plane. 13.In the Simulink model, connect the line going to the Scop
48、e block labeled Display Position to the Plane translation input. After connecting the signals and removing the Scope blocks, your model should look similar to the figure shown. Note Virtual world degrees of freedom have different requested input vector sizes depending on the associated VRML fie
49、ld types. If the vector size of the connected signal does not match the associated VRML field size, an Incorrect input vector size error is reported when you start the simulation. 14.Double-click the VR Sink block in the Simulink model. Select the View button. A viewer window containing the plane's virtual world opens. 15.From the Simulation menu of the model file, click Start. A plane, moving right to left, starts down the runway and takes off into the air. Changing the Virtual World Associated with a Simulink Block Sometimes you might wan






