Dettect when a Cylinder is rolling on the floor(vertex mesh)

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
jbosch
Posts: 43
Joined: Sat May 29, 2010 4:42 pm
Contact:

Dettect when a Cylinder is rolling on the floor(vertex mesh)

Post by jbosch »

Hi there,

I've seen there are built in events to control collision between entities. I'm developing a bowling game and I check collisions between the ball (sphere) and bowls(cylinders). I also detect collisions between bowls(cylinders) and the floor(triangles).

That way I can play different sound fx in each situation.

I also need to dettect when a cylinder is rolling over the floor, do you have any idea how to do it in a "solid" way?


Thanks,

Jesús Bosch
Jesús Bosch
XNA BLOG: http://geeks.ms/blogs/jbosch
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Dettect when a Cylinder is rolling on the floor(vertex mesh)

Post by Norbo »

Pin.OrientationMatrix.Up.Y will be close to 0 if it's rolling on a horizontal floor. It would be a good idea to test to see if the entity's collision pairs have any contacts as well, to ensure that it's not flying through the air.
jbosch
Posts: 43
Joined: Sat May 29, 2010 4:42 pm
Contact:

Re: Dettect when a Cylinder is rolling on the floor(vertex mesh)

Post by jbosch »

That way I'll know when the bowl is lying, but not when it is rolling, isn't it? sorry because of my bad English :-P

When I mean rolling, I want to say that the cilinder falls to the ground and rolls during a short period of time
Jesús Bosch
XNA BLOG: http://geeks.ms/blogs/jbosch
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Dettect when a Cylinder is rolling on the floor(vertex mesh)

Post by Norbo »

Once it's established that it's on the ground, the velocity can be tested. Dotting the angular velocity around the entity's Up vector would give you its rolling velocity.

Linear velocity could also be used. If the entity's Up vector is horizontal, you can use it as one of two horizontal movement axes. The other horizontal axis would be the up vector crossed with the floor's normal.

Dotting the linear velocity with each axis would give you the velocity along that axis. This isn't necessarily 'rolling' velocity, since it could be sliding without rotation. Linear velocity along the up vector would be definitely sliding.

To determine if linear velocity along the other horizontal axis means it's sliding or rolling, you could compare the velocity along that axis to the rolling angular velocity (angular velocity dot up vector, as mentioned earlier) magnitude times the radius of the pin. That is the velocity of a point on the surface of the pin moving due to angular velocity.

In other words:
Rolling angular velocity = w dot up
Point on surface velocity due to entity angular velocity = rolling angular velocity * radius

Horizontal sliding axis 1 = entity.OrientationMatrix.Up;
Horizontal sliding axis 2 = floor normal cross horizontal sliding axis 1;

Sliding velocity axis 1 = entity.LinearVelocity dot horizontal sliding axis 1;
Linear velocity component axis 2 = entity.LinearVelocity dot horizontal axis 2;

sliding velocity axis 2 = point on surface velocity due to entity angular velocity + linear velocity component axis 2;

You don't have to use all of that information, but you could combine/use parts of it in different ways to get different effects if you wanted.
Post Reply