|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.microedition.lcdui.Displayable
javax.microedition.lcdui.Canvas
javax.microedition.lcdui.game.GameCanvas
m3g12.RobotSample
public class RobotSample
Displays a walking robot that can be controlled with the game keys.
| Field Summary | |
|---|---|
private javax.microedition.m3g.AnimationController |
controller
The robot's animation controller. |
private static int |
DATA_DISTANCE
State data index for walking distance. |
private static int |
DATA_DURATION
State data index for animation duration. |
private static int |
DATA_FALSE_STATE
State data index for next state if key was not pressed. |
private static int |
DATA_KEY
State data index for key to move to the next state. |
private static int |
DATA_SPEED
State data index for animation speed. |
private static int |
DATA_START
State data index for animation start time. |
private static int |
DATA_TRUE_STATE
State data index for next state if key was pressed. |
private float |
direction
Current walking direction. |
private javax.microedition.lcdui.Graphics |
graphics
2D graphics singleton used for rendering. |
private javax.microedition.m3g.Graphics3D |
graphics3d
3D graphics singleton used for rendering. |
private boolean |
isRunning
Flag for stopping the animation thread. |
private static java.lang.String |
M3G_FILE
File that stores the scene graph. |
private javax.microedition.m3g.SkinnedMesh |
mesh
Robot. |
private javax.microedition.m3g.Group |
position
The robot's position. |
private int |
state
Current state. |
private static int[][] |
STATE_DATA
State data. |
private static int |
STATE_IDLE
State index for idle state. |
private static int |
STATE_INVALID
State index for invalid state. |
private static int |
STATE_STARTING
State index for starting state. |
private static int |
STATE_STOPPING
State index for stopping state. |
private static int |
STATE_WALKING
State index for walking state. |
private int |
stateTime
Time since last state update. |
private javax.microedition.m3g.Transform |
transform
Helper object for transformation. |
private static int |
USER_ID_MESH
User ID to find the mesh inside the scene graph. |
private javax.microedition.m3g.World |
world
Object that represents the 3D world. |
| Fields inherited from class javax.microedition.lcdui.game.GameCanvas |
|---|
DOWN_PRESSED, FIRE_PRESSED, GAME_A_PRESSED, GAME_B_PRESSED, GAME_C_PRESSED, GAME_D_PRESSED, LEFT_PRESSED, RIGHT_PRESSED, UP_PRESSED |
| Fields inherited from class javax.microedition.lcdui.Canvas |
|---|
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP |
| Constructor Summary | |
|---|---|
RobotSample()
Constructor. |
|
| Method Summary | |
|---|---|
private void |
changeState(int state,
int worldTime,
int error)
Changes state and updates the animation position. |
void |
destroy()
Destroys the sample. |
private void |
drawMenu(javax.microedition.lcdui.Graphics graphics)
Draws a menu for the current key assignments. |
private int |
getData(int index)
Returns data for the current state. |
void |
init()
Initializes the sample. |
private void |
process(int worldTime,
int stateDelta)
Checks for key presses and advances the state machine. |
protected void |
render(javax.microedition.lcdui.Graphics graphics)
Renders the sample. |
void |
reset()
Initializes the sample. |
void |
run()
Animation loop. |
| Methods inherited from class javax.microedition.lcdui.game.GameCanvas |
|---|
flushGraphics, flushGraphics, getGraphics, getKeyStates, paint |
| Methods inherited from class javax.microedition.lcdui.Canvas |
|---|
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setCommandListener, setFullScreenMode, showNotify, sizeChanged |
| Methods inherited from class javax.microedition.lcdui.Displayable |
|---|
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setTicker, setTitle |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String M3G_FILE
private static final int USER_ID_MESH
private static final int STATE_INVALID
private static final int STATE_IDLE
private static final int STATE_STARTING
private static final int STATE_WALKING
private static final int STATE_STOPPING
private static final int[][] STATE_DATA
private static final int DATA_START
private static final int DATA_DURATION
private static final int DATA_SPEED
private static final int DATA_KEY
private static final int DATA_TRUE_STATE
private static final int DATA_FALSE_STATE
private static final int DATA_DISTANCE
private int stateTime
private int state
private javax.microedition.m3g.World world
private javax.microedition.m3g.SkinnedMesh mesh
private javax.microedition.m3g.AnimationController controller
private javax.microedition.m3g.Group position
private float direction
private javax.microedition.m3g.Transform transform
private boolean isRunning
private javax.microedition.m3g.Graphics3D graphics3d
private javax.microedition.lcdui.Graphics graphics
| Constructor Detail |
|---|
public RobotSample()
| Method Detail |
|---|
public void init()
init in interface Samplepublic void reset()
public void destroy()
destroy in interface Samplepublic void run()
run in interface java.lang.Runnableprivate int getData(int index)
index - type of state data.
private void changeState(int state,
int worldTime,
int error)
state - new state.worldTime - current world time.error - delta between the animation start and current
world time.
private void process(int worldTime,
int stateDelta)
worldTime - current world time.stateDelta - time since last state change.protected void render(javax.microedition.lcdui.Graphics graphics)
graphics - graphics context for drawing.private void drawMenu(javax.microedition.lcdui.Graphics graphics)
graphics - graphics context for drawing.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||