Collision between 2 balls

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Collision between 2 balls

Post by Serg Nechaeff »

I have 2 balls (3ds models) how can I detect when they touch each other? I have them in 2 different nodes... Thnx in advance!
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Post by Serg Nechaeff »

Maybe I have to calculate the distance between their centres?
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
stampsm
Posts: 142
Joined: Mon Nov 10, 2003 5:52 pm
Location: Las Vegas

Post by stampsm »

possibly that can be a cheep form of colition detection
did you read all of the tutorials one of them talked about colition detection
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

I believe only static collision detection is implemented so far. This enables detection of a model colliding with the map, but not with two moving models. You may want to see about implementing a 3rd party library for detection if you can't wait for a this feature to be implemented
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Post by Serg Nechaeff »

oh... it sucks! i wanted to finish my game in 2 days, it complicates things a bit... probably will go with radius vectors or smth :-/
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

another options is to use ODE oe Tokamak physics engines, there are tuts on the irrlicht page on how to intergrate them with the engine
Guest

Post by Guest »

The solution is sooo simply : Calculate the distance between the centers of your balls. That is dist = ball2_pos - ball1_pos. Add the radius' of the two balls and compare it to the distance. rad = ball1_rad + ball2_rad;

if (dist > rad) --> not colliding
if (dist == rad) --> touching
if (dist < rad) --> intersecting each other

To calculate co-called "dynamic" collision detection, simply advance one frame and test for collision. If they collide, un-do your move ! It's as easy as that...
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Post by Serg Nechaeff »

yeah, thanks, i did that already :) another solution is to use bounding box collisions
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

Oups... the guest was me :lol:
Post Reply