34
Flash Online Conference #7 Scripting 3D apps with Lua and C++ @Minko3D http://minko.io

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

  • Upload
    minko3d

  • View
    1.864

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Minko - Scripting 3D apps with Lua and C++

Flash Online Conference #7

Scripting 3D apps with Lua and C++

@Minko3D http://minko.io

Page 2: Minko - Scripting 3D apps with Lua and C++

LATEST MINKO 2 ADDITIONS Available today on minko.io

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

New Minko 2 Features

Editor – Auto-save – Multiple optimizations

Framework

– Mutiple fixes on the lighting system

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

Page 4: Minko - Scripting 3D apps with Lua and C++

MINKO 3 Codename « Normandie »

Page 5: Minko - Scripting 3D apps with Lua and C++

Motivations

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

Increase performances, epecially CPU-wise

– Multi-threading?

Leverage existing codebase

Page 6: Minko - Scripting 3D apps with Lua and C++

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

Page 7: Minko - Scripting 3D apps with Lua and C++

Demo – HTML5 Sponza

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

Page 8: Minko - Scripting 3D apps with Lua and C++

Babolat Play - First commercial project!

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

Page 9: Minko - Scripting 3D apps with Lua and C++

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.

Page 10: Minko - Scripting 3D apps with Lua and C++

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++

Page 11: Minko - Scripting 3D apps with Lua and 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

Page 12: Minko - Scripting 3D apps with Lua and C++

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…

Page 13: Minko - Scripting 3D apps with Lua and C++

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)

Page 14: Minko - Scripting 3D apps with Lua and C++

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

Page 16: Minko - Scripting 3D apps with Lua and C++

Oculus Rift support

Page 17: Minko - Scripting 3D apps with Lua and C++

SCRIPTING IN MINKO 3

Page 18: Minko - Scripting 3D apps with Lua and C++

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

Page 19: Minko - Scripting 3D apps with Lua and C++

Core Framework Language Fast

Rich & expressive

Optimized for each target

Scripting Language Simple

Interpreted

Dynamic

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

Page 20: Minko - Scripting 3D apps with Lua and C++

Complaints about ActionScript

Garbage collector is messy

No operators overloading

Bad performances

No (easy) concurrency

Page 21: Minko - Scripting 3D apps with Lua and C++

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!

Page 22: Minko - Scripting 3D apps with Lua and C++

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

Page 23: Minko - Scripting 3D apps with Lua and C++

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

Page 24: Minko - Scripting 3D apps with Lua and C++

Minko 3 VS Flash

Flash Runtime

Core Library

ActionScript VM

Application

OS

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

ANE

Page 25: Minko - Scripting 3D apps with Lua and C++

Flexible

Flash Runtime

Core Library

ActionScript VM

Application

OS

ANE

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

Page 26: Minko - Scripting 3D apps with Lua and C++

Open Source

Flash Runtime

Core Library

ActionScript VM

Application

OS

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

ANE

Page 27: Minko - Scripting 3D apps with Lua and C++

Customizable

Flash Runtime

Core Library

ActionScript VM

Application

OS

Minko 3

Core Framework & Plugins

Lua VM

Application

OS

ANE

Page 28: Minko - Scripting 3D apps with Lua and C++

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

Page 29: Minko - Scripting 3D apps with Lua and C++

Coroutines

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

Page 30: Minko - Scripting 3D apps with Lua and C++
Page 31: Minko - Scripting 3D apps with Lua and C++

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

Page 32: Minko - Scripting 3D apps with Lua and C++

You chose!

C++ – Performances – Rich and powerful language

Lua

– Simple and efficient – Fast iteration times

Mix both in any project on any target

Page 33: Minko - Scripting 3D apps with Lua and C++

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

Page 34: Minko - Scripting 3D apps with Lua and C++

JOYEUX NOEL! THANK YOU SERGEY

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