Click to See Complete Forum and Search --> : moving sphere to stationary sphere collision


vtgyrlz619
June 6th, 2004, 04:50 AM
Hi

I've researched a lot of ways to implement a moving sphere to a stationary sphere collision detection..
but I can't start because I don't know how to keep track of a moving sphere's center.

So I'm doing this game that is a clone of "Bust a Move" where there are bubbles at the top and an arrow with a shooting ball at the bottom center.. and u press a key to shoot the ball to hit the balls at the top...

Well I know the position of the shooting ball (it's on top of the arrow) and I just use glTranslatef .. to shoot the ball, however, it doesn't update the ball's center..
Here's a clip of my code.. I know that I actually do explicitly SET the ball's center to 0 0 0 but I thought that with the glTranslatef.. it actually moves the ball and updates the points (I do see the ball moving .. so the translate actually works)

printf("shoot %f \n", shoot);
Balls[ball_num].ctr[0]=0.0;
Balls[ball_num].ctr[1]=0.0;
Balls[ball_num].ctr[2]=0.0;
glTranslatef(tempx,shoot,tempz);
drawarrowball();

Please help.. how do I get the center of the moving sphere to update?

wien
June 6th, 2004, 12:33 PM
Can't you just update the position as the animation proceeds? You must at some point know where the ball should be translated, so saving it's position at that point shouldn't be a problem.

vtgyrlz619
June 6th, 2004, 04:42 PM
Hi

Well there's a problem because.. the location of the ball .. is different.. What I did was used glBegin(GL_POINTS) to draw a point at the center of the ball.. So the vertices of that point is 0,0,0 (center of the ball) however the position of the ball is at 0,0.3,0 (passed into glTranslatef() to translate the ball at that position).. these two points are not the same..
if i draw the point at 0,0.3,0 then the point is a good amount above the position of the ball..

wien
June 6th, 2004, 05:07 PM
Umm.. I really don't get it. If the ball has the position 0,0.3,0, it's centre should be at those coordinates also, and that's where you should draw the point, right?

Could you post your entire draw function to help me along a little? I don't really see the problem here.