Download Intro to JME

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Intro to Java Monkey Engine
Download JME SDK @
http://hub.jmonkeyengine.org/down
loads/
JME Technology
• JME stands for the java monkey engine: a game engine written in
java and built upon LWJGL (light-weight java GL -- a java binding for
OpenGL)
– OpenGL is a platform independent library for 2D and 3D graphics.
– For our purposes, OpenGL is far too low-level for the kinds of
graphics programming we'd like to accomplish
• OpenGL concerns itself with fast, often hardware accelerated,
rendering of basic geometric primitives)
– We appeal to a game engine to provide additional high-level
functionality
• Note: JME provides audio capability via OpenAL support. JME
supports Ogg Vorbis (.ogg) and uncompressed PCM Wave (.wav)
formats.
– We can use Audicity (http://audacity.sourceforge.net/) to convert
other formats to these
Game-Level Objects
• Main Application (SimpleApplication) - A base class from which the
custom game inherits
– Provides method hooks (i.e., callbacks) to initialize a game
(simpleInitApp) update game (simpleUpdate) objects and re-display
(simpleRender) objects.
– InputManager - A class to manage all device input (e.g., keyboard,
mouse, joystick) and present that input to the application for
handling.
– Display - A class to insulate the game from the device specific
characteristics of platform on which the game is being run. The
Display also encapsulates the features of window management.
– Renderer - An abstraction of the OpenGL state and rendering
pipeline as discussed in class. OpenGL is a state-driven system.
That is, you define a graphics state as a set of rendering attributes
and then send a sequence of geometric data to the renderer which
then is drawn subject to the current attributes.
– The three classes above are referred collectively as the JME context.
The Main Game Loop
Game-Level Objects (cont)
• Main Application (SimpleApplication) - A base class from which the
custom game inherits
– Scene Graph - A class to manage the objects in the scene
– Camera - A class to encapsulate the eye position and its attributes
(e.g., field of view, depth of field, up vector, etc.).
– Math Library for 3D Graphics (functions to handle vectors,
matrices, geometric data, collisions, etc.).
– Model Importers - A fully featured game engine provides for
importing mesh models from any of several different modeling
programs.
The Scene Graph
• A grouping of Nodes in a tree hierarchy according
(most of the time) to spatial location.
• Spatially because …
–
–
–
–
Game objects are typically located by location
Allows for fast culling
Tree structure natural for many game objects
Easy to express, create tools for this data structure
• Spatial is an abstract class allowing uniform treatment
of:
– Node (internal, invisible, grouping class, transformable)
– Geometry (leaf, visible—mesh and material—
transformable).
Beginning a Project
In the jMonkeyEngine SDK:
• Choose File→New Project… from the main menu.
• In the New Project wizard, select the template
JME3→Basic Game. Click Next.
– Specify a project name, e.g. "HelloWorldTutorial"
– Specify a path where to store your new project, e.g. a
jMonkeyProjects directory in your home directory.
•
Click Finish.
Understanding the JME App Structure
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
Understanding the JME App Structure
public class Main extends SimpleApplication {
.
@Override
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, “…");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
Understanding the JME App Structure
public class Main extends SimpleApplication {
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
Typical Game Objects
• Spatial: Spatials are abstract and exist to
allow handling of the Nodes and Geometry
uniformly.
– Node (internal, i.e. has children) contains
transformations and links to children (no
Mesh or Material--invisible)
– Geometry (leaf) contains transformations
and visible characteristics, i.e., Mesh and
Material
Typical Game Objects
– Geometry (leaf) contains transformations
and visible characteristics, i.e., Mesh and
Material
• Mesh
• Material
–Color (Ambient, Diffuse, Emmisive, Specular)
- Base color of an object that is not
influenced by a color map
–Texture
»Color Map
»Specular Map
»Bump Map (Height Map, Normal Map)
Typical Game Objects
• Distinguished Spatials
– rootNode
– Camera
Getting Started
One of the better ways to learn what you can do
in JME is to:
• Examine the JME Tests
• Complete the JME "Tutorial Series
(http://hub.jmonkeyengine.org/wiki/doku.ph
p/jme3:beginner)