Ball and Board questions.. jmePhysics2

Just implemented jmePhysics2 to try and completely a school project, which is basically a simple Labyrinth game.

We are having an issue right now:

First of all, the board which the ball rolls on is made up of multiple smaller boxes. This is so we can generate a board from a text file, and have parts of the board missing (places where the ball can fall through).

Now, the node which holds all of those smaller boxes is attached to a StaticPhysicsNode, not a DynamicPhysicsNode. This is because we don't want the ball affected the board at all, only visa-versa. But because we are using StaticPhysicsNode, we can't use joints. This was a problem since the player has to be able to rotate the board to roll the ball in a desired direction. So instead, we are using setLocalRotation to manually rotate the board. This seemed to be okay, except there is one big glitch:

If we are rotating the board while the ball crosses over two of the small boxes (there isn't a visible gap between the boxes or anything, they are placed directly next to eachother), the balls bounces into the air. Very frustrating for the player.

I have a feeling the solution is either going to be a different method of rotating the board, or using a trimesh for the board instead of multiple boxes… but I've already written a map generator for this, if there was an easy solution it would be awesome. Either way, any input would be greatly appreciated!

There are some other guys trying to do just that, but I cannot find the post right now  ://

Have a look at TestMarble (in jME Physics 2) it kind of does what you want to have, I guess. Using static nodes for the board is not a good idea, as your board is rotating. If you want to have a smaller gravity effect on the board raise the mass of it a little bit and make the joints stronger.

What about locking transfoms on the smaller boxes?



Or using an update listener to tell if the ball 'bounced' and resetting the Y value?

Wait I think I realized it's not just when the ball crosses over seperations in the boxes, it's actually other times too. Which means the problem is strictly to do with how I'm rotating the board.

Hmm… I know, I can use joints, and turn gravity off on the board. But even so - when the ball hits a wall attached to the board, the whole board jolts. If I set the mass of the board way high, that kinda works, but then the board is impossible to move around.

Maybe post a test case?

I have been thinking (for a change ;)) and considered that, if instead of rotating your board, you rotate the gravity force, the bounding boxes would still be axis aligned and work perfectly (you would also have to change the camera to give the illusion of rotating the board, but that is not that bad)…



But maybe this solution is not good for you, but only for the other guys who were doing their own calculations without jme-physics…  :expressionless: