Java game programming. Game engines. Fayolle Pierre-Alain



Similar documents
Game Programming with Groovy. James Sr. Software Engineer, BT/Ribbit

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

CLOUD GAMING WITH NVIDIA GRID TECHNOLOGIES Franck DIARD, Ph.D., SW Chief Software Architect GDC 2014

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

JavaFX Session Agenda

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

Game Design From Concepts To Implementation

How To Teach Computer Graphics

Bachelor of Games and Virtual Worlds (Programming) Subject and Course Summaries

3D Application and Game Development With OpenGL

Abstractions from Multimedia Hardware. Libraries. Abstraction Levels

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

An evaluation of JavaFX as 2D game creation tool

Experiences with 2-D and 3-D Mathematical Plots on the Java Platform

CS 378: Computer Game Technology

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Beginning Android 4. Games Development. Mario Zechner. Robert Green

Ch 1: What is Game Programming Really Like? Ch 2: What s in a Game? Quiz #1 Discussion

WVU College of Engineering and Mineral Resources Proposal for Gaming Curriculum Undergraduate Minor and Graduate Certificate

Introduction to Computer Graphics

Masters of Science in Software & Information Systems

INTRODUCTION TO RENDERING TECHNIQUES

Course Overview. CSCI 480 Computer Graphics Lecture 1. Administrative Issues Modeling Animation Rendering OpenGL Programming [Angel Ch.

CURRICULUM VITAE EDUCATION:

Computer Animation and Visualisation. Lecture 1. Introduction

Advanced Rendering for Engineering & Styling

Board Games They are adaptations of classic board games. Examples of board games include Chess, Checkers, Backgammon, Scrabble and Monopoly.

Programming 3D Applications with HTML5 and WebGL

A Short Introduction to Computer Graphics

Performance Optimization and Debug Tools for mobile games with PlayCanvas

Game Programming with DXFramework

A Generic Rendering System

LibGDX játék fejlesztése és publikálása Google Play-en. Vörös Viktor, NNG

Chapter 6 - The Scene Graph

Dipartimento di Tecnologie dell Informazione Università di MIlano. Physics Engines LOGO

Lecture Notes, CEng 477

3D VIRTUAL DESKTOP APPLICATION Of UNSW. Introduction. What we propose to do 2/4. What we propose to do 1/4. What we propose to do 4/4

CSE 564: Visualization. GPU Programming (First Steps) GPU Generations. Klaus Mueller. Computer Science Department Stony Brook University

How To Understand The Power Of Unity 3D (Pro) And The Power Behind It (Pro/Pro)

Tec: A Cross-Platform Game Engine

Computer Graphics. Computer graphics deals with all aspects of creating images with a computer

Certified Game Developer

Software Evaluation Guide for Autodesk 3ds Max 2009* and Enemy Territory: Quake Wars* Render a 3D character while playing a game

Virtuelle Realität. Overview. Termin 9: Scene Graphs. Virtuelle Realität. Prof. Bernhard Jung

Games Development Education to Industry. Dr. Catherine French Academic Group Leader Games Programming, Software Engineering and Mobile Systems

MobiX3D: a player for displaying 3D content on mobile devices

3D web visualization of huge CityGML models

Game Development in Android Disgruntled Rats LLC. Sean Godinez Brian Morgan Michael Boldischar

Introduction Computer stuff Pixels Line Drawing. Video Game World 2D 3D Puzzle Characters Camera Time steps

Using WPF for Computer Graphics

Optimizing Unity Games for Mobile Platforms. Angelo Theodorou Software Engineer Unite 2013, 28 th -30 th August

Homeschool Programming, Inc.

3D Computer Games History and Technology

Institutionen för systemteknik Department of Electrical Engineering

Windows Presentation Foundation: What, Why and When

REMOTE RENDERING OF COMPUTER GAMES

Hardware design for ray tracing

Introduction to WebGL

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Friday 18 th January 2008.

1. INTRODUCTION Graphics 2

Building Interactive Animations using VRML and Java

lubyk lua libraries for live arts Gaspard Bucher (Buma)! artist, musician, coder

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

Introduction to NaviGenie SDK Client API for Android

C0600 Technical Report. Computer Animation in Java Emergent Behaviour in Autonomous Agents

DD1354. Christopher Peters. Sweden.

Lecture 1 Introduction to Android

The Car Tutorial Part 1 Creating a Racing Game for Unity

Outline. 1.! Development Platforms for Multimedia Programming!

Chapter 6 - The Scene Graph

Optimisation of a Graph Visualization Tool: Vizz3D

Parallel Web Programming

SOFTWARE ENGINEER. For Online (front end) Java, Javascript, Flash For Online (back end) Web frameworks, relational databases, REST/SOAP, Java/Scala

Research and Design of Universal and Open Software Development Platform for Digital Home

<Insert Picture Here> Java, the language for the future

NVPRO-PIPELINE A RESEARCH RENDERING PIPELINE MARKUS TAVENRATH MATAVENRATH@NVIDIA.COM SENIOR DEVELOPER TECHNOLOGY ENGINEER, NVIDIA

Chapter 2 - Graphics Programming with JOGL

Red Hat VDI. David Simmons

C O M P U C O M P T U T E R G R A E R G R P A H I C P S Computer Animation Guoying Zhao 1 / 66 /

Rally Sport Racing Game: CodeName Space Racer

GearVRf Developer Guide

Service-Oriented Visualization of Virtual 3D City Models

Haptics Don t Lose Touch with Virtual Reality. Petr Kmoch Computer Graphics Group MFF UK

4 Overview on Approaches to Multimedia Programming

Teaching Introductory Computer Graphics Via Ray Tracing

Remote Graphical Visualization of Large Interactive Spatial Data

Career Opportunities in Electronic Game & Simulation Design

The MaXX Desktop. Workstation Environment. Revised Road Map Version 0.7. for Graphics Professionals

An Instructional Aid System for Driving Schools Based on Visual Simulation

Cortona3D Viewer. User's Guide. Copyright ParallelGraphics

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

CARS Configurable Automotive Research Simulator

CS130 - Intro to computer graphics. Dr. Victor B. Zordan vbz@cs.ucr.edu Objectives

NVIDIA IndeX Enabling Interactive and Scalable Visualization for Large Data Marc Nienhaus, NVIDIA IndeX Engineering Manager and Chief Architect

Fundamentals of Computer Graphics

Develop Computer Animation

Computer Graphics on Mobile Devices VL SS ECTS

Dynamic Resolution Rendering

Generating Automated Test Scripts for AltioLive using QF Test

Transcription:

Java game programming Game engines 2010 Fayolle Pierre-Alain

Plan Some definitions List of (Java) game engines Examples of game engines and their use

A first and simple definition A game engine is a (complex) software system designed for the creation and development of video games It abstracts the (platform dependent) details of doing common game-related tasks Its core functionality (may) include: a rendering engine, a physics engine, a scene graph, a sound engine

Purpose of a game engine To provide a flexible and reusable software platform for game development It does so by providing all or part of the core functionality needed for a game This helps reducing: The complexity of game development The time-to-market Time-to-market is the length of time it takes from the conception of a product to its availability for sale The cost of development

Hardware / Platform abstraction Game engines usually provide platform abstraction (for example: game consoles and personal computers, Windows or Linux) Rendering engines are built upon graphics API such Direct3D or OpenGL providing a software abstraction to different video cards Input / sound engines may be built upon low level libraries such as DirectX or SDL providing software abstraction to input devices, network cards, or sound cards

Hardware abstraction Prior to hardware accelerated graphics, software renderers were used Software renderers may still be present in some rendering engines, e.g. to emulates features absent from some cards Physics engines may build on physics processing units (PPU) and their API and provide an abstraction of the PPU hardware

Component-based architecture Game engines are often designed with a component-based architecture that allows part of the system to be replaced with other components A component is a software package or a module encapsulating a set of functions (and / or data) Components communicate with each other through interfaces

History of game engines Historically games were designed from the ground up to make optimal use of limited hardware Early games for consoles and personal computers were mostly programmed in low-level language (assembly or C) and optimized for a particular hardware The term game engine gained popularity in the 90s with games such as Doom or Quake

History of game engine The concept of game engine was made popular with first person shooting (FPS) game where engine (program) and assets (texture, characters, etc) became clearly separated It allowed the same engine to be re-used with different scenarios and assets to produce different games Popular example is the Quake engine which was used in Quake, Half-life, Hexen II and other

Trends in game engine FPS games saw lots of progress on rendering engines: from wireframes to 3D world, (basic) graphics hardware acceleration, popularization of GPU, lighting and pixel shaders Progress on physics engine as well: rigid body dynamics, soft body dynamics (cloth), fluid dynamics New hardware / platform targets: mobile phones Usage of higher-level languages: C#, Java

Middleware A middleware is a software that resides between applications and the underlying operating systems, network protocol stacks, and hardware Middleware s role is to functionally bridge the gap between lower-level and applications Originally game engines were developed internally for reuse in future game of the company Then some companies started to sell them to provide another source of income (Id Software) Now some companies specialize only in developing and selling game engines (or part of it); the term middleware is used in this context

Example: DMM Engine Middleware physics engine developed by Pixelux Simulates a large sets of physical properties by using Finite Element Analysis instead of the classical rigid body kinematics Based on an algorithm developed by Prof. James O Brien in his PhD thesis: Graphical modeling and animation of fracture (Berkeley)

Taxonomy of game engines Game engines can be classified using different criteria: The type of game that can be developed with (FPS, MMORPG, simulation, ) The functionalities that are covered (rendering, physics) The platform that are supported (Linux / Windows, game console / personal computer) Commercial / Open source

List of (Java) game engine List limited to: open-source game engines and either written in Java language or providing bindings to the Java language Written in Java: Ardor3D (http://www.ardor3d.com/) jmonkeyengine (http://www.jmonkeyengine.com/home/) Jogre (http://jogre.sourceforge.net/main.htm) Lightweight Java Game Library (http://www.lwjgl.org/index.php)

Game engines with Java bindings Typically written in C++ Third party bindings for the Java language are provided (typically using JNI: Java Native Interface) Irrlicht Engine (http://www.irrlicht3d.org/wiki/) Crystal space (http://www.crystalspace3d.org/main/main _Page)

JOGRE Java Online Gaming Real-time Engine http://jogre.sourceforge.net/main.htm A client / server game engine allowing the creation of multi-player online games (ex: chess, go, ) Provide a set of packages to help developers with: rendering, network and communications, state manipulations Provide base abstract classes to be extended by developers

LWJGL LightWeight Java Game Library http://www.lwjgl.org/index.php Provide developers access to crossplatform libraries for: Rendering (using OpenGL) Sound (using OpenAL and FMOD) Input controls (gamepad, joystick) Timer

LWJGL Low-level Similar to JOGL (for OpenGL) and JOAL (for OpenAL) Regroup these low-level libraries together into one library Main packages: input, OpenGL, and OpenAL Style is procedural (in spirit of OpenGL and OpenAL which are C libraries) Best to use as a component for other game engines For example: jmonkeyengine or ardor3d use LWJGL in their rendering engine

LWJGL opengl.display and opengl.displaymode: to browse available modes, select one, toggle between full-screen and windowed mode Opengl.GL11: implementation of OpenGL 1.1 specifications; render in 2D and 3D, texture mapping, transformations Input.Keyboard: methods to check if a key is pressed, key codes (similar classes for mouse and joysticks) Util.Timer to control the game speed

Spinning cube public static void main(string args[]) { cube cube1 = new cube(); cube1.run(); } public void run() { // within a try {} catch() {`} init(); while (!done) { keyloop(); render(); Display.update(); } }

private void init() throws Exception { // 1. Init display Display.setFullscreen(fullscreen);.. // Loop to find an acceptable display displaymode =..;.. Display.setDisplayMode(displayMode); Display.create(); Spinning cube } // 2. Init GL GL11.glShadeModel( );.. private void keyloop() {.. if(keyboard.iskeydown(keyboard.key_right)){ angley = 0.015f; }.. }

jmonkeyengine http://www.jmonkeyengine.com/home/ jme is a Java based 3D game engine It provides a scene graph architecture It provides functionalities for sound, input, GUI dev., and several effects (water, particle system, ) It is mostly written in Java except for a thin JNI layer used to interface with audio, video and input device

Architecture Code for your game Scene management Model importers Collision detection Audio management Graphics Effects Input management LWJGL Extension For physics engine OpenGL OpenAL jinput ODE Operating system

jme renderer It uses OpenGL (LWJGL) or software rendering Responsibilities: Transform from world space to screen space Traverse the scene graph and renders visible portions of it

Scene graph A hierarchical data structure (tree) used to group data Internal nodes used to apply operations (geometrical transformation, lighting, ) Leaf nodes contain geometrical data root Node With scaling sphere Tri mesh box

Benefits of a scene graph Simplify management of attributes: Ex: define a light applying only to a sub-tree Facilitate the definition of hierarchical geometrical models In OpenGL, it would be done by using glpushmatrix() and glpopmatrix() on the ModelView matrix Grouping objects in a region Help in culling non-visible areas of the scene

jme scene graph Leaf nodes: geometrical data Internal nodes maintain spatial and semantical information Transformation: for positioning, scaling and orienting objects Bounding volumes: for culling and intersection testing Render state: information passed to the renderer for rendering object (ex: lighting state, texture state, material state) Animation state: to represent time varying node data

Example Box1 Root Node With scaling Box2 With translation protected void simpleinitgame() { Node n = new Node("Node1"); Box b1 = new Box("Box1", new Vector3f(0, 0, 0), new Vector3f(1, 1, 1)); b1.setmodelbound(new BoundingBox()); b1.updatemodelbound(); Box b2 = new Box("Box1", new Vector3f(0, 0, 0), new Vector3f(1, 1, 1)); b2.setmodelbound(new BoundingBox()); b2.updatemodelbound(); b2.setlocaltranslation(1.0f, 2.0f, 0.0f); n.attachchild(b1); n.attachchild(b2); n.setlocalscale(2.0f); } rootnode.attachchild(n);

jme sound Sounds are defined in a similar way as the geometry inside the scene graph Sounds are rendered in 3D (using OpenAL JOAL) Access to the audio system is performed by: AudioSystem audio = AudioSystem.getSystem(); Possibility to load.ogg or.wav files to be played during the game

Graphics functionalities Loading, mapping and rendering of textures Various 3D model data loaders: MD2: Quake 2 model format ASE: 3D Studio Max Ascii format Built-in primitives: point, line, sphere, box, triangle meshes, States: lights, textures, fog, materials, shading, alpha

Effects Particles, water, terrain, shadow Example: Particle system Creation through the factory: ParticleMesh p = ParticleFactory.buildParticles( particles, 60); Setup properties: size, color, p.setinitialvelocity(0.1f); p.setstartsize(3f); Add influences such as wind, gravity, ParticleInfluence wind = SimpleParticleInfluenceFactory.createBasicWind(.6f, new Vector3f(0, 1, 0), true, true); p.addinfluence(wind);

Simple example of game Framework: jme proposes some application classes: AbstractGame, SimpleGame, SimplePassGame, StandardGame We will use the simplest one: SimpleGame public class TestGame extends SimpleGame { @override protected void simpleinitgame() { } }

jme application classes AbstractGame Basic API for games Some implementations common to all game: initsystem(); initgame(); the game loop which calls update(float) and render(float); cleanup() SimpleGame extends BaseSimpleGame BaseSimpleGame provides implementation for most of the needed tasks; it is only required to build a scene graph in simpleinitgame() AbstractGame -> BaseGame -> BaseSimpleGame

jme application classes SimplePassGame: same as BaseSimpleGame with multi-pass rendering management StandardGame: implements basic functionalities needed in a game

Simple example of game jme s geometrical primitive for the game elements: ball = new Sphere( Ball, 10, 10, 1); ball.setmodelbound(new BoundingSphere()); ball.updatemodelbound(); player = new Box( Player, new Vector3f(), 5, 5, 10); player.setmodelbound(new BoundingBox()); player.updatemodelbound(); player.setlocaltranslation(110f, 0f, 0f); // walls and bricks are similarly made of Box rootnode.attachchild(ball); rootnode.attachchild(player);

Input control Use KeyBindingManager to register actions and map keyboard input these actions simpleinitgame() { KeyBindingManager.getKeyBindingManager().set( PLAYER_MOVE_LEFT, KeyInput.KEY_1); } simpleupdate() { if (KeyBindingManager.getKeyBindingManager().isValidCommand( PLAYER_MOVE_LEFT, true)) { // move the position of the player to the left player.getlocaltranslation().z -= speed * timer.gettimeperframe(); } }

Ball movement Use the ball speed and the time elapsed (between the last and the current call) to update the ball position at each update simpleupdate() { ball.getlocaltranslation().x = ball.getlocaltranslation().x + ball_speed.x * timer.gettimeperframe(); ball.getlocaltranslation().y = ball.getlocaltranslation().y + ball_speed.y * timer.gettimeperframe(); ball.getlocaltranslation().z = ball.getlocaltranslation().z + ball_speed.z * timer.gettimeperframe(); }

Collision detection We use the bounding volume only for checking collision simpleupdate() { if (player.hascollision(ball, false)) { ball_speed.x = ball_speed.x * (-1.0f); } // same for the back wall if (lateral_walls.hascollision(ball, false)) { ball_speed.z = ball_speed.z * (-1.0f); } }

Collision with the bricks For the bricks in addition to changing the ball velocity direction, we need to remove the brick from the scene graph simpleupdate() { if (!brick_wall.isempty()) { for (Brick b : brick_wall) { if (!b._removed && b._box!= null && ball.hascollision(b._box, false)) { ball_speed.x = ball_speed.x * -1.0f; rootnode.detachchildnamed(b._name); b._removed = true; } } } }

Simple example of game Breakout like game

Adding sound to the game First obtain access to the audio system: AudioSystem audio = AudioSystem.getSystem(); Setup a track in the init part: AudioTrack collide_sound = audio.createaudiotrack( collision.ogg, false); Every time a collision is detected, play the sound: collide_sound.play(); Update the AudioSystem in the game loop: AudioSystem.getSystem().update();

More effects For example: add some particle system making some firework effect once the game is finished Add texture to the player paddle, to the walls, Add a background music All of these can be quickly done using the jme API

Physics engine Collision detection is already provided Cloth simulation is also provided (jmex.effects.cloth.clothutils and jmex.effects.cloth.collidingclothpatch) For doing more physically based simulation: possibility to add jme physics 2 that provides access to ODE, PhysX

Summary: game engines Game engines are software libraries bringing (through API) to the developer functionalities needed for developing games As with any other software libraries, they allow the developer to re-use components and decrease its development time Java game engines developed in Java (with some JNI layers) or bindings to game engines (developed in other languages) Examples with LWJGL (low-level) and jmonkeyengine (higher level) showed how game engines can facilitate the creation of game

Summary: Java for game development Cross platform Power of Java technology: Easy to use Size of the standard library Object oriented Deployment Applet or application Full-screen or windowed Bottlenecks can be rewritten in lower level languages (with default implementation in Java) for speed improvement (JNI, Swig)