Top Banner
iq Muhammad Adams J. [email protected] | http://eriq.lecture.ub.ac.id Informatics University of Brawijaya
18

Game Programming

Mar 21, 2016

Download

Documents

catrin

Game Programming. 3D Scenegraph. Informatics University of Brawijaya. Eriq Muhammad Adams J. [email protected] | http://eriq.lecture.ub.ac.id. Agenda. Hello JMonkeyEngine 3.0 3D Math Scenegraph. Hello JMonkeyEngine 3.0 (cont.). - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Game Programming

Eriq Muhammad Adams [email protected] | http://eriq.lecture.ub.ac.id

InformaticsUniversity of Brawijaya

Page 2: Game Programming

Hello JMonkeyEngine 3.0 3D Math Scenegraph

Agenda

Page 3: Game Programming

You can extends com.jme3.app.SimpleApplication to build JMonkey apps.

SimpleApplication provide us default camera input. simpleInitApp() is used for game initialization. to start app you can call start() from your main(). rootNode is top node in JME scenegraph. Lets look the code at jme3test.helloworld.HelloJME http://jmonkeyengine.org/wiki/doku.php/

jme3:beginner:hello_simpleapplication

Hello JMonkeyEngine 3.0 (cont.)

Page 4: Game Programming

Hello JMonkeyEngine 3.0 (cont.)

Page 5: Game Programming

Hello JMonkeyEngine 3.0 (cont.)

Start applicatio

n

Extends SimpleApplicat

ion

Initialization (resources creation )

Page 6: Game Programming

JME uses right-handed coordinated system (as OpenGL does).

3D Math

Coordinate defined as com.jme3.math.Vector3f (x,y,z)

Origin coordinate is (0,0,0) Unit measurement is wu

(world unit), typically 1 wu is 1 meter.

Page 7: Game Programming

Transformation : operation that converts points from one coordinate system to another includes rotation, scaling, translation.

Local transforms represent the positioning of objects relative to a parent coordinate system.

Global transforms represent the positioning of objects in a global coordinate system.

JME 3.0 provide us low-level transformation functionality.

3D Math (cont.)

Page 8: Game Programming

Visibility Determination concerns itself with minimizing the amount of data that is sent to the graphics card for rendering.

Not all data being sent to graphics card but data which we can see are being sent.

Data not sent to is said to be culled. Fustrum Culling is the procedure for visibility determination. The BoundingVolume of an object is tested against the

frustum planes to determine if it is contained in the frustum. If at any point the object's bounding is outside of the plane, it is tossed out and no longer processed for rendering.

3D Math (cont.)

Page 9: Game Programming

View Fustrum Culling : the process of removing objects that lie completely outside the viewing frustum from the rendering process (wikipedia)

3D Math (cont.)

Page 10: Game Programming

Fundamental Types in JME 3.0 : ColorRGBA, Matrix (Matrix 3f, Matrix4f), Vector (Vector2f, Vector3f).

ColorRGBA defines a color value (red, green, blue, alpha).

Matrix typically used as linear transformations (scale, rotate, translate) to map vectors to vectors.

Matrix3f is a 3×3 matrix and is the most commonly used (able to handle scaling and rotating), while Matrix4f is a 4×4 matrix that can also handle translation.

3D Math (cont.)

Page 11: Game Programming

3D Math (cont.)

Source : New Riders, Beginning Math and Physics for Game Programmers

Page 12: Game Programming

Vectors are used to represent a multitude of things in jME, points in space, vertices in a triangle mesh, normals, etc. These classes (Vector3f in particular) are probably the most used class in jME.

Quaternions define a subset of a hyper complex number system. Quaternions are defined by (i2 = j2 = k2 = i j k = -1). jME makes use of Quaternions because they allow for compact representations of rotations, or correspondingly, orientations, in 3D space. With only four float values, we can represent an object's orientation, where a rotation matrix would require nine. They also require fewer arithmetic operations for concatenation.

3D Math (cont.)

Page 13: Game Programming

For more math tutorials in JME please learn JME math for dummies presentation at http://jmonkeyengine.org/wiki/doku.php/jme3:math_for_dummies

3D Math (cont.)

Page 14: Game Programming

Represents your 3D world. Object in JME scenegraph are called spatial.

Scenegraph

Page 15: Game Programming

Scenegraph (cont.)

Page 16: Game Programming

Scenegraph (cont.)

Page 17: Game Programming

Scenegraph (cont.)

Create Blue

Cube

Create Red

Cube

Create Node

“Pivot”

Attach blue &

red cube to pivot

nodeRotate Pivot Node

Page 18: Game Programming

Scenegraph (cont.)

Root Node

Pivot Node

Red Cube Blue Cube