Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Game programming

Dynamics Collider for Disc

All about the StoneScript

Dynamics Collider for Disc

Postby SharpShooter » 20 Nov 2011, 09:47

Hi All,
I am new to Shiva3D and I must say that I am really impressed with the engine.
I am trying to create something like Air Hockey. I could get the basic physics to work, but if I use the box collider for the discs, the collisions are really bad. I would like to know whats the best way to set a collider to a disc or a cylinder.

Thanks. :)
SharpShooter
Fresh Boarder
Fresh Boarder
 
Posts: 1

Re: Dynamics Collider for Disc

Postby broozar » 20 Nov 2011, 22:52

compound physics object composed of 5 boxes. maybe this video helps: http://www.youtube.com/watch?v=81r-1E-hwEY&feature=channel_video_title
User avatar
broozar
Platinum Boarder
Platinum Boarder
 
Posts: 3565
Location: Berlin - Germany

Re: Dynamics Collider for Disc

Postby rusty » 21 Nov 2011, 13:36

I have no evidence for this, but when i've imported complex models (concave, etc) the collisions have seemed to work fine even though there are no settings for triangle meshes and convex hulls.


Taking a quick look at the ODE docs, it does handle both...
http://opende.sourceforge.net/wiki/index.php/Manual_%28All%29#Convex_Class

If you go up a little, it also handles capsules and cylinders too. I don't know how ShiVa works internally but it should have the capability even though the GUI doesn't reflect it.
rusty
Expert Boarder
Expert Boarder
 
Posts: 106

Re: Dynamics Collider for Disc

Postby Fraser » 16 Mar 2012, 23:38

This could be done with your own AI physics:
pseudocode for puck with puck collision:
Code: Select all
x1,y1,z1 = gettranslation(puck1)
x2,y2,z2 = gettranslation(puck2)

d1 = x2-x1
d2 = z2-z1

d = sqrt(d1*d1 + d2*d2)

r2 = radius_of_pucks * 2
if(d < r2)
then
   COLLIDED:
   collision point on puck edges is obtained with math.ATAN2(d1,d2)
end


An alternative and easier method (although maybe more CPU) would be to use shiva physics with spherical dynamic bounding bodies for the pucks, centred about the pucks centre, same radius as the pucks. Then lock the angular rotation for X and Z using

dynamics.setAngularDampingEx ( hPuck, 1000000, 0, 1000000 )

if the above does not lock hard enough or it "creeps" then instead use this in each enterframe:

object.setRotation( hPuck, 0, 0, 0, object.kGlobalSpace)

Of course this spherical bounding body would cause the visible pucks to levitate over the table, so you would need to place the visible table (without collider) above an invisible collider object underneath.
Fraser Ashworth,
https://www.cortex7.net
User avatar
Fraser
Platinum Boarder
Platinum Boarder
 
Posts: 1086
Location: Europe


Return to Game programming