Sign in to follow this  

3d pool game. need help

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm doing a project in which I have to make a 3d pool game. I'm using dev C++. I'm new to OpenGL and so far I've managed to make a reasonable pool table and a bunch of cubes that are intended to be pool balls(I don know how to make spheres)and pool cues. The problem I am having is that I need to get collision detection to work on game. I have to get the balls to move and hit off each other. I've looked through the net And found a few collision detection codes but I don't know how to put it into my project. I don't know whereabouts the different lines of code are supposed to go into in a project. Whenever I try to get collision detection to work I just get a whole load of errors. I've managed to get a pool cue to move but moves in and out and right and left but I think in reality though its just everything else thats being moved. Could anyone help me with getting at least getting one object to hit off one another?

Share this post


Link to post
Share on other sites
If you want to stay simple, use a 2d simulation. That way you need only circle-circle collision and circle-plane collision. Both of them are trivial. The circle-circle is just if(c1.rad+r2.rad<dist(c1,c2)). If the planes are horizontal or vertical, just test for the distance from the circle to the plane's x or y component and compare to the radius of the circle.

As for drawing spheres, there's a function for that in the glu library.

Share this post


Link to post
Share on other sites
Well I don't really understand what you're asking here. You have already found some samples on net that do collision detection, you just don't know how to integrate them to your project. I understand this is a problem, but I don't see how we can help here, even if someone offers you some code that solves collision detection and response, you'll still have the same difficulties as before to use it on your project.

Try to read the code you got, understand what it's doing. It's not necessary to understand all the math and physics formulas, just what it's doing and how, in general terms. Once you do that, you'll be able to merge it to your project.

Share this post


Link to post
Share on other sites
"What is this for? If this is for school didnt they teach you this stuff already?"

Its for my theses.I'm required to research and learn opengl from scratch. I have no prior experience with 3d programming, so this is quite challenging for me. Any advice, tips or comments are appreciated.

Share this post


Link to post
Share on other sites
Hey theres tons of info on this. First the subject area is physic so look around for open source physic library or get a pyhisic book and start reading get the ideal of whats happing here and there in collision theres an article on this site about it too. When i was a senior i create this 3d pool game also it was fun. To make sphere in opengl use glu.h it has a method for creating them and curved surfaces. you can get real detailed withit like i did and calculate the force and torque of the ball find its angle

Share this post


Link to post
Share on other sites

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this