
|
November 2004 |
[Back] |
|
| |
|
We will show how to make two simple 3D MIDlets, one that uses the JSR 184 API and the other that uses the Micro3D version 3 API. The MIDlets demonstrate how to use both of these APIs to produce the same 3D animation. Because the example code uses immediate mode operations, no 3D content files are required.
The code in the "MIDletMain.java" and "SampleApp.java" files is identical; the file names were changed to prevent confusion. These files perform the standard MIDlet initialization and start a timer thread that implements the scene's animation. The initialization code next creates an instance of a custom Canvas. Its paint method makes 3D API calls that generate a cube and apply the image in "cubeface.png" or "cubeface.bmp" as a texture map onto its faces. The method also performs a matrix transformation that changes the cube's orientation slightly. The timer thread periodically calls the Canvas's repaint() method, which continues to change the cube's orientation and thus generates the rotation effect. These simple demos show that if the MIDlet is carefully designed, it is possible to substitute the code that makes JSR 184 API calls with the code that makes Micro3D version 3 calls without modifying the MIDlet's core logic. Download an example with source code>>
| |
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.