Execution Requirements

As a minimum environment, the examples from the book require CLDC 1.1, MIDP 2.0, and M3G 1.0. The examples are also compatible with M3G 1.1.

If you are unsure whether your phone meets these requirements, the best starting point is the manufacturer's or operator's developer Web site. Also check out Web sites that list common properties of Java devices such as Sun's Java ME Device Table and the device database at J2ME Polish. If you already own a device or have access to it, you can query Java's system properties to check for M3G support. The application from Chapter 3 (JAD/JAR, 2 KB) is a quick way to do so.

On Windows XP, you can execute the examples with Sun's Java Wireless Toolkit (WTK). The WTK supports M3G 1.0 since version 2.2 and M3G 1.1 since version 2.5 Beta. The example in Appendix B needs a special emulator that supports MascotCapsule V3 API, such as the SDK from Sony Ericsson. Appendix C (Java Binding for the OpenGL ES API, JSR 239) requires the WTK 2.5 Beta 2 version or higher.

The screen shots on this page were taken with the WTK 2.5 Beta 2 (DefaultColorPhone) and Sony Ericsson's SDK 2.2.3 (S700, Appendix B only). In both cases, the color resolution was set to 16 bit. Depending on the graphical capabilities of your execution environment, the visual quality of the examples might be better or worse than what's displayed here.

Installation

To download the applications directly to your device, send the link to the application's JAD file to your phone or type the URL into the browser of your mobile phone. You can also use this low-res page as an index to the examples. Installing over the air requires you to have a properly set up network connection for your mobile phone's browser. Alternatively, download the JAD and JAR file to your computer and install the files offline.

All Examples

All examples (except appendixes) in one application: JAD/JAR (555 KB)

Part I: Overview

Chapter 2: Hello, World!

JAD/JAR (8 KB), Javadoc

Hello, World!

m3g02.HelloWorldSample
Animates a three-dimensional Hello, World! text that's stored in a binary file.

Chapter 3: Before You Start

M3G support: JAD/JAR (2 KB), Javadoc
System properties: JAD/JAR (9 KB), Javadoc

M3G support

m3g03.midp1.Main
Test application to find out whether a phone supports M3G.

M3G properties

m3g03.midp2.M3gProperties
Displays M3G properties obtained from Graphics3D.getProperties().

MIDP properties

m3g03.midp2.MidpProperties
Displays MIDP properties.

GameCanvas key states

m3g03.midp2.GameCanvasKeyStates
Displays key states read from GameCanvas.getKeyStates().

Canvas key events

m3g03.midp2.CanvasKeyEvents
Displays key events received from Canvas.keyPressed().

Part II: 3D Fundamentals

Chapter 4: Rendering Geometric Objects

JAD/JAR (81 KB), Javadoc

Colored geometry

m3g04.ColoredGeometrySample
Sample displaying a cube with per-vertex colors.

Geometric shapes

m3g04.GeometricShapesSample
Sample displaying different meshes. Also see mesh classes in the m3g04.mesh package.

Chapter 5: Transformations

JAD/JAR (32 KB), Javadoc

Model transformations

m3g05.ModelTransformationsSample
Sample displaying a cube that can be transformed interactively.

View transformations

m3g05.ViewTransformationsSample
Demonstrates switching between portrait and landscape rendering by changing the camera transformation.

Projection

m3g05.ProjectionSample
Sample demonstrating parallel and perspective projection.

Depth buffer

m3g05.DepthBufferSample
Sample demonstrating depth buffer and projection.

Wireframe

m3g05.WireframeSample
Demonstrates manual transformation of vertices by displaying wireframe objects. Also see m3g05.WireframeEngine.

Chapter 6: Textures

Describes how you can wrap an image around a mesh to create realistically looking models.
JAD/JAR (118 KB), Javadoc

Image2D types

m3g06.Image2DTypesSample
Loads PNG images with different color types and transparency combinations by using Loader.load() and displays the resulting Image2D pixel format.

Texturing

m3g06.TexturingSample
Displays different shapes with textures and allows changing texture parameters interactively.

Environment mapping

m3g06.EnvironmentMappingSample
Demonstrates environment mapping. Also see m3g06.EnvironmentMap.

Chapter 7: Blending and Transparency

JAD/JAR (82 KB), Javadoc

Compositing

m3g07.CompositingSample
Demonstrates compositing with different blending modes.

Fog

m3g07.FogSample
Sample demonstrating fog.

Emboss effect

m3g07.EmbossingSample
Demonstrates embossing. See also m3g07.EmbossEffect.

Chapter 8: Lighting

JAD/JAR (67 KB), Javadoc

Lighting

m3g08.LightingSample
A sphere lit with different light sources.

Materials

m3g08.MaterialsSample
Demonstrates how different materials change the look of a mesh.

Emulating light

m3g08.EmulatingLightSample
Shows alternatives to real lighting.

Part III: Advanced Topics

Chapter 9: Scene Graphs

JAD/JAR (85 KB), Javadoc

Scene graph

m3g09.SceneGraphSample
Uses a scene graph tree to structure a hierarchy of 3D objects.

Picking

m3g09.PickingSample
Picks meshes in viewport coordinates.

Billboards

m3g09.BillboardSample
This sample displays a field of flowers to demonstrate two alternative billboard techniques.

Chapter 10: M3G's File Format

JAD/JAR (110 KB), Javadoc

M3G files

m3g10.M3gFileSample
Loads 3D models from M3G files that were created with Blender.

User data

m3g10.UserDataSample
Memory game that uses information serialized in a model's user data. Also see UserData, Card, and CardDeck in the m3g10 package as well as m3g_export_06_userdata.py.

Chapter 11: Keyframe Animations

JAD/JAR (47 KB), Javadoc

Simple animation

m3g11.AnimationSample
Simple animation with different interpolation modes.

Texture animation

m3g11.TextureAnimationSample
Displays a scene with UV animations. See also m3g11.UvAnimation.

Chapter 12: Dynamic Meshes

JAD/JAR (47 KB), Javadoc

Morphing mesh

m3g12.MorphingSample
Defines an animation that blends mesh shapes into each other by using morphing.

Skinned mesh

m3g12.SkinnedMeshSample
SkinnedMesh animation that bends a skeleton with an adjustable number of bones. See also m3g12.Quaternion.

Animated robot

m3g12.RobotSample
Displays a walking robot that can be controlled with the game keys.

Appendixes

Appendix B: MascotCapsule V3 API

JAD/JAR (54 KB), Javadoc

MascotCapsule V3

m3gab.MascotSample
Demonstrates 3D rendering using the MascotCapsule V3 API.

Appendix C: Java Binding for the OpenGL ES API

JAD/JAR (38 KB), Javadoc

Java Binding for the OpenGL ES API

m3gac.OpenGLSample
Demonstrates 3D rendering using the Java Binding for the OpenGL ES API (JSR 239).