Post image for Using papervision3D with the jiglib physics engine
Post image for Using papervision3D with the jiglib physics engine

Using papervision3D with the jiglib physics engine

When a few examples of the ported jiglib physics engine were released, I wanted to see what this engine was capable of. Here are a few of those experiments.

Please Download the Zip files to try each one of these out. They run much more smoothly when not running in a browser.

The Basketball example:
File: basketball.zip

How to play:
When you start, the basketball follows the mouse – click to shoot the ball forward and try to make a basket. If you get it in, the hoop will move somewhere randomly. The ball won’t come back to the mouse, but click again to shoot the ball from the position of the mouse.

About it:
By messing around with the weight and bounce, I got a nice basketball effect. One problem was creating the hoop; since making odd shapes to work with jiglib is near impossible – the hoop was just constructed out of 5 boxes.

The Bowling Example:
File:bowling.zip

How to play:
Move the mouse to position the bowling ball and then click to throw it. You get 2 shots to see if you can knock down all the pins – then it will restart the simulation. You start off with a 2lb ball at a pretty low speed, move the sliders to increase the weight, speed, and the spin of the ball.

About it:
Cool to see a bunch of things knocked out by a bowling ball weighing 50lbs… One of the major problems I’ve encountered with the jiglib engine is that objects moving too fast will go right through another object instead of colliding with it.

The Ball Drop Example:
File: ball_drop.zip

How to play:
Move the mouse to tilt the wooden board. You have to collect all the gold on the board to continue on to the next level. The weird angry thing following you will eat you if it catches up to you. Higher levels will increase the gravity on the ball and the speed that the weird angry thing follows you.

About it:
One of the major problems that had to be overcome in this example is detecting collision while moving the board. If you moved the board too fast – the ball would fall through. Although this is now almost fixed, other problems came up; if the gravity gets too strong, the ball begins to act oddly (happens around level 3).

The Dominos (The Coolest) Example:
File: dominos.zip
File: dominos_sample.xml

How to play:
Click “Play” to begin. Click anywhere on the board and hold the mouse button down. You will start dragging a domino. Let go of the mouse button to drop the domino and moving the mouse now will rotate the domino. Click again to finish placing the domino. Click “Look Around” to take a look around… you cannot place dominos while you’re looking around, to continue placing dominos click “Resume”. Once you’re done placing the dominos, click “Start” to drop the golden domino that will begin the chain drop. You can also click “Save” to see an xml with all the positions of the dominos you placed. If you want to load an xml layout, click “Load” and paste the xml there (you have to overwrite the existing text in the box).

About it:
As you can see, if you place too many dominos, the performance begins to slow down. I was able to increase the performance by setting a domino to immovable once it fell low enough. You can see how the domino freezes by dropping one outside the board.

And just remember BLITZ is still looking for another Senior Flash Developer with experience in papervision.

{ 12 comments… read them below or add one }

Flashbookmarks February 24, 2009 at 12:59 am

Aloha Yosef,

Glad to see that you did gave it a try.

Question: The issue you had when it’s running in a browser, did you run it with the debug flash player or the standard flash player? The debug version can be upto 100% slower then the standard flash player in combo with jiglibflash (http://www.jiglibflash.com/blog/)

Adrian February 26, 2009 at 7:53 am

Very nice. It’s getting more and more exciting with Flash (as allways).

We made some experiments too and added another very fun-promising ingredient: Socket Server.

For some prototyping we used the SmartFox server and produced a small multi player game where you have to push your opponents down the plattform.

It’s unfortunately in german and the prototype is not online. Have a look anyway, we love to share:

http://lab.dudagroup.com/?p=103

Indyaner March 8, 2009 at 12:17 am
Yosef Flomin March 9, 2009 at 4:51 pm

I confess I was testing it in the debug player. Thanks for the heads up.

ramon May 7, 2009 at 12:10 pm

source?

matt October 26, 2009 at 11:28 pm

any chance to get the source for the basketball hoop game?
i’d really like to see you you pulled that off

!matt

dave October 28, 2009 at 1:32 am

these guys are stingy with the source i guess….

Marissa Lerer November 9, 2009 at 11:47 am

In the basketball example, how did you detect for the ball going through the hoop?

Yosef Flomin November 9, 2009 at 1:49 pm

Nothing fancy, just getting the location of the ball every frame ( or render ) and checking to see if it is in the area (x, y, z) of the hoop. You should just make sure that the ranges of x,y,z are wide enough to include fast movement; since the values of the location of the ball will change in greater intervals if it is moving faster.

Michal Sajban November 26, 2009 at 6:07 am

Hi, this is my new game based on papervision + jiglib. Its helicopter simulation http://www.littlebigplay.com/game/548

ian schneider December 23, 2009 at 2:13 pm

Hi, I was wondering How you add Force to your ball. I tried Hard coding
in numbers to the addBodyForce method, ex: jball.addBodyForce(new JNumber3D(10, 229, 398), new JNumber3D(0, 0, 0)); , but the result is always different. The ball will sometimes shoot higher than other times. Shouldn’t it always travel in the same path. Any help would be greatly appreciated!

tali kaniatobe January 28, 2010 at 11:42 am

Hey Ian I think I found a fix to your problem. I had the same issue and found myself sifting through the jiglib source to see what was happening in the addBodyForce() method. You need to reset the orientation of your RigidBody object each time you call that method. I captured that original orientation when creating the jiglib object. so something like the script below might work for you.

jSphere = new JSphere(new Pv3dMesh(pvSphere), 30);
var _startOrientation:JMatrix3D = jSphere.currentState.orientation;

function shootBall():void {
jSphere.currentState.orientation = _startOrientation;
jSphere.moveTo(new JNumber3D(0, 0, 0));
jSphere.addBodyForce();
}

Leave a Comment

{ 4 trackbacks }

Using PV3D with the Jiglib physics engine « Papervision3D
February 26, 2009 at 7:38 am
Using PV3D with the Jiglib physics engine « Papervision3D - Developers
February 26, 2009 at 7:41 am
Using PV3D with the Jiglib physics engine « dev.papervision3d(beta)
May 27, 2009 at 11:32 pm
FOTB’09 presentation: 3D Bowling demo - Everyday Flash
September 29, 2009 at 3:17 am