ball physics

Hello, I am try to make a ball bounce around in an enclosed box. So far I have used ODE and OdePlaneGeom to make the floor. I have given the ball an OdeBody and OdeMass so that it is bouncing on the floor OK. I am wondering how to do the sides though, when I used OdePlaneGeom I gave it a vector and the floor just happens to be on the origin so it worked. However the sides of the box are obviously not on the origin, how do I move the plane somewhere else? I realise you can attach it to an ODEbody for dyanimc objects, but the walls of the box aren’t really dynamic.

Well, you could just use an OdeBoxGeom to make the walls (as well as the floor, actually). You can place it normally around the scene.

I thought about that, it just seems a strange way of doing things. Is it best to use ODE or should I just handle the collisions myself, as in the ball-in-maze example? I am actually making a football game, so in the future I will need the ball to bounce off players, etc.

Well, it’s actually not. It’s the simplest and most flexible way.

Which is the most vital information here.

To do it right, you would need continuous collision detection (among other things), otherwise the ball might tunnel through your players, and ODE doesn’t provide that. Panda’s internal collision detection does, AFAICS in the manual now, but it seems quite limited and I’m not sure if it work with physics.

Unfortunately, I know that Panda’s PhysX wrapper doesn’t have that too. I’m not sure about the Bullet integration enn0x is working on, so you might want to take a look there, but note that it’s more experimental than bullet itself ATM.

Still, though, Bullet or PhysX are probably your best bets anyway. I haven’t used Panda’s internal systems, so I can’t speak for them, but as far as ODE goes it would probably not work for you. Aside of the aforementioned limitation, ODE doesn’t support rolling friction and you would have to deal with that yourself, and I guess that’s something you really need.

Do you mean that in one step of the physics system the ball might be on one side of the player, and in the next it might be on the other side and ODE wouldn’t notice?

By rolling friction do you mean a ball turning in the air should boucne off at a certain angle when it hits a surface? I did notice that this isn’t working in my game, I guess I will have to do it manually.

Precisely. ODE (and Panda’s PhysX wrapper) is limited to discrete collision detection, so it only checks for collisions in frames, not between them.

Obviously, if you set your steps to be very small you should be fine. Should is the key word here, though.

And more than that. The spheres also have trouble stopping. They just spin forever. Even if they hit a wall they will only stop sliding (as in moving forward on the ground), but they will spin on.

Spheres in ODE also have a tendency to sink into trimeshes, but I’m sure you wouldn’t use these (given the game genre) so it’s just FYI.

So, as you can see, ODE is really not the best choice for this kinda game. Obviously, you can deal with everything by yourself (I’ve written a lot of additional stuff for ODE, which is published on the forum) but it will never be as reliable as PhysX or Bullet. This is not an issue in a shooter, for instance, but in a sports game you just need stuff to work in a correct and predictable way.

To be honest, the physics don’t really matter that much, I’m probably going to be concentrating more on the AI of the other players. I was really just getting a bit confused by the fact that some examples use ODE and autoCollide and some use panda3d’s collision detection. I was thinking that perhaps ODE provided a more realistic simulation but from what you say it doesn’t.