[ This chapter does not appear in the book. ]
This article describes how to display a Wavefront OBJ model in a MIDP 2.0 application called ModelDisplay, using the Mobile 3D Graphics API (M3G for short).
ModelDisplay displays a single OBJ model in the center of the screen, and allows it to be translated left, right, up, down, forward, and back, and rotated around the y-axis via the keypad (see the 'hand' pictures here). Holding a key down causes its associated action to repeat.
Although ModelDisplay is designed to display a single model at a time, with some effort it can be modified to show multiple models at once. I'll go into the details later.
I won't be explaining MIDP 2.0, or even M3G; plentiful documentation on both of them comes with the latest version of the J2ME Wireless Toolkit, v.2.2 (available from http://java.sun.com/products/j2mewtoolkit/).
The motivation for this work is that 3D models can only be loaded into M3G if they're stored in the M3G file format. There are a few free or shareware utilities for exporting M3G files from 3D modeling software. For example, HI Corporation, developers of the Mascot Capsule engine, offers several tools at http://www.mascotcapsule.com/M3G/index_e.html.
Ben Hui maintains a great website listing M3G resources, including tutorials and development software ( http://www.benhui.net/mobile3d).
Our approach doesn't use the M3G file format, instead the model is converted into Java methods.
The 3D modeling package must export the model as an OBJ file. This is processed by a separate Java 3D application, called ObjView, which outputs a text file of methods containing the model's vertices, normals, and so on. These methods are manually pasted into the ModelDisplay prior to its compilation. The general strategy is shown below.
The main advantage of this approach is the accessibility of the code representing the model. The methods can be pasted into any M3G-based application, not just ModelDisplay. The methods can be easily modified, and integrated with other M3G code in various ways. Later chapters will use ObjView-generated methods to create animated and morphing models.
Dr. Andrew Davison
Back to my home page