Sun Microsystems J2ME manual Retained Mode, Trading Quality for Speed

Models: J2ME

1 134
Download 134 pages 62.02 Kb
Page 80
Image 80

For an example of immediate mode, see the Life3D MIDlet in the Demo3D example application.

9.3Retained Mode

Most applications, particularly games, will use the retained mode or scene graph API. In this approach, a graphic designer or artist uses 3D modeling software to create a scene graph. The scene graph is saved in the JSR 184 file format. The scene graph file is bundled with the application. At runtime, the application uses the scene graph API to load and display the file.

Applications can manipulate parts of a loaded scene graph to animate characters or create other effects. The basic strategy is to do as much work as possible in the modeling software. At runtime, the application can grab and manipulate parts of the scene graph, which can also include paths for animation or other effects.

For an example of retained mode, see the retainedmode MIDlet in the Demo3D example application.

9.4Trading Quality for Speed

One of the challenges of MIDP development is the constrained environment of typical devices. Compared to desktop computers, MIDP devices have slow processors and little memory. These challenges extend into the arena of 3D graphics. To accomodate a wide variety of implementations, the JSR 184 specification provides various mechanisms to make the display of a 3D scene as efficient as possible.

One approach is scoping, a technique where you tell the 3D graphics implementation when objects are not going to interact with each other. For example, if you defined a scene graph for a house, you could use scoping to specify that the light in the basement doesn’t affect the appearance of the bedroom on the second floor. Scoping makes the implementation’s job easier by reducing the number of calculations required to show a scene.

In general, however, the best way to improve the rendering speed of 3D scenes is to make some compromises in quality. The Mobile 3D Graphics API includes rendering hints so that applications can suggest how the implementation can compromise quality to improve rendering speed.

68 J2ME Wireless Toolkit User’s Guide • October 2004

Page 80
Image 80
Sun Microsystems J2ME manual Retained Mode, Trading Quality for Speed