Collision detecting

Hi,

I am learning 3D with LWJGL and I’ve got some rendering done, but my question is how do I detect collisions? I’ve read about AABB but I think that only applies to stuff that’s on a fixed grid, but I want all of my shapes (cubes and such) to be moveable without a grid.

Thanks!

Try out a physics engine. There are tons out there!
Here’s just one!
And another (2d)!

I only need collision. If you could point me in the right direction (like AABB or so?) I’d be happy. :slight_smile:

Well, unless you want to write your own physics engine (do not, and I mean DO NOT do this), you have to use physics engines. That is pretty much what they are for, if you aren’t using something like aabb. I would just use JBullet and be done with it.

AABB and things like it require the shapes to be A: cubes, and B: fixed to a grid.

Relevant tutorial

I’ve never actually done it myself, but this site looks good:
rocketmandevelopment.com/blog/separation-of-axis-theorem-for-collision-detection/

That is a good link! Thanks! But if you are looking for something that is more precise, I would still suggest you use jbullet. That is a great resource though. +1

Very true, a good physics library would work. I just wouldt like the extra “bloat” it would add from the unused classes!

That ‘bloat’ is delete able :slight_smile:

Sometimes, sometimes some libraries (actually most) have dependencies on other classes, so if you delete a class, others will stop working, even possibly the one you’re trying to use!

No, see, just using a physics engine because you can, is doing it wrong. Yes physics engines have collision checks but its a small part.
Do not use a physics engine just because you need collision checks.
Actually there are many many many many cases in which having a physics engine as opposed to just collision algorithm would make everything harder to code.

most games have “physics”, HOWEVER physics engines are mostly for games that want to replicate REAL physics(realistic games) or it is the main focus to play around with physics(angry birds)

we do SAT is one of our games
all of these OBB, AABB, rects, spheres or whatever work just fine without a grid
how often and when you do collision checks is important from the performance point of view
like having a grid and only check collisions among them, then do sphere checks first and only if thats true too, do real collision checks - something like that

AABBs does not require them to be fixed on grids. You can move them as you like.

www.rel.phatcode.net/index.php?action=contents&item=Pyromax-Dax

Anyway, the choice of collision system depends on what type of game you’re making.

What type of game are you making?

I’m not sure yet, I was thinking something in the space or something.

I have another question which doesn’t really relate to this topic but, does anyone know what method Notch used for collision detecting in his 0x10c game? And which vecmath library?
I’ve searched all over the web trying to find that vecmath library, but with no luck sadly.

@Evenscio

vecmath is a separate package aside Java SE. You can get it at java.net/projects/vecmath.
Also LWJGL provides a math library in [icode]lwjgl_util.jar[/icode]

If you’re a fresh developer, I wouldn’t advice you to start with something that huge as 0x10c (Please correct me if you’ve got some experience). I tried it myself, and while it got the basics of the room editor, it lacks so much. My point is that something like 0x10c is very hard because you have an 3D environment that is translatable, scalable and customizable by the user. That takes collision detecting to a whole new level for people who do not have great knowledge on that topic (if you choose to not use a collision/physics engine).

But if you want to try it, try it. You’ll learn a ton, but as said, it requires a lot of knowledge (I gave up on it just because the lack of experience).

Well, I’ve programmed for over 7 years so I’ve got quite a bit of expierence.

@Evenscio

By fresh developer, Simn means fresh in game development. Also if you wanted to try, here’s a tutorial I’ve found.

SVp_p19sX6M

It was made by Oskar Veerhoek and I recommend his full series if you are a complete beginner for 3D OpenGL.

+1 for Oskar, he’s a great teacher. I would also recommend theBennyBox, he has a whole series on building a 3D game engine from the ground up, and then creating a clone of some popular game that I just forgot the name of :confused: One of his latest episodes deals with collision detection, so you could probably take his collision detection theory and apply it in your game, as our engine is probably very different.

It’s Wolfenstein 3D.

Thanks for the link to thebennybox! I’m now following his tutorials and he explains it very well :slight_smile: