Game programming
This presentation is the property of its rightful owner.
Sponsored Links
1 / 39

Game Programming PowerPoint PPT Presentation


  • 97 Views
  • Uploaded on
  • Presentation posted in: General

Game Programming. Loading assets, Materials, Lighting & Shading, Camera, Game Loop , Input Handling. Informatics Engineering University of Brawijaya. Eriq Muhammad Adams J. [email protected] Agenda. Loading assets Materials Lighting & Shading Camera Game Loop Input Handling

Download Presentation

Game Programming

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Game programming

Game Programming

Loading assets, Materials, Lighting & Shading, Camera, Game Loop, Input Handling

Informatics Engineering

University of Brawijaya

Eriq Muhammad Adams J.

[email protected]


Agenda

Agenda

Loading assets

Materials

Lighting & Shading

Camera

Game Loop

Input Handling

Sky

Demo


Loading assets

Loading Assets

  • JME3 comes with a handy asset manager that helps you keep your assets structured.

    • assets/Interface/

    • assets/MatDefs/

    • assets/Materials/

    • assets/Models/

    • assets/Scenes/

    • assets/Shaders/

    • assets/Sounds/

    • assets/Textures/

    • build.xml

    • src/...

    • dist/...


Loading assets cont

Loading Assets (cont.)

Add box image texture “BrickWall.jpg”

Loading Textures


Loading assets cont1

Loading Assets (cont.)

Load default font

Loading Texts and Fonts


Loading assets cont2

Loading Assets (cont.)

Load Ogre Model

Loading an Ogre XML Model


Loading assets cont3

Loading Assets (cont.)

Load Local Zip File

Load Zip File via HTTP

Loading Assets From Custom Paths


Loading assets cont4

Loading Assets (cont.)

Ogre XML (.mesh.xml) and JME Binary (.j3o) Model included with Materials included

.obj model didn’t came with materials

Load models with materials

Load models without materials


Loading assets cont5

Loading Assets (cont.)

Load ogre scene

  • Load Ogre Scene

  • How to export OgreXML scenes from Blender to JME:

  • https://docs.google.com/fileview?id=0B9hhZie2D-fENDBlZDU5MzgtNzlkYi00YmQzLTliNTQtNzZhYTJhYjEzNWNk&hl=en


Materials

Materials

Default Materials Definition (in jme/core-data/Common)


Materials cont

Materials (cont.)

Create Unshaded Material

Simple Unshaded Texture


Materials cont1

Materials (cont.)

Create Unshaded Material

Activate Transparency

Transparent Unshaded Texture


Materials cont2

Materials (cont.)

You have to use lit material to get nice looks. n a lit material, the standard texture layer is referred to as Diffuse Map, any material can have it. A lit material can additionally have lighting effects such as Shininess used together with the Specular Map layer, and even a realistically bumpy or cracked surface with help of the Normal Map layer.


Materials cont3

Materials (cont.)


Materials cont4

Materials (cont.)

Create Lighting Material

Set Diffuse Map Texture

Set Normal Map Texture

Set Shininess


Lighting shading

Lighting & Shading

Create Point Light

JME 3 has three types of light : point light, ambient light, directional light, and spot light.

A PointLight has a location and shines from there in all directions as far as its radius reaches, like a lamp. The light intensity decreases with increased distance from the light source.


Lighting and shading cont

Lighting and Shading (cont.)

Create Directional Light

A DirectionalLight has no position, only a direction. It is considered “infinitely” far away and sends out parallel beams of light. It can cast shadows. You typically use it to simulate sun light.


Lighting and shading cont1

Lighting and Shading (cont.)

Create

Ambient Light

An AmbientLight influences the brightness of the whole scene globally. It has no direction and no location, and does not cast any shadow.

SpotLight is WIP (Work In Progress) …


Lighting and shading cont2

Lighting and Shading (cont.)

Switch Off default Shadow and Add BasicShadowRenderer Scene Processor

BasicShadowRenderer, Use the Shadow Renderer to make textured scene nodes cast and receive shadows.

http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestShadow.java


Lighting and shading cont3

Lighting and Shading (cont.)

Then you need set shadows for every scene that need shadows


Lighting and shading cont4

