Jump to content

  • Log In with Google      Sign In   
  • Create Account


Questions about collision detection


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Dustin01   Members   -  Reputation: 108

Like
0Likes
Like

Posted 15 March 2012 - 04:58 PM

I'm fairly new to the world of 3d programming, so please forgive me. I cannot really find any good tutorials on 3d collision detection (i'm using Lwjgl), but I think I have it somewhat figured out on my own. This is how I would do it: each update, check the coordinates of the object against the coordinates of the other existing objects. If they intersect, do the event. For example, if a player object intersected a wall, set the player object's coordinates to the outside coordinates of the wall, therefore making it appear solid. Is this somewhat the correct way to do this?

Sponsor:

#2 elanthis   Members   -  Reputation: 126

Like
0Likes
Like

Posted 15 March 2012 - 06:12 PM

3D collision detection is fairly complicated. 3D collision response (fixing the collision after detected) is very complicated. Doing interesting physics with these events (from bouncing balls to complex constraint-based physics) is insanely complex.

There are a number of books on the topic. There are also Open Source libraries to learn from, such as Bullet.

If you're looking to use physics without digging into the details and writing it all from scratch yourself, you are far better off using an existing physics library. Bullet is quite serviceable. There are others. If the game is a free/hobby project, I believe you can even use Havok or PhysX freely.

#3 Krohm   Crossbones+   -  Reputation: 2964

Like
1Likes
Like

Posted 16 March 2012 - 01:48 AM

Is this somewhat the correct way to do this?

It is the correct way to do it. Well, it was.
It is no more considered sufficient those days and a lot, a lot of things can go wrong. Trying to make my physics subsystem (back when physics engines were new) is possibly the 2nd major error I did. The 1st is spending too much time on terrain algorithms.
I strongly suggest to find bindings for some ready to go physics library and the language of choice.
Let me elaborate.

If they intersect, do the event. For example, if a player object intersected a wall, set the player object's coordinates to the outside coordinates of the wall, therefore making it appear solid.

I take for granted 'do the event' means something involving to notification and re-positioning.
Here are a few things that could go wrong:
  • Quantum tunneling: timestep is too long, collision is missed
  • Quantum tunneling (opposite encroaching vector): collision is detected but encroaching is so deep the object is pushed out the wrong side
  • Instability: when it comes to floors, the object will continuously "jump" on top.
Even with a ready to go physics library, (3) has been a serious concern for me. I have managed to hide this for the time being but it's only a duct-tape solution... and I still have no idea on how to fix this.

#4 Dustin01   Members   -  Reputation: 108

Like
0Likes
Like

Posted 16 March 2012 - 09:57 AM

Thanks for the advice, guys. I'm going to look into the Bullet physics engine.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS