Flash 3D physics with Minko and jiglibflash

Drawing (a lot of) triangles is nice. But making them move is another problem… even harder: making them move like objects would move in real life! This is what a “physics engine” is about:

“A physics engine is computer software that provides an approximate simulation of certain simple physical systems, such as rigid body dynamics (including collision detection), soft body dynamics, and fluid dynamics, of use in the domains of computer graphics, video games and film. Their main uses are in video games (typically as middleware), in which case the simulations are in real-time. The term is sometimes used more generally to describe any software system for simulating physical phenomena, such as high-performance scientific simulation.”

Source: Wikipedia, Physics engine

Flash is no exception and has a few physics engine libraries available. Nothing like a “high-performance scientific simulation” though…

Still, jiglibflash is one of those libraries. It is free and open-source. It provides a 3D-capable physics engine and exposes a rather simple API to make it work with any 3D graphics engine. Which brings me to the good news: Minko now supports jiglibflash!

So here you go :

Tron inspired jiglibflash + minko demo application

You can try the following inputs :

  • space: slow-motion
  • mouse click + drag: move the camera
  • tab: toggle performance monitor
  • r: reset the scene

The goal of the application was to benchmark jiglibflash to see how many rigid bodies can be handled in a single scene. This is the purpose of the performance monitor:

Press 'tab' to toggle the performance monitor in the above application.

The tracked values are :

  • the framerate
  • the memory consumption
  • the physics processing time (as ‘processingTime’)
  • the rendering time (as ‘renderingTime’, this duration actually includes the physics processing time as the physics engine is a node of the 3D scene graph)
  • the total amount of triangles
  • the total amount of visible objects (as ‘numChildren’)
  • the maximum amount of visible objects (as ‘maxChildren’)

And of course, the bigger ‘maxChildren’ gets the better. The application is actually very simple: as soon as the framerate is above 24 frames per second, we create new cubes/spheres and add them to the simulation. This way we supposedly add as much objects as the simulation can handle while remaining smooth (or at least that’s what is supposed to happend in a perfect world).

Here are my results :

  • Flash 10.1 on Google Chrome 6.0
  • Intel Core 2 Duo U9400 @ 1.4Ghz
  • maxChildren = 111
  • You did a extremely great work~!!! I’m a very beginner for flash 3d, for now I’m studying the basic 3D knowledge and Stage3D, physics 3D engine, etc. I’m So excited to find your website, and I decide to study your Minko engine in the first place!!! My lovest demo is Gravity: 3D physics, lights and sounds. I download the source code and take effort on research. I beg you could tell me how to change the whole scence’s background color. such as change to white color, now is black. And I’m wonder if Minko can make the effect like http://www.monolith-net.co.jp, if so, could you make a very simple demo like http://www.monolith-net.co.jp, dont’ need the texture on each cube, just make them more physics and organized, I’ll pay you if you’d like to do it and send me the source code with necessary comment in detail, just for study~,!!! Thank you So much!!! And Please have a reply ASAP ~!!!