quarc_vr_toolbox_demo.mdl
Open this model

Integration with Simulink 3D Animation Toolbox Demo

This example demonstrates how to use QUARC specific blocks with the Simulink 3D Animation Toolbox from Simulink. It showcases the ability of QUARC to be integrated with the Simulink 3D Animation Toolbox.

Simulink 3D Animation Toolbox Demo Simulink Diagram

The Host Mouse block from the QUARC Targets library is used to obtain the X-Y coordinates of the mouse cursor. The virtual world is a small red ball which traces the movement of the mouse cursor. In addition, the Host Keyboard block is used as a switch to dictate when the ball should trace the cursor. For details of these blocks, please refer to the Host Mouse and Host Keyboard blocks reference pages in the QUARC documentation. The VR Sink and VR Placeholder blocks used in this example reside in the Simulink 3D Animation Toolbox library in the Simulink library browser.

The Host Mouse block has been configured to output the X-Y coordinates as percentages of the entire display (including all monitors) so that the demo works the same regardless of the display resolution. The reason for negating the value of the Y coordinate in addition to scaling it up is for the ball in the virtual world to trace the mouse cursor's movement as it moves around the display. Both coordinates are biased so that the ball is centered in the virtual scene when the mouse is centered in the display.

Demonstration

Make sure that the virtual world is not opened by the viewer before starting the model.

Building, deploying and starting the model

Refer to One Step Process in QUARC Basic Procedures to build, deploy and start the model.

Running the model

Once the model has started running, double-click on the VR Sink block to view the virtual world.

Virtual World Viewer

If you move the mouse cursor, you do not see the ball changing its position from its origin. Now, press and hold the H key on the keyboard. While the H key is held pressed, move around the mouse cursor. Notice how the ball traces the movement of the mouse cursor.

Close the virtual world window.

Stopping the model

Refer to One Step Process in QUARC Basic Procedures to stop the model.

Running the example on a different target

To run the example on a different target, refer to the instructions on the Running QUARC Examples on Remote Targets page.