Minko - Scripting 3D apps with Lua and C++

Preview:

Citation preview

Flash Online Conference #7

Scripting 3D apps with Lua and C++

@Minko3D http://minko.io

LATEST MINKO 2 ADDITIONS Available today on minko.io

New Minko 2 Features

Editor – Auto-save – Multiple optimizations

Framework

– Mutiple fixes on the lighting system

Available today! http://minko.io/download

MINKO 3 Codename « Normandie »

Motivations

Target new platforms – Keep the « design once, deploy everywhere » workflow – Larger community

Increase performances, epecially CPU-wise

– Multi-threading?

Leverage existing codebase

Technological choices

C++11 core framework and plugins

Develop once, deploy everywhere – Windows, Mac, Linux – Android, iOS – HTML5, Flash

Work with all the tools you like

Demo – HTML5 Sponza

http://minko.io/showcase/sponza-html5

Babolat Play - First commercial project!

http://www.youtube.com/watch?v=ewUUerxdZ7U

Babolat Play - Fallback

Is WebGL

available?

Run web app. Generate JPEG on the server

no yes

Thanks to Minko 3, the same code runs on the server side and in the browser.

New Platforms

Platform Status Target Languages

iOS OK Native C/C++

Android OK Native C/C++

Flash (Stage3D) WIP X-Compilation C/C++, AS3

Windows (DirectX) OK Native C/C++

Mac OK Native C/C++

Windows (OpenGL) OK Native C/C++

Linux OK Native C/C++

HTML5 (WebGL) OK X-Compilation C/C++, Javascript

Windows Phone WIP Native C/C++

BlackBerry 10 NA Native C/C++

Firefox OS NA Native C/C++

How can I help?

Show your love for Crossbridge and Minko on the dedicated feature request on Github! – https://github.com/adobe-flash/crossbridge/issues/28

Please leave a comment, even just a +1

2D/3D file formats

50+ 3D file formats – 3DS, BLEND (Blender 3D), DAE/Collada, FBX, IFC-STEP , ASE, DXF,

HMP, MD2, MD3 , MD5, MDC, MDL, NFF, PLY, STL, X, OBJ, SMD, LWO, LXO, LWS, TER, AC3D , MS3D , COB, Q3BSP, XGL, CSM, BVH, B3D, NDO, Ogre XML, Q3D

20+ 2D file formats

– JPEG, PNG, TIF, TGA, RAW, PSD…

Effect files

Store a fully setup multi-pass rendering effect

Include 3rd party shaders and plug them in the engine using bindings

Support über-shaders using automated macro definition based on bindings

Handle multiple rendering techniques to choose from at runtime

Can fallback to another specific technique when the selected one fails (WIP)

Portable Effects & Shaders

Group passes in a named « technique »

Select that technique at runtime based on some flags – Platform – Available features/plugins – Custom flags

"techniques" : [ { "configuration" : [ "windows" ], "passes" : [ { "vertexShader" : … "fragmentShader" : … } }, { "configuration" : [ "flash" ], "passes" : [ { "vertexShader" : … "fragmentShader" : … }, { "vertexShader" : … "fragmentShader" : … } } ]

« w

indo

ws »

tech

niqu

e «

flash

» te

chni

que

Oculus Rift support

SCRIPTING IN MINKO 3

C++11 is great, but…

Is a new language for most developers

It’s too complex for prototyping game design

Requires some setup to get started

Slow iteration times

Core Framework Language Fast

Rich & expressive

Optimized for each target

Scripting Language Simple

Interpreted

Dynamic

VS C, C++, Java, C#... Javascript, Python, AS3…

Complaints about ActionScript

Garbage collector is messy

No operators overloading

Bad performances

No (easy) concurrency

We chose… Lua!

Fits all the requirements of a scripting language

Vastly used by the video game industry (World of Warcraft, Fable II & III, Neverwinter Nights, …) – Complete list of games scripted with Lua

Very (very) fast

– LuaJIT is comparable to Javascript V8, if not faster

Designed to be embedded

Designed to script games – Simple but very efficient syntax – Minimalistic set of features but very extensible – Coroutines!

C++ Lua? LuaGlue!

C++/Lua bindings

Open source project – https://github.com/Tomasu/LuaGlue – We contribute as much as possible

Leverage C++11

– Optimize as compile time as much as possible – Simple binding interface

Used to bind 90% of Minko’s C++ API

– Write 100% of your app in Lua

ActionScript VS Lua

ActionScript Messy garbage

collector

No operators overloading

Bad performances

No easy concurrency

Lua Customizable garbage

collector

Operators overloading

Very fast + custom C/C++ bindings

Coroutines

Minko 3 VS Flash

Flash Runtime

Core Library

ActionScript VM

Application

OS

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

ANE

Flexible

Flash Runtime

Core Library

ActionScript VM

Application

OS

ANE

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

Open Source

Flash Runtime

Core Library

ActionScript VM

Application

OS

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

ANE

Customizable

Flash Runtime

Core Library

ActionScript VM

Application

OS

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

ANE

Coroutines

A function can suspend its execution… – coroutine.yield()

… and then resume « sometime later »

– coroutine.resume()

Gives the illusion of parallelism – Yet no complicated threading stuff – Fully cross-platform

Allow the creation of non-blocking (heavy) functions

Can (always?) be used in place of events/callbacks

Coroutines

function myScript doSomething() while isIdle say(‘hello how are you?’) wait(seconds(3)) while no isIdle wait(keyboard:keyDown()) handleKeyboard() …

Event driven Coroutine driven

Action => reaction

Breaks the code in multiple handlers

Messy execution flow

Messy scopes

Wait for « something » to happen

Non-blocking

Simple execution flow

Meaningful and readable

You chose!

C++ – Performances – Rich and powerful language

Lua

– Simple and efficient – Fast iteration times

Mix both in any project on any target

2014

New Minko editor – Script editor – Live coding – ShaderLab – Animations editor – Plugins system

Open beta of Minko 3 (January)

An amazing new Minko product for businesses and teams

http://www.youtube.com/watch?v=yuR1e1PjU8Y

JOYEUX NOEL! THANK YOU SERGEY

Don’t forget to check http://minko.io !