Collision box for AS3 + papervision3d + jiglib

824 views Asked by At

I'm trying to recreate the "tutorial" explained on the site below. It's 5 dices bouncing around on the scene. But i'm stuck at the very beginning :)

papervision3d-jiglib-dice-demo

My problem is the bounding box. I want to create a box with a floor and 4 walls based on the size of the stage. I can get it the right size using zoom/focus on the camera. But the problem is the dices go through it.

How can i build 4 walls and make sure a dice doesnt go through it when i apply forces to it?

I tried the solution in the following source, but somehow the dices keep going through :(

throwing-dice-with-the-jiglib-physics-engine-and-away3d

Anybody knows how to do it? Or a better way to keep the dices on screen?

1

There are 1 answers

0
Hugo Delsing On BEST ANSWER

I solved the problem. Just to share with others who want to try the same:

  • Set camera zoom = 2
  • Set camera focus = distance / zoom
  • // now the scene width and height match the actual size of the stage.

  • add the planes for all sides and make sure you make the segments smaller then the dice size. (EG: dice size = 30; stage width = 300; segments = stage width/ dice size = 10).

  • make sure you ceil the results because segments require int
  • Ofcourse you can make it larger, but then it will be harder to render.
  • I made the height of the planes a little smaller then twice the dice size to make sure they never get on top of eachother.

  • And finally add a ceiling by placing another plane with small segments on top of the other planes