VizualPV3DPhysics – combining VizualPV3D with JigLibFlash

Standard

Following on from my earlier post about loading xml from a VizualPV3D scene into Papervision3D, this class extends VizualPV3DLoader by adding some basic integration with the brilliant JigLibFlash 3D physics engine.

At the moment it is really more of a tech demo than a fully featured class, but it shows potential and I thought it might be useful to post it here. The class takes any cubes that are listed in the scene xml and turns them into physics objects using JigLibFlash, creating a set of static surfaces that could be used as the backdrop for your project. You can then create extra physics objects manually in ActionScript and add them into the scene as well.

So what could you do with this? Well theoretically it might be possible to make a simple 3D game using VizualPV3D to build the levels out of cubes, then animate parts of each level to make moving platforms or doors, before adding other more interactive elements like enemies or a player character using some extra ActionScript.

For more inspiration, there are some really cool JigLibFlash demos over on the project’s main blog, which are definitely worth checking out.

Here’s an example of how you might use the class in a project.

//include the class
import me.pv3d.VizualPV3DPhysics;

//elsewhere add it to your physics enabled papervision3d scene
var light:PointLight3D = new PointLight3D(); //light
var physics:Papervision3DPhysics = new Papervision3DPhysics(scene, 5);
var pv3d:VizualPV3DPhysics = new VizualPV3DPhysics('./assets/', light, physics);
pv3d.load('scene.xml');
scene.addChild(pv3d);

//then when the scene has loaded access objects by name and move them about
var mybox:RidgidBody = pv3d.getPhysicsBodyByName("mybox");
mybox.y += 10;

Here’s a very simple demo based on the game idea above, links to the demo and source code are below.

demo4-physics

View demo and download source code

VizualPV3DPhysics
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s