Slides mihail-ivanchev-1

24
GamePlay3D: the versatile cross- platform 3D game framework Mihail Ivanchev droidcon 2013, Berlin

Transcript of Slides mihail-ivanchev-1

GamePlay3D: the versatile cross-platform 3D game framework

Mihail Ivanchev

droidcon 2013, Berlin

• GamePlay3D is an open-source 3D game framework supporting numerous platforms.

Overview

• GamePlay3D is an open-source 3D game framework supporting numerous platforms.

• Quick facts:

– Apache 2.0 license; free for all usage types

– The development is supported by BlackBerry

– The development language is C++

– Declarative nature for rapid development

– Targets independent developers

Overview

• There are open-source frameworks for the development of cross-platform 2D games.

• For 3D games however the choice is mostly among proprietary technologies such as Unity3D and Adobe AIR.

• Flexible, simple, solid design. Intuitive API with focus on productivity.

Motivation

• Initially a private research project known as Octane3D, a cross-platform engine featuring intuitive tools and a clean API.

• Envisioned and developed by the duo Sean Paul Taylor and Steve Grenier in their spare time while working for BlackBerry.

• In 2012 BlackBerry offers to support the development of the framework to enhance the feature set.

History

• Flexible 3D scene graph.

• Material system.

• Particle system.

• Terrain rendering.

• Themable GUI system.

• 3D physics and collision detection.

• AI state machine.

• Lua scripting.

Features

• Many code structures in GamePlay3D can be build up declaratively using text files.

Declarative nature

Structure type File extension

Configuration files .config

Scene definitions .scene

Collision definitions .physics

Animation definitions .animation

Audio asset definitions .audio

Particle systems .particle

GUI forms .form

GUI themes .theme

• Many code structures in GamePlay3D can be build up declaratively using text files.

Declarative nature

animation animations

{

frameCount = 1100

clip idle

{

begin = 27

end = 167

repeatCount = INDEFINITE

loopBlendTime = 250

}

clip walking

{

begin = 274

end = 298

repeatCount = INDEFINITE

}

clip running

{

begin = 331

end = 346

repeatCount = INDEFINITE

}

clip runningLeft

{

begin = 899

end = 915

repeatCount = INDEFINITE

}

...

}

window

{

title = Character

width = 1280

height = 720

fullscreen = false

samples = 2

}

aliases

{

backboard = res/dxt/backboard.dds

basketball = res/dxt/basketball.dds

book = res/dxt/book.dds

...

toybox = res/dxt/toybox.dds

walleast = res/dxt/walleast.dds

wallnorth = res/dxt/wallnorth.dds

walloverhang = res/dxt/walloverhang.dds

wallsouth = res/dxt/wallsouth.dds

wallwest = res/dxt/wallwest.dds

windowledge = res/dxt/windowledge.dds

wood = res/dxt/wood.dds

woodn = res/dxt/woodn.dds

}

gamepads

{

form = res/common/gamepad.form

}

Animation: Configuration:

• GamePlay3D is fully C++, not a single Java file is required on Android.

Technical

Since Android 2.3!

• GamePlay3D is fully C++, not a single Java file is required on Android.

• OpenGL 3 used on desktop and OpenGL ES 2 used on mobile targets.

• API support for native features: multi-touch, accelerometer, file system access etc.

• Different methods for interacting with platform-specific code: e.g. JNI on Android.

Technical

• The material defines how a piece of geometry is rendered on screen.

Material system

Material

PASS 1

Render state Vert. shader Frag. shader

PASS 2

Render state Vert. shader Frag. shader

PASS N

Render state Vert. shader Frag. shader

Technique

• The material defines how a piece of geometry is rendered on screen.

Material system

material duck

{

technique

{

pass 0

{

vertexShader = res/shaders/textured.vert

fragmentShader = res/shaders/textured.frag

defines = SPECULAR

sampler u_diffuseTexture

{

path = res/duck-diffuse.png

mipmap = true

wrapS = CLAMP

wrapT = CLAMP

minFilter = NEAREST_MIPMAP_LINEAR

magFilter = LINEAR

}

renderState

{

cullFace = true

depthTest = true

}

u_cameraPosition = CAMERA_WORLD_POSITION

u_ambientColor = 0.2, 0.2, 0.2

u_lightColor = 0.75, 0.75, 0.75

u_specularExponent = 50

u_worldViewProjectionMatrix = WORLD_VIEW_PROJECTION_MATRIX

u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX

}

}

}

• The material defines how a piece of geometry is rendered on screen.

• Flexible interaction with the shader uniforms through material parameters.

Material system

• Supports several control types.

GUI system

• Supports several control types.

GUI system

form particleEditor

{

theme = res/editor.theme

autoWidth = true

autoHeight = true

container presets

{

style = basic

layout = LAYOUT_VERTICAL

position = 0, 0

size = 160, 220

label title

{

style = title

size = 140, 30

text = Presets

}

radioButton spiralFlame

{

style = iconNoBorder

text = Fire

group = presets

size = 140, 40

imageSize = 35, 35

selected = true

}

...

}

...

}

• Supports several control types.

• Flexible theming mechanism.

GUI system

theme particleEditor

{

texture = res/editor.png

imageList normalImages

{

color = #4A8799ff

...

}

imageList activeImages : normalImages

{

color = #C3D9BFff

...

}

skin mainNormal

{

border

{

left = 10

right = 10

top = 10

bottom = 10

}

region = 1, 1, 74, 74

color = #4A8799ff

}

skin mainActive : mainNormal

{

color = #C3D9BFff

}

style basic

{

stateNormal

{

skin = mainNormal

imageList = normalImages

font = res/arial18.gpb

textColor = #ffffffff

fontSize = 18

textAlignment = ALIGN_VCENTER_HCENTER

}

stateActive

{

imageList = activeImages

}

}

...

}

• Wraps the Bullet physics library.

• Provides standard rigid body simulation.

• Provides game character and vehicle models.

• Provides ray and hit testing.

Physics & Collision Detection

• Supports many particle attributes.

• Supports animated particles.

• Lacks support for particle collisions.

• A simple editor is provided as a sample.

Particle System

• gameplay-encoder – a command-line tool for packing game assets to a binary file package.

– (.TTF) True-type fonts

– (.FBX) Autodesk’s 3D scene format

Asset Management

gameplay-encoder -s 14 Futura-Medium.ttf futura-med.gpb

gameplay-encoder -oa –tb sphere Level1-Tutorial.fbx lev1-tut.gpb

• gameplay-encoder – a command-line tool for packing game assets to a binary file package.

– (.TTF) True-type fonts

– (.FBX) Autodesk’s 3D scene format

• Other formats are supported directly.

– Standard image formats

– Standard audio formats

Asset Management

• Lua scripting is done by specifying Lua handlers for predefined or custom events.

Lua Scripting & Language Bindings

scripts

{

initialize = res/script.lua#initialize

update = res/script.lua#update

render = res/script.lua#render

finalize = res/script.lua#finalize

}

Game config:

Lua script:

• Lua scripting is done by specifying Lua handlers for predefined or custom events.

• Additional interaction possible through the game’s script controller.

• Additional language bindings available for the cross-compiled language Haxe.

Lua Scripting & Language Bindings

https://github.com/MIvanchev/hx-gameplay

• GamePlay3D is well documented.

• All C++ environments usable.

• All Lua environments usable.

• Command line tools for packaging and deployment.

Documentation and development environments

Thank you for your time!

Questions