Skip to main content
gamedev.net
🔒 Locked

Collision Dedection Math / problem

Started by MJAY Mar 13, 2005 at 7:00 AM 0 replies 750+ views
Original Post
MJAY
MJAY
Hi, i'm trying to make a billard game without using ANY engine! But currently, i do not use any billard table :) I'm just trying to implement the basics. So if i can complete this step, making it a simple billard game won't be too hard as i think. Currently at least for testing purposes i have a Plane object. This object holds 4 vertices in an Array ( in fact quad object ) The system has gravity on. Currently what i'm trying to do is: Adding planes to world ( just defining vertices, adding it to world and drawing ) my ball should hit these planes. In fact, i did it, but it's not perfect. If i just reflect the ball's velocity, it's almost ok.. But this is a hack! So i don't want to just do it. If you don't apply any force. It hits to ground. Problems: I couldn't make the system in balance ( forces ) perfectly yet :( Because when it hits the ground, and while it says on ground, ground must apply the same force according to its angle to object. Problem may lie on my technic or on the calculations, floating numbers.. Please now let me explain my code a little. First i apply gravity force every frame to ball. "this->forceIt(TVector(0.0f, -9.8f, 0.0f)*this->get_m()); " Then i start to loop through planes those were added to the world " for(int i=0;i ) if (fabs(distance)<=this->radius) i try to balance the system, do smthg... Currently, it can hit to planes from back and front. But as i said it is not perfect and as i want.. I know that i couldn't explain my idea maybe.. I would want to hear your ideas. Also i'm afraid the problem also lies on the "distance" for example ball's radius is "2.6" for me. And sometimes when i debug. I see that distance is something like "2.535396954" or "2.593435236" .. etc.. I can not do simply a rounding function to round it to 2.6 because it'll fail somewhere else. I'm really stuck on this. I would appreciate any help :( Thank you for reading my question/problem

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.