JigLibFlash and FIVe3D in Flash Player 10

January 24, 2010 by Devin Reimer

FIVe3D JigLibFlash FP10 Demo Screenshot

This post is long overdue as I put a lot of effort into the code behind this and when it was finally finished, I just never got around to blogging about it.

A little while ago katopz a new member of the JigLibFlash team started work on Flash Player 10 specific version of JigLibFlash. Once he got it up and running I started work on optimizing it’s performance. I had done performance optimizations for many different projects in the past,  but I had never undertaken an optimizing task quite this complex. Overall it was a very great learning experience, learning the ins and outs of the Flash Player and gaining more knowledge on the weird thing that is the Flash Compiler. While I thought I understood people’s frustrations with the Flash Compiler, it wasn’t until my second week into making performance tweaks that I began to see how poorly the Flash Compiler actually works.

In the end my work finally paid off as JigLibFlash began performing 150% faster than the previous version.

Once that was complete I fixed up the JigLibFlash FIVe3D plugin to make it work with a slightly modified version of FIVe3D (just modified enough so it would compile under Flash Player 10). This is the point when I decided that since I had learned so much about FP10 and the Flash Compiler, I should take a stab at creating a properly FP10 version of FIVe3D. What I thought would be a quick task ended up evolving into me completely rewriting the library. When this new version was complete it ran well over twice as fast as the old one. I contacted Mathieu (creator of FIVe3D) so see if he wanted a copy. It turned out that during the same time period he was also working on an FP10 version of FIVe3D.

Not all was lost, he sent me an alpha version of the library, so I could perform some benchmarks. While my code performed better in certain situation, his performed better in normal uses cases. With this new information in hand I began work trying to incorporate some of my feature enhancements into his version of the library. The most important feature being the addition of ‘direct transform matrix manipulation’. Mathieu and I had spoke of about this feature a few times prior, but understandably he had more important items to tackle. For people that don’t know ‘direct transform matrix manipulation’ is so important because it is a requirement for JigLibFlash to work. This is why in the past to get FIVe3D and JigLibFlash to work together you had to download a custom Sprite3D class from my site.

After a lot of thought I managed to come up with a way to not only incorporate this feature, but also make the library a little bit faster in the process. I sent the modified version back to Mathieu and this code has since been added to the FP10 version of the FIVe3D library. Mathieu was also nice enough to add me as a contributor to the library.

This means that need to download a custom Sprite3D class is no longer required. All the code (minus the Cube class) for using JigLibFlash together with FIVe3D is now added to their respective libraries. This also means that things are a lot faster and in the end; speed = fun.

All the pieces you with need to download:

To see the demo click here.

To get the source for this example click here.

Note: This demo is the same as my first FIVe3D JigLibFlash example the only difference being it is using the FP10 version of both JigLibFlash and FIVe3D.

Update: Some people are having problems with the scale of objects being too small. This is a bug in the original Flash Player 10 player. This bug has since been fixed so make sure you get the newest version of Flash Player 10, Flash CS4 and/or Flex SDK.

JigLibFlash FIVe3D Dominos

October 1, 2009 by Devin Reimer

JigLibFlash FIVe3D Dominos

So far the only FIVe3D JigLibFlash example I have shown is the Falling Cube Demo. So it was time to create something a little more practical. Dominos.

In this demo you can create, position and rotate dominos, then knock them over. You can also move the camera around the scene to get a better view.

This demo is my first use of flat shading in FIVe3D , which is a new feature in V2.1.2. Flat shading couldn’t be easier to implement, I simply set scene.ambientLightIntensity=.05 and then set all the sides of my dominos to flatShaded=true. I’m impressed with how easy it was to add and how much more visually appealing it made this demo.

This demo is also my first since joining the JigLibFlash team and adding FIVe3D support to the JigLibFlash library. This means the sample source does not contain any JigLibFlash classes, as they are now within the JigLibFlash library itself. Make sure you update your version of JigLibFlash rev 101 or higher.

To check out the demo click here.

To get the demo source click here.

Source Requirements: You will need both FIVe3D 2.1.2 and JigLibFlash to compile the demo source.

JigLibFlash Contributor – JigLibFlash Native FIVe3D Support

September 21, 2009 by Devin Reimer

JigLibFlash Logo

I recently became a member of the JigLibFlash team. The first item of business was to add FIVe3D support into the library itself. You can read the brief article about it here. While you now will not need to download additional files for JigLibFlash you will still have to download the additional FIVe3D files (including the FIVe3D cube) from this site until they are supported features of FIVe3D. You can download those additional files here.

For those who have already implemented JigLibFlash with FIVe3D this new change should require no more effort than removing the old jiglib folder from my orignal source. An example of the new implementation is also available within the JigLibFlash library.

For those who haven’t heard of or used JigLibFlash yet check it out.

JigLibFlash Blog:
JigLibFlash Source:

If you haven’t already seen the demo here it is – FIVe3D JigLibFlash Demo.

JigLibFlash FIVe3D Support and FIVe3D Cube

August 3, 2009 by Devin Reimer

FIVe3D JigLibFlash Demo 1 Screenshot

