Home > Articles > Programming > Java

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

  • Print
  • + Share This
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

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.

CompositingMode

An Appearance class that encapsulates per-pixel compositing attributes.

Fog

An Appearance class that contains attributes for fogging.

Graphics3D

A singleton 3D graphics context. All rendering is done through the render() methods in this class.

Group

A scene graph node that stores an unordered set of nodes as its children.

Image2D

A two-dimensional image that can be used as a texture, background, or sprite image.

IndexBuffer

The class defines how to connect vertices to form a geometric object.

KeyframeSequence

Encapsulates animation data as a sequence of time-stamped, vector-valued keyframes.

Light

Represents different kinds of light sources.

Loader

Downloads and deserializes graph nodes and node components, as well as entire scene graphs.

Material

Encapsulates material attributes for lighting computations.

Mesh

Represents a 3D object defined as a polygonal surface.

MorphingMesh

Represents a vertex-morphing polygon mesh.

Node

An abstract class for all scene graph nodes. The five kinds are Camera, Mesh, Sprite3D, Light, and Group.

Object3D

An abstract base class for all objects that can be part of a 3D world.

PolygonMode

Encapsulating polygon-level attributes.

RayIntersection

Stores a reference to an intersected Mesh or Sprite3D and information about the intersection point.

SkinnedMesh

Represents a skeletally animated polygon mesh.

Sprite3D

Represents a 2D image with a 3D position.

Texture2D

Encapsulates a 2D texture image and a set of attributes specifying how the image is to be applied on submeshes.

Transform

A generic 4x4 floating-point matrix representing a transformation.

Transformable

An abstract base class for Node and Texture2D.

TriangleStripArray

Defines an array of triangle strips.

VertexArray

An array of integer vectors representing vertex positions, normals, colors, or texture coordinates.

VertexBuffer

Holds references to VertexArrays that contain the positions, colors, normals, and texture coordinates for a set of vertices.

World

A special group node that is a top-level container for scene graphs.

  • + Share This
  • 🔖 Save To Your Account