Exploring JigLibFlash – the AS3 3D physics library
JigLibFlash is a new library for 3D physics simulation in Flash. It is ported from a C++ open source engine. It’s been around for a few months now, and if you haven’t heard about it, you need to catch up!
I believe physics simulation is the next step in the Flash 3D world, so I got very excited when Ringo from FlashBookmarks invited me join the JigLibFlash team a couple of months ago. One little problem: I am perfectly lame when it comes to physics… In this situation, the only logical thing to do was to join the team and learn all the stuff I need to know about it in the meantime. Sounds like a challenge!
Now I slowly fill my knowledge gap. However, I also managed to do some actual work on the library. Together with Reyco we remodeled the API. We started by making it more Flash developer friendly, less C-style and more AS-style. All the methods start with a lowercase letter now, and instead of having to set the position and rotation using vectors and matrices, the new API offers simple getter/setters for properties like x/y/z and rotationX/Y/Z just like in Papervision3D or in the new Flash Player 10 API.
Last but not least, we also created a plugin system to easily integrate JigLibFlash with the popular 3D engines like Papervision3D or Away3D. Now there are specialized classes to interact with those two engines and it should be pretty easy to create a plugin for another engine if one needs. If you worked with AS3Dmod you should notice that the concept is similar to the plugin architecture in there. Update: I just saw in the sources that someone already created a plugin for Sandy3D.
To learn more about these changes you can refer to the tutorial I wrote which is posted on the projects wiki page. Reyco also wrote a great article about this on his blog.
The demo above is my first little experiment with JigLibFlash and Papervision3D. My idea was to integrate a Collada object with the physics system and to add some interactivity to it. I extended the Mouse constraint class created by Reyco to control the racket. I encountered some problems with stabilizing it in the long run. After having bounced the ball a few times the racket starts to rotate as if the constraints were broken… well, I still need to do some research on that.
Source code. You can browse the sources for the demo here.
Links. Some links to get you started with JigLibFlash:





It’s very fluid. Congrats
Great work! Add a table and it’d make a pretty cool game :)
Great demo bartek! I did something similar a couple weeks ago , but your racket model is just perfect! You should try to do something else of this demo ;)
@David Thanks! A tennis table game would be cool indeed. Must find time to work on it.
@Peixinho I modelled the racket in Blender and the textures I got the from.. ehm.. Google Image Search :)
is the racket supposed to be 10X smaller than the ball or it’s something on my side ?
@vitaLee :) Nope, it’s should look like on the picture in the post. What browser/platform are you using or are you running the SWF standalone?
Windows XP // FF 3.0.9 // Flash PLayer 10 (Debug).
checked it on a MAC / flash player 10 and it looks all fine(like on the picture you posted).
there you have something to think about. :)
Congrats
Now you can try use FLARToolKit to control the racket.
Lovely Bartek:)
@VitaLee: that sounds weird, the only thing i’ll like to add is, the debug player for flash can be about 100% slower with the 3d physics examples then the normal player.
W O W – amazing stuff – Bartek is a hero
[...] Visit Article [...]
Hi Bartek,
Awesome work, congrats!
I’ve got a question tho. Is there a way to bend the ground in the Jig Lib? I’m trying to achieve a low-rise skyline effect, only object located close to the camera are too flat/low. Any ideas?
Hi bartek, great work! Jiglibflash have a great potential.
This is my first experiment with jibliflash http://www.david5.com/wp-content/uploads/2009/03/testjiglibmenu3.swf
(key arrows to move)
Hi, great work!!!
In the Racket class.
there is an import of the Scale class
“import com.as3dmod.modifiers.Scale;”
and you use it to scale the mesh,
but there is not such class in the package
com.as3dmod.modifiers at SVN
sorry for my bad english
@pablo Sorry, I forgot to specify that for this example you need to use the fp10 branch of AS3Dmod, which is also located in the SVN here: http://code.google.com/p/as3dmod/source/browse/#svn/branches/fp10 Now I also update the post above. Thanks!
Everydayflash is my home page now. You rock, man.
Thanks, good article.
[...] http://www.everydayflash.com/blog/index.php/2009/04/23/jiglibflash-3d-physics/ [...]
Thanks for this example..
I am using collada files as 3D objects which are of uneven shape and mapping the collada with JSphere Object of Jiglib…in this object i have to pass the radius as one of the parameters…is there any way i can find the dimensions of collada objects so that i can use it as a radius for spherical objects?
[...] gerade mit JigLibFlash herum. Genaue Vorgehensweise und technischen Hintergrund erfahrt ihr drüben bei Bartek. Auch könnt ihr selbst aktiv werden und ein wenig eure Ping Pong-Künste [...]
Appreciate it for helping out, superb data.