Lighting and Shading (cont.)

PSSM shadow renderer, The PSSM shadow renderer can cast real-time shadows on curved surfaces. To activate it, add a jMESceneProcessor named com.jme3.shadow.PssmShadowRenderer to the viewPort


Lighting and shading cont5

Lighting and Shading (cont.)

  • You can set the following properties on the pssmRenderer object:

    • setDirection(Vector3f) – the direction of the light

    • setLambda(0.65f) – Factor to use to reduce the split size

    • setShadowIntensity(0.7f) – shadow darkness (1 black, 0 invisible)

    • setShadowZextend() – distance how far away from camera shadows will still be computed

  • Then you need set shadows for every scene that need shadows

  • http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestPssmShadow.java


Camera

Camera

  • JME 3 have 3 types of built-in camera : Default Camera, FlyBy Camera, Chase Camera.

  • Default Camera, The default com.jme3.renderer.Camera object is cam in com.jme3.app.Application. Has default settings.

  • Width and height are set to the current Application's settings.getWidth() and settings.getHeight() values.

  • Frustum Perspective:

    • Frame of view angle of 45° along the Y axis

    • Aspect ratio of width divided by height

    • Near view plane of 1 wu

    • Far view plane of 1000 wu

    • Start location at (0f, 0f, 10f).

    • Start direction is looking at the origin.


Camera cont

Camera (cont.)


Camera cont1

Camera (cont.)

FlyBy Camera, The flyby camera is an extension of the default camera in com.jme3.app.SimpleApplication. It is preconfigured to respond to the WASD keys for walking forwards and backwards, and for strafing to the sides. Move the mouse to rotate the camera, scroll the mouse wheel for zooming in or out. The QZ keys raise or lower the camera.


Camera cont2

Camera (cont.)


Camera cont3

Camera (cont.)

Chase Camera, jME3 also supports a Chase Cam that can follow a moving target Spatial (com.jme3.input.ChaseCamera).


Camera cont4

Camera (cont.)

Multiple Camera Views, You can split the screen and look into the 3D scene from different camera angles at the same time. In this example, we create four views (2×2) with the same aspect ratio as the normal view, but half the size.


Camera cont5

Camera (cont.)

Setup first view

Setup 2nd – 4th view


Camera cont6

Camera (cont.)

Resizing and positioning viewport.

See TestMultiViews.java


Game loop

Game Loop

  • Initialization (simpleInit())

  • If exit is requested, then cleanup and destroy

  • Input handling (listeners)

  • Update game state

    • Application States update

    • User update (simpleUpdate() method)

    • Entity logical update (Custom Controls)

  • render

    • Application States rendering

    • Scene rendering

    • User rendering (simpleRender() method)

  • Repeat (goto 2)


Input handling

Input Handling

3 types input handling that JME 3 support : Keyboard, Mouse, and Joystick.

Type of Trigger :


Input handling cont

Input Handling (cont.)


Input handling cont1

Input Handling (cont.)

One trigger One Action

Multiple Trigger

One Action

Add trigger mapping


Input handling cont2

Input Handling (cont.)

  • Create Listeners, JME 3 has 2 type of listeners :

    com.jme3.input.controls.AnalogListener

    Use for continuous and gradual actions.

    Examples: Walk, run, rotate, accelerate vehicle, strafe, (semi-)automatic weapon shot

    JME gives you access to:

    the name of the triggered action.

    a gradual value between 0-9 how long the key has been pressed.

    com.jme3.input.controls.ActionListener

    Use for absolute “pressed or released?”, “on or off?” actions.

    Examples: Pause/unpause, a rifle or revolver shot, jump, click to select.

    JME gives you access to:

    the name of the triggered action.

    a boolean whether the key is still pressed or has just been released.


Input handling cont3

Input Handling (cont.)

Register Mappings to Listeners, To activate the mappings, you must register them to the Listener.


Input handling cont4

Input Handling (cont.)

Implements Action


Game programming

Sky

To Create Sky Box set sphere boolean value to false

You can use any Node as sky, even complex sets of geometries and quads with animated clouds, blinking stars, city skylines, etc. But, if you want a simple method use SkyFactory in JME 3.


Game programming

Demo

DemoScene.zip


  • Login