|
J2ME Lets You Go 3D
The time is ripe for 3D graphics programming for Java-enabled mobile devices through the M3G API
by Daniel F. Savarese
June 27, 2005
Just as nature abhors a vacuum, software abhors an underutilized CPU. The more capable a device, the more feature-rich its software will become. The graphics-capable devices catered to by Java 2 Platform, Micro Edition (J2ME)—from PDAs to cell phones—have become sufficiently powerful to render 3D graphics in real time. In addition to games, applications such as three-dimensional data visualization, mapping programs, and user interfaces require 3D graphics. The J2ME Mobile 3D Graphics API (M3G) bridges platform-specific graphics capabilities with a common programming interface for Java-enabled small devices. If you are already familiar with the MIDP 2.0 API, M3G provides a great way to enhance your J2ME projects.
As with the Java 3D API (see "Learning to Fly," Java Pro, June 2003), the most difficult part of understanding M3G is figuring out where to get started if you have no prior experience with 3D graphics programming. In such a situation, I recommend inventing a simple program to write and scour the API for only those pieces you need to know as you write a particular part of the program. By the time you're done, you'll understand the API enough to study it in depth. Also, you'll realize a better way to write your familiarization program, which you'll promptly throw away. If you have prior experience with 3D graphics programming, you'll grasp M3G quickly because it borrows design concepts from OpenGL.
M3G supports two modes of operation: retained and immediate. Retained mode allows you to load and display prefabricated 3D environments. Immediate mode allows you to define 3D environments through direct instantiation and assembly of objects in a program. The distinction is somewhat artificial because the data structures required to support immediate mode are used by retained mode methods when they load scene graphs from persistent storage. Providing an immediate mode API is simply a matter of exposing publicly the private programming framework used by retained mode. Likewise, providing retained mode is simply a matter of building some scene graph parsers and combining them with scene assemblers built on top of the immediate mode framework.
Back to top
|