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

Eriq Muhammad Adams J. [email protected]@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Embed Size (px)

Citation preview

Page 1: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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

InformaticsUniversity of Brawijaya

Page 2: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Hello JMonkeyEngine 3.0 3D Math Scenegraph

Agenda

Page 3: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Hello JMonkeyEngine 3.0 (cont.)

Page 5: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Hello JMonkeyEngine 3.0 (cont.)

Start applicatio

n

Start applicatio

n

Extends SimpleApplicat

ion

Extends SimpleApplicat

ion

Initialization (resources creation )

Initialization (resources creation )

Page 6: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

3D Math (cont.)

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

Page 12: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

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

Scenegraph

Page 15: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Scenegraph (cont.)

Page 16: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Scenegraph (cont.)

Page 17: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Scenegraph (cont.)

Create Blue

Cube

Create Blue

Cube

Create Red

Cube

Create Red

Cube

Create Node

“Pivot”

Create Node

“Pivot”

Attach blue &

red cube to pivot

node

Attach blue &

red cube to pivot

node

Rotate Pivot Node

Rotate Pivot Node

Page 18: Eriq Muhammad Adams J. eriq.adams@ub.ac.ideriq.adams@ub.ac.id | ://eriq.lecture.ub.ac.id Informatics University of Brawijaya

Scenegraph (cont.)

Root Node

Pivot Node

Red Cube Blue Cube