Accurate 3D Pong Physics

Blitz3D Forums/Blitz3D Programming/Accurate 3D Pong Physics

Techlord(Posted 2007) [#1]
Need a little help 3D Math Gurus. I'm nearly complete with my 3D pong game but, unfortunately, I'm stumped on getting the orbs to deflect with proper direction (angle) when colliding with a Walls, Paddles, and other Orbs.

I was referencing this excellent 2D Billiards Style Collision Physics for the basis of 3D conversion. However, I'm using Blitz3D Entity Collision and the orbs travel all directions (XYZ planes).

Needless to say my 3D conversion of the 2D code is not working and my hair is falling out. I have a strong feeling that Im supposed to use Blit3's fancy Collision Normal and Vector functions somewhere in there.

This was supposed to be easy...:(


Techlord(Posted 2007) [#2]
I was able to restore the code back to its working 2D-in-3D conversion.


I desire my game to play exactly like this one.

Any help from the great Blitz3D Masters will be appreciated.


Stevie G(Posted 2007) [#3]
This should do what you require ...

http://www.blitzbasic.com/codearcs/codearcs.php?code=670


Techlord(Posted 2007) [#4]
Stevie G you are very Great!!!


Techlord(Posted 2007) [#5]
Almost there!

I'm using the code provided here. The Orbs wants to continue in the same direction after collision.



Not quite sure on whats needed to adjust the motion vector for proper deflection.


Yahfree(Posted 2007) [#6]
Hmm i used something a while back for a breakout game, you subtract the ball z/x location(however your game is setup) by the paddles z/x position, then you devide it untill its a working math, then you use this to get the balls z/x volocity...

dif# = entityx(ball) - entityx(paddle) / 8

If entityscollide(ball,type_padle)
ballx_dir = dif
ballz_dir = 0.5
End if

Moveentity ball,ballx_dir,0,ballz_dir



Techlord(Posted 2007) [#7]
@Yahfree: Thanks. I'll give it a shot and see what it does.


Stevie G(Posted 2007) [#8]
The above code from Yahfree is nonsense, at least to me ;) ... use a coefficient of restitution like so ...




Stevie G(Posted 2007) [#9]
EDIT : Actually - that does the same as your code - e.g. no reflection and jittery as hell. Seems to be a collision issue which is resolved by moving the orb slightly away from contact.

I made some other changes. Note that there is no need to store the x,y,z position as this is what entityx,y,& z are for. You can then use translateentity based on your velocity vector.




Techlord(Posted 2007) [#10]
@Stevie G: Awesome! I truly appreciate your assistance. Now all I have to do is replace my directplay code.