Minko physics is probably one of the most awaited features for this new year. I will not cover it extensively right now - I'll rather post a few demos in a later post - but if you must know it was designed to be the fastest 3D physics engine for ActionScript 3 and the Flash platform.
I will share extensive details about this new physics engine during the Stage3D online conference in February. Make sure you attend: it's online and it's free!
Anyway, I just wanted to tease the community with one of the stress tests we're using here to benchmark the engine. It's a really simple test and it uses only a very very small subset of the available features.
Here you go (just press "space" to throw some balls):
This video demonstrates what can be achieved using Minko, the next-gen 3D engine for Flash "Molehill" I'm working on. The environment is a Quake 3 map loaded at runtime and displayed using high definition textures. The demo shows some technical features such as:
- Quake 3 BSP file format parser
- Potentially Visible Set (PVS)
- complex physics for spheres, boxes and convex volumes using BSP trees
- light mapping using fragment shaders
- materials substitution at runtime
- dynamic materials using SWF and the Flash workflow
- first person camera system
Quake 3 BSP file format
Quake 3 uses the version 46 of the BSP file format. It's farily easy to find unofficial specifications for the file format itself. Yet, parsing a file and rendering the loaded geometry are two very different things. With Minko, it is now possible to do both without any knowledge of the specific details about the BSP format and algorithms. Still, those are interesting algorithms so I wanted to explain how it works.
Binary Space Partioning (BSP) is a very effective algorithm to subdivise space in two according to a "partition". To store the subdivided spaces, we use a data structure called a BSP tree. A BSP tree is just a binary tree plus the partition that separates both children. This picture shows the BSP algorithm in 2 dimensions:
In that case, each node of the BSP tree will store the partition line. When working with 3D the partition will be a plane. We can then walk through the tree by simply comparing the location of a particular point to the partition. A good use case is 3D z-sorting: we simply have to compare the location of the camera to the planes stored in the BSP nodes to know which child should be walked through (or renderered) first. But in Quake 3, the BSP tree is used for:
- physics: the tree makes it possible to optimize collisions detection by performing only the required computations and tests
- rendering optimization: by locating the node where the camera is, we can know what is the Potentially Visible Set (PVS) of polygons that should be renderered and ignore the rest
In each "*.bsp" file are stored the BSP tree itself, the partition planes, the geometry, the PVS data and even bounding boxes/spheres for each node to perform frustum culling. This data is very precious and is compiled directly in the file by tools like GTKRadiant.
HD textures were provided by the ioquake3 project.
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!