Page 1 of 1

how to make a ball roll?

Posted: Thu Apr 07, 2011 8:02 am
by gmotagi
How do I make a sphere roll?

I downloaded a free sphere from turbosquid. Put it in the demo as a sphere. I can see it and everything.
I changed the 'fire button' code to exert a linear velosity on the sphere in the direction of the camera.

(doing this with the demo cube makes the cube slide and collide with static objects btw)

Two things happen difefrently with the sphere.
1. It slides rather than rolls. How do I make it roll?
2. it goes through the walls i made (it has a mass of 1)?

I assume the going through wall thing is some model issue? and reading some other forum posts i think this is a friction issue. If so how do I add friction if thats the rolling 'fix'

Thanks.

Re: how to make a ball roll?

Posted: Thu Apr 07, 2011 6:02 pm
by Norbo
What are you actually supplying the physics engine?

-Is it a Sphere entity?
-Is the sphere extremely tiny (~0.02 units)? Try making it larger if it is super tiny.
-Did you set its LocalInertiaTensorInverse to zero? (it cannot roll with infinite inertia)
-Did you set all frictions to 0? (frictions default to nonzero, so if you haven't changed them, they should be fine, and this would not cause it to go through walls)
-Does the graphic actually match the physics shape? You can use the BEPUphysicsDrawer to debug this.

Re: how to make a ball roll?

Posted: Fri Apr 08, 2011 8:07 am
by gmotagi
Thanks for the reply. I think this is a blender problem although its good to know about those other fields you mentioned. The latest version of blender isnt exporting .fbx correctly I think but I tried with wings3D importing a .x file and I have a rolling sphere now :)

I do have a further question though (well two actually).

1. When I import the sphere it hovers one radius above my ground layer. If I have a scene already set up and this happens with a model whats the correct way to correct it? In this case it rolls and bounces etc but in the air above the scene. its origin is at 0,0,0 in the moddler so If I need to correct it wheres the correct place. Is it where you set the visual entity matrix scale? I tried adding a -0.5y transform to the scale matrix after that line but it went a bit crazy in its behavior.

2. Appart from the basic tutorials in the documentation is ther a site that has some further / more advanced examples anywhere?

Cheers

Re: how to make a ball roll?

Posted: Fri Apr 08, 2011 6:50 pm
by Norbo
If I have a scene already set up and this happens with a model whats the correct way to correct it?
If it's a problem with the graphic transform, then figure out the local transform which brings the mesh into alignment with the entity's shape in local space. Apply that transform first before applying the world transform each frame. Keep in mind that it might not just be the sphere mesh that's incorrect. You could try using the BEPUphysicsDrawer to debug it.
2. Appart from the basic tutorials in the documentation is ther a site that has some further / more advanced examples anywhere?
The source code repository includes the BEPUphysicsDemos project, which has 30+ different demos in it. There's also a little game I made a while back called "Blocks Explode Your Castle" which is a slightly larger integration example. Apparently I forgot to include it on the documentation page; I'll look into updating it. Blocks Explode Your Castle was made over the course of 2 days, so it's not a particularly clean or beautiful game, but it's something :)

Edit: Blocks Explode Your Castle is now up on the codplex documentation page: http://bepuphysics.codeplex.com/documentation

Re: how to make a ball roll?

Posted: Sat Apr 09, 2011 4:32 pm
by gmotagi
Cool thanks will take a look,