Mouse Constraints using Jiglib AS3

Actionscript Jiglib AS3

JiglibFlash is a great physics engine for the flash platform. Combined with Papervision 3D you can do some amazing stuff. The library has been recently updated and now not only contains a car physics model, but mouse constraints. The mouse contraint can add a new level of interactity to your scene.

I’ve been dying to try it out, and finally after moving house i finally got my lil studio / junk room setup. Below I have created a basic scene in which several block fall from the sky on init. These can then be picked up and thrown, interacting with other objects. Just a finishing touch I Though it would be good to have shadows. The code of which is from the brilliant Andy Zupko (Article on shadow casting). Anyway, I’ve provided the code below with ample commenting.

View Demo

Download JigLibFlash

Download Papervision

Download source

Tags: , , , , ,

You can leave a response, or trackback from your own site.

6 Responses to “Mouse Constraints using Jiglib AS3”

  1. mat

    hey, the example looks amazing,
    I’m trying to test it and play around with it on my pc, but I keep getting this error,

    1137: Incorrect number of arguments. Expected no more than 3.
    FlatShadeMaterial = new FlatShadeMaterial(pLight,0×999999,_BOX_COLOR,2);

    any ideas?

    thanks!
    ~matt

  2. admin

    Hi Matt, I’m glad you like it.

    I’ve checked the docs for FlatShadeMaterial and I Cant see any obvious reson why it would error here.

    Which version of papervision are you using? I tend to check out from the svn. In any case I have zipped the version of the libraries I used up and uploaded them here.

    Give these a try and let me know how you get on.

    Dave

  3. mehpac

    Hi, thanks for the great example, I’m new to this (jiglib, not pv3d) and I’m facing all kind of problems..

    I just downloaded Jiglib via SVN on googlecode, but I noticed jiglib.plugin.papervision3d.constraint.MouseConstraint DOESN’T come with the source…

    I downloaded the MouseConstraint Class elsewhere and copied it into the correct location, but now I get all kind of errors, like JNumber3D now doesn’t accept any parameters but in MouseContstraint it pases 3 parameters to it (JNumber3D(mouse3D.x, mouse3D.y, mouse3D.z))

    What do I have to do to get this example to work ??

  4. dave

    @mehpac Hi, i’ve looked through the code and noticed that the constraint plugin is only in the fp9 branch of the code. The same library doesnt seem to exist in the fp10 yet.

    the docs for the fp9 plugin can be found here:

    http://www.jiglibflash.com/docs/jiglib/plugin/papervision3d/constraint/MouseConstraint.html

    I hope that helps, if you’re still having problems let me know.

    Dave

  5. mehpac

    Hey Dave, thanks a lot for your response, the problem is I’m creating a FP10 based project, so it’s impossible to target FP9 for this one…

    What I want to achieve is pretty simple actually, I want to have some cubes (lets say 4) to be able to be dragged and dropped by the user.

    Almost like your example…

    I’m sure there must be another way to do this, any ideas where I should begin ?

Leave a Reply