Jump to content
  • Advertisement
Sign in to follow this  
ProfEich

Sphere x World - Collision & Physics

This topic is 4356 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

Hi. I've got two little questions that require big answers - I guess. The first question: I've got code for "Sphere x Line" collision and for "Triangle x Triangle" collision. But is there also a simple code for "Sphere x Triangle"? Would be easier to use than checking every triangle of the sphere. And the second question: Well. After I know that the ball collide somewhere, I need to find out how it bounces. The ball must be able to start rolling down somewhere or to bounce from edges. The ball must be able to collide at walls, ceils and floors and bounce correctly. If it's just lying on the floor, it shouldn't bounce. If the floor is a slope the ball should start to roll down. I guess you know what I want. How to calculate all these physics? Thanks for every help :)

Share this post


Link to post
Share on other sites
Advertisement
First of whats your intentions? Do you want to make a game, do you want a physics engine or do you just want a bit of theory?
If it's the former I highly recommend you to use an existing physics engine like ODE. The reason for this is that it will take many months to create what you want. It was a few years since I did exactly what your asking so I'm a bit ruty on the subject but if i would do it again I would go with an existing engine.

Now to you questions. If you search for 'triangle sphere' collision you should find a few good sources. But you need to know what you want. Do you need to known just that they have collided or do you also need to know penetration depth?
The later is a bit harder but most physics engine needs that information. Anyway you basically you have 7 cases that needs to be taken into account. Inside the triangle, hitting each edge, hitting each vertex. Using a SAT (Separating Axis Theorem) to test each case.

For the later question you really need to go and buy some physics books for this. The problem of rolling firction is a though problem to solve and it isn't getting easier on a triangulated surface.

I don't want to kill your entusiasm I just want to make sure you know what your getting yourself into. So you do start doing something that will eventually make you give up on your game idea. Physics is a very fun subject but there are a lot of hair tearing moments to go through..

Share this post


Link to post
Share on other sites
Hi, thanks for your fast answer.

Yes, it's for a little game. Well using an existing physics engine was one of my first ideas, too.
I didn't take much time to read through the features of them, so I don't know whether some of the physics engines support all features I need or not.

Is it useful for my game idea to use ODE (i.e.)? Well, collision detection IS implented in this engine. But is the engine also useful for the ball movement (or basics of them)?

Would be nice to have something I can implent fast and easy. :)

Share this post


Link to post
Share on other sites
Quote:

But is the engine also useful for the ball movement (or basics of them)?

Quote:
ODE home page
It has advanced joint types and integrated collision detection with friction.


Sounds like it has what you need: collision detection and response with friction. So if a ball is on a slope, it will roll.

If you're going to make a physics engine on your own, be prepared to put off your game idea for at least a few months.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!