Creating and Controlling Virtual Worlds
by Andrew Thomas, Andrew Foo and Alan Islas-Cital.
One of the most exciting developments in computer graphics, from the perspective of data visualisation, is virtual reality (VR). VR lets you explore realistic 3D scenes as if you were actually there, and one of the more important mainstream methods of developing VR worlds is through use of the Virtual Reality Markup Language (VRML). However, to create a scene in VRML with many thousands of elements can be time consuming and extremely complex. So, here VRML development is simplified to create a complex 3D scene using a simple set of library functions, together with some details of a project to control the VR scene using a microcontroller circuit.
The library functions are programmed using MatLab compatible code, which provides a very powerful way to simplify the maths associated with 3D design. That means the code can be run in MatLab, although you could just as easily use Sysquake, LME, Octave, or FreeMat. To illustrate what can be achieved a VRML world is illustrated in Figure 1 (click the image to access the VRML file, either for downloading or for exploring in an embedded viewer). The code to achieve this scene can be downloaded by clicking here, and has been tested using FreeMat, as well as LME for VRML creation on a Pocket PC. If you study the code carefully, you should be able to use the library functions to develop your own VRML scene, as it includes functions to create the VRML file, add viewpoints, draw 3D primitives, draw triangle meshes, and even draw simple trees and lamp-posts. In fact, when you read it, you may be quite surprised just how simple the code is for such a complex scene!
Figure 1. The VRML world (click to view the virtual reality file on a Windows PC).
The VRML scene in Figure 1 was developed as part of a spare-time project to create an open-source example of how to interact with a virtual world using a prototype microcontroller-based wireless (Bluetooth) controller. The controller (see Figure 1) was based around a Microchip PIC microcontroller, a two-axis accelerometer module, a two-axis magnetometer compass module, a GPS module and a Bluetooth transceiver module. As you can see in Figure 2, fitting all of those components in a sensible-sized plastic enclosure was a significant challenge for Alan.
Figure 2. The prototype microcontroller based control box (closed and open).
The advantage of including so many sensors was that the controller could prove itself useful not only for desk-based navigation through the VRML scene, but also by allowing the viewpoint position and view direction to be updated in real-time when moving around outdoors. That has two advantages. Firstly, it allows the controller users position and direction to be viewed in VR by another person with a Bluetooth enabled computer (a laptop and Pocket PC were both used for this). Secondly, the controller allowed the user to navigate a 3D scene (whether a represntation of an imaginary place, or somewhere real) by actually walking around it. Prototype software was developed using MatLab and NS Basic on a laptop PC, as well as using NS Basic on a Pocket PC, the latter allowing more portable use. Those software files can't be provided here however, due to the licensing requirements of the VRML viewer software module used (Cortona by Parallel Graphics).
Overall, the project provided a lot of fun and learning for those involved, and the concept of using a single prototype controller for a wide range of indoor and outdoor VR control uses was definitely validated. Hopefully you will find the project inspiring enough to develop your own VRML scene and maybe even your own microcontroller based interface.
The work described above was part of a personal collaboration between three people, who met while working at the University of Birmingham (UK), and whose involvement is gratefully acknowledged. Without their teamwork it is unlikely that the project described above would have been realised.
Andrew Thomas was responsible for development of initial controller prototype circuits/code, development of the VRML scene based on previous MatLab compatible library programming, and writing of NS Basic code.
Andrew Foo was responsible for development of GPS circuitry and associated microcontroller code, development of MatLab-based code for viewing and manipulating the VRML scene, and testing the prototype hardware and software.
Alan Islas-Cital was responsible for development of the controller circuit into a usable final prototype form including electrical CAD design, PCB layout design, PCB construction, PCB population, and the unenviable task of making it fit into the relatively small plastic enclosure.