Java Reference
In-Depth Information
The
.m3g
file that you will need is called
pogoroo.m3g
. You can find it at the following path:
<WTK 2.2 inst. dir.>/apps/Demo3D/res/com/superscape/m3g/wtksamples/pogoroo/content
Copy this
.m3g
file to the
res
directory of the
RMMIDlet
project.
Now build and run the MIDlet. You will see a 3D kangaroo jumping up and down in front
of you. Use the navigation keys on the phone emulator to move the camera around the kangaroo's
world. Figure 15-10 shows the
RMMIDlet
in action.
Figure 15-10.
Interacting with a retained mode 3D world
The custom
GameCanvas
subclass in this MIDlet is called
RetainedCanvas
. The source code
for
RetainedCanvas
is shown in Listing 15-4.
Listing 15-4.
RetainedCanvas for Interacting with a Retained Mode 3D World
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.*;
import javax.microedition.m3g.*;
class RetainedCanvas extends GameCanvas implements Runnable {
private boolean mRunning = false;
private Thread mPaintThrd = null;
private Graphics3D mGraphics3D = Graphics3D.getInstance();
private World mWorld = null;
private Camera mCam = null;
private long mWorldStartTime = 0;
public RetainedCanvas() {
super(true);
}
Search WWH ::
Custom Search