Last week I spoke at ‘Flash in the Peg‘ – Winnipeg’s Adobe User Group. Here I got the opportunity to show a demo of JigLibFlash FIVe3D support that I have been working on for the last few weeks. After more hours than I would like to admit JigLibFlash FIVe3D support is now available for download. Like both JigLibFlash and FIVe3D these classes are released under the MIT License.

If you have used FIVe3D before you will know that there are no 3D object primitives built into the library, because of this I have also wrote a Cube class primitive for FIVe3D. Even if you do not need to use physics in your project you can still use this new Cube primitive.

Setting up JigLibFlash to work with FIVe3D is not quite as easy as Papervision3D, but it’s not a lot harder. The reason for this is FIVe3D does not allow for direct transformation matrix manipulations. In simpler terms a  few small changes needed to be made to the Sprite3D class within FIVe3D. You can use my modified version of the Sprite3D class to replace your current version, or just add it directly to your project using the same package folder structure. An example of how to do this is in my source below. The modifications to the Sprite3D class are small and should have no impact on your projects (with or without JigLibFlash).

To check out the demo click here.

To get the demo source, including all required files click here.

To just download the required files (JigLibFlash FIVe3D Plugin, modified Sprite3D class and new Cube primitive) click here.

Source Requirements: You will need both FIVe3D 2.1.2 and JigLibFlash to compile the demo source.

Update: As I am now a JigLibFlash contributor, JigLibFlash library now has built-in FIVe3D support. For more information click here.

Update 2: The JigLibFlash team (myself included) have completed work on upgrading JigLibFlash to Flash Player 10. To view the my blog post on this click here.

JigLibFlash Rewrite – Video Game Case Physics Example

April 13, 2009 by Devin Reimer

Video Game Case Physics Screenshot

Over the past 2 months the JigLibFlash team has been re-architecting the whole JigLibFlash project and the new version is now available. Using this re-architected library is quite a bit different from the old version. So before I convert some of my older stuff over, I decided to making a new demo of the updated library in action.

In this demo randomly positioned and oriented video game cases drop one on top of the other until 7 cases are on the screen. Then it resets and starts all over again. It is a very simple example, but it will give you a place to start.

To play the demo click here.

To get the source click here.

Source Requirements: You will need Papervision3D , JigLibFlash and bulk-loader to compile the source.

Note: The case is a scan of my copy of ‘Left 4 Dead’, if you want to read a good article on how the actual case artwork came to be, check out this link:

JigLibFlash Object Rotation – Pitch, Yaw and Roll

March 27, 2009 by Devin Reimer

JigLibFlash Rotation Example Screenshot

I get asked the following question a lot: “How do I rotate a JigLibFlash object?”. I do understand why people have this question as rotating pieces of geometry in JigLibFlash is not very straight forward. It also can end up being kind of challenging if your not familiar with exactly how rotation matrix work. The bottom line is it is not as easy as Papervision3D ( ex: pitch(10) ). So instead of me trying to explain any formulas I decided to add a few functions to the RigidBody class in JigLibFlash to make it easier for people to use.  I have created the following functions.

public static var toDEGREES:Number = 180/Math.PI;
public static var toRADIANS:Number = Math.PI/180;
public function pitch(angleDeg:Number):void
	SetOrientation(JMatrix3D.multiply(CurrentState.Orientation, JMatrix3D.rotationX(angleDeg*toRADIANS)));
public function yaw(angleDeg:Number):void
	SetOrientation(JMatrix3D.multiply(CurrentState.Orientation, JMatrix3D.rotationY(-angleDeg * toRADIANS)));
public function roll(angleDeg:Number):void
	SetOrientation(JMatrix3D.multiply(CurrentState.Orientation, JMatrix3D.rotationZ(angleDeg*toRADIANS)));
public function setRotationsDegrees(xRotation:Number, yRotation:Number, zRotation:Number):void
	SetOrientation(JMatrix3D.euler2matrix(new JNumber3D(xRotation, yRotation, zRotation)));
public function get rotationX():Number
	return JMatrix3D.matrix2euler(CurrentState.Orientation).x;
public function get rotationY():Number
	return JMatrix3D.matrix2euler(CurrentState.Orientation).y;
public function get rotationZ():Number
	return JMatrix3D.matrix2euler(CurrentState.Orientation).z;

You can copy this into the RigidBody Class within JigLibFlash (jiglib/physics/). Or you can click here to download a modified version of the RigidBody class to add to your JigLibFlash source. Once complete you can now use these functions from any standard JigLibFlash geometry object.

What you might notice is this source is missing a set function for rotationX, rotationY and rotationZ. I have included commented out version of my function in the source, but be advised that they are commented out because they can cause some weird results when rotating on more then one axis. You are free to use them, but you have been warned. I’m not a math genius so if anyone has any optimizations or additions please let me know.

These functions should hold everyone over until the JigLibFlash team has finished its rewrite of this project.  To read more about what the new syntax will be when completed, check out this recent post by drojdjou.

To play the demo click here.

To get the demo source click here.

Update: As of April 12 (rev. 81), these functions are now part of JigLibFlash source, so you will no longer need to copy in these functions into your project. :)