Home > Articles > Programming > Java

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

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Beginning Mobile Phone Game Programming

Like this article? We recommend
Beginning Mobile Phone Game Programming

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.

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 ThisShare This
  • Your Account

Discussions

Make a New Comment

You must log in in order to post a comment.

Related Resources

Jennifer  BortelWin FREE iPhone Developer Books and Videos- Introducing @InformIT Giveaways
By Jennifer Bortel on February 5, 2010 No Comments

Apples’s recent iPad announcement made our hearts flutter so we couldn’t resist making an announcement of our own!

Today marks the first ever @InformIT Giveaway!

We’ll regularly post a video like this one profiling spectacular prizes we’re giving away—from books and videos to T-shirts and other exciting stuff. Check out the video below to see the giveaways for today, and then scroll down for more prize details and instructions on how to win them!

Dustin Sullivan"Every OSX developer should have this book on their desk."
By Dustin Sullivan on February 1, 2010 No Comments

That was the sentence Mike Riley ended his recent Dr Dobb's CodeTalk review of Cocoa Programming Developer's Handbook with.

David ChisnallCocoa Tip of the Day, 1/29/10
By David Chisnall on January 29, 2010 No Comments

Don't ignore old versions of OS X.

See All Related Blogs

Informit Network