|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbluegammon.gui.Context3D
The 3d context used in this game. Consists of the scene which is a camera with one main headlight; and dice, string or piece objects. Also contains functionality for creating objects and defining materials. We only have one 3d context, thus the singleton pattern.
The dice and the piece is constructed mathematically based on the JSR184 specifications.
The piece is constructed from a number of predefined pie-slices. The greater amount of slices, the more circular piece - but also the amount of triangles per piece will increase, impacting the performance. Each piece consists of 4 * numberOfSlices triangles.
The dice is calculated using a somewhat more complicated model. Each dice consists of 6 * 6 faces + 8 corners = 44 triangles.
A graphical representation of how one face of the dice is calculated is depicted below:
Field Summary | |
static float |
FAR_CLIPPING_PLANE
Z-axis far clipping plane |
static float |
FOVY
Field of view, degrees on horizontal axis |
static float |
NEAR_CLIPPING_PLANE
Z-axis near clipping plane |
Constructor Summary | |
Context3D()
|
Method Summary | |
javax.microedition.m3g.Graphics3D |
bindScene(javax.microedition.lcdui.Graphics g)
Binds a graphics context and set up the common 3d environment used in this game. |
static int[] |
createShadowRGB(int size,
int sizeDim)
Creates an rgb buffer rendered a shadow that is transparant. |
javax.microedition.m3g.Appearance |
getDiceAppearance(boolean white)
Returns the appearance (texture and material) for a dice. |
javax.microedition.m3g.IndexBuffer |
getDiceIndexBuffer()
Returns index buffer for a dice. |
javax.microedition.m3g.VertexBuffer |
getDiceVertexBuffer()
Returns vertexbuffer for a dice. |
static Context3D |
getInstance()
Returns singleton instance. |
javax.microedition.m3g.Appearance |
getPieceAppearance(boolean white)
Returns the appearance (texture and material) for a piece. |
javax.microedition.m3g.IndexBuffer |
getPieceIndexBuffer()
Returns indexbuffer for a piece. |
javax.microedition.m3g.VertexBuffer |
getPieceVertexBuffer()
Returns vertexbuffer for a piece. |
float |
getShadowProjectionDeltaX(float deltaZ)
Returns delta x coordinate of shadow position given specified delta z between object and projection plane. |
javax.microedition.m3g.Texture2D |
getTexture(boolean white)
Returns the textures used within this game. |
void |
init(int width,
int height)
Sets up our viewport, camera, lighting - everyting needed for the scene |
float |
to3DCoordinateX(float coordinateScreen,
float z)
Recalculates a screen x coordinate to a 3d x coordinate. |
float |
to3DCoordinateY(float coordinateScreen,
float z)
Recalculates a screen y coordinate to a 3d y coordinate. |
float |
toScreenCoordinateX(float coordinate3D,
float z)
Recalculates a x 3d coordinate to a screen x coordinate. |
float |
toScreenCoordinateY(float coordinate3D,
float z)
Recalculates a 3d y coordinate to a screen y coordinate. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final float FOVY
public static final float NEAR_CLIPPING_PLANE
public static final float FAR_CLIPPING_PLANE
Constructor Detail |
public Context3D()
Method Detail |
public static Context3D getInstance()
public void init(int width, int height)
width
- The width of the viewportheight
- The height of the viewportpublic float toScreenCoordinateX(float coordinate3D, float z)
coordinate3D
- The 3d x coordinatez
- The depth of the 3d coordinate
public float to3DCoordinateX(float coordinateScreen, float z)
coordinateScreen
- The screen x coordinatez
- The depth of the 3d coordinate
public float toScreenCoordinateY(float coordinate3D, float z)
coordinate3D
- The 3d y coordinatez
- The depth of the 3d coordinate
public float to3DCoordinateY(float coordinateScreen, float z)
coordinateScreen
- The screen y coordinatez
- The depth of the 3d coordinate
public float getShadowProjectionDeltaX(float deltaZ)
deltaZ
- The difference in z between object
and shadow projecton plane.
public javax.microedition.m3g.Graphics3D bindScene(javax.microedition.lcdui.Graphics g)
g
- The graphics environment to render upon.
public static int[] createShadowRGB(int size, int sizeDim)
size
- Shadow sizesizeDim
- Blank border.
public javax.microedition.m3g.Appearance getPieceAppearance(boolean white)
white
- true for white appearance, false for black appearance.
public javax.microedition.m3g.Appearance getDiceAppearance(boolean white)
white
- true for white appearance, false for black appearance.
public javax.microedition.m3g.Texture2D getTexture(boolean white)
white
- true for white textures, false for black textures.
public javax.microedition.m3g.VertexBuffer getPieceVertexBuffer()
public javax.microedition.m3g.IndexBuffer getPieceIndexBuffer()
public javax.microedition.m3g.VertexBuffer getDiceVertexBuffer()
public javax.microedition.m3g.IndexBuffer getDiceIndexBuffer()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |