Game Development Community

Ball Physics

by Harrison Brock · in Torque Game Engine · 04/25/2007 (9:09 pm) · 12 replies

Has anyone about ball physics to TGE it? Am about to start my ball physics design in a few weeks. Just want to do if anyone has done it before.

Harrison Brock

#1
04/25/2007 (9:33 pm)
ODE and PhysX resources will handle such things, unless you mean you want to steer the ball like the marble in marble blast which can be done with a one-wheel vehicle approach. (with tilt)
#2
04/25/2007 (11:44 pm)
Realistically, the existing physics also work. They need to be cleaned up a bit in order to work perfectly, but if you just want the physics for a ball, it'll be more than sufficient.

See "rigidshape." I'm not going to describe how to fix up the Rigid class here, but there's more than enough info on that in these forums (and it technically works "well enough" out of the box if you just want to recreate a bouncing ball of some kind and don't care if it can, say, knock over a stack of boxes when it hits them).
#3
04/26/2007 (5:38 am)
Thanks...I work on ball physics so that it could be used in a game where you can steer ball and also where the ball could be use for many sport games. So I will have to make more than one ball class.

Thanks for you help.
#4
04/26/2007 (7:35 am)
I am actually starting to work on ball physics myself. I asked around, and the general consensus is that accurate ball physics can only be created by developing a custom class. Start with shapeBase, or even gameBase, and work from there. Ben Garney (namedrop!) told me that the Item physics might be a good template/starting point.

The biggest problem I am encountering is collisions. Torque regards everything as meshes, but for a ball I want to use a sphere to check for collisions. I believe that this was accomplished in Marble Blast. Right now I'm digging into the code and using the collision tutorial object as a reference. Does anybody know of any resources that implement bounding sphere collisions?
#5
04/26/2007 (10:38 am)
I don't know of any resources. The most straightforward way I can think is using a bounding box around your sphere and using the extrudedPolyList to extrude it along velocity and grab the list of polygons which collide with it. Then you read the polygons from the list yourself and perform sphere/polygon tests.
#6
04/26/2007 (12:03 pm)
Here Harry,

That sound like u will be have a lot of fun with that.
#7
05/02/2007 (7:37 am)
This is how I am going about implementing sphere-based collisions. I may be way off, and would appreciate any feedback.

Right now I am just focusing on detecting the collisions. I will worry about response once/if this works.

Let's assume mConvex is a OrthoBoxConvex which contains/inscribes the sphere.

We call mConvex.updateWorkingList( boundingBox, myCollisionMask );
This creates a list of objects that we are testing against.

Now I think that I need to iterate through the objects and in each object, iterate through the (collision hull) polys and use simple sphere/poly collision tests to detect collisions.

Please let me know if I am on the right track of if there is an easier way.
#8
05/02/2007 (8:06 am)
@ Frank- Today is the first that I have the time to start design the ball physics and about to start on two other big projects. I don't think a boundingBox wll work good for the collision. I was think of use the center of the ball and see if hit the ball.
#9
03/12/2009 (3:17 am)
Hi guys,
can u guys update me on the achievements in the direction of ball physics. i plan to work on ball physics for a sports game. Any suggestions are appreciated. thanks very much guys.
#10
03/12/2009 (3:33 am)
The simple easy way to go would be modify the rigidshape class to fit your needs.

The supper duper easy way: I toyed with useing ITEMs for a simple 'toss the ball around' effect with early 1.3version TGE. All that i did was %obj.throw(toy); during the ::onFire function. Also changing the datablock ItemData mass, elasticity, friction, for a more realistic bounce and 'slide' effect. It worked out being a neat effect, without any true overhead and deep reprogramming, all done with scripting.
#11
03/12/2009 (3:43 am)
I dug out the script i used as an 'mockup' test, so you could toy with it if need/want. Seems it took a tad more then i mentioned above.




#12
03/20/2009 (9:15 pm)
Thanks Caylo, i will try that.