Developing Mobile 3D Graphics for J2ME (JSR-184)

Mobile gaming and mobile applications are hot! Games need to have flashy and stylish graphics, and the standards are now higher than ever. Mikko Kontio tells you how to develop 3D graphics for your J2ME devices with the ultra-cool Mobile 3D Graphics API.

Like this article? We recommend

Like this article? We recommend

If you are programming the user interface with MIDP 1.0, there are two paths
you can walk: use the high-level UI classes or do everything yourself. For game
developers, the first choice is often not possible; that's why game
developers had to develop their own 3D engines for advanced games. That took
time and effort, and the lack of floating point numbers in CLDC 1.0 (which MIDP
1.0 is built on top of) didn't help the job.

In MIDP 2.0, there's an optional package called Mobile 3D Graphics API,
or JSR 184. The API is the first Java-specific standard for three-dimensional
graphics on mobile devices. The API has both high-level and low-level graphics
features; the high-level feature is called retained mode, and the
low-level one is called immediate mode. Retained mode makes it possible
for developers to use scene graphs, and the world renders itself based on the
positions of virtual cameras and lights. Immediate mode allows applications to
draw the objects directly. Both of the modes can be used in the same application
if necessary.

This article focuses on immediate mode (in the next article we'll have a
look at retained mode).

3D API

Let's start by listing and explaining the classes in the 3D API. In
addition to the API, the JSR 184 also contains a scene graph structure and a
corresponding file format for managing and deploying 3D content efficiently. The
file format defines m3g files, which typically are transformed from 3D modeling
applications.

Table 1. 3D API Classes

Class

Description

AnimationController

Controls the animation sequence.

AnimationTrack

Associates a KeyframeSequence with an AnimationController.

Appearance

A set of objects that defines the rendering attributes of a Mesh or a
Spring3D.

Background

Defines how the viewport is cleared.

Camera

A scene graph node that defines the position of the viewer in the scene and
the projection from 3D to 2D.