Collision detection between DirectX meshes?

A place for people with an interest in developing new shmups.
Post Reply
User avatar
sniperwolf
Posts: 39
Joined: Wed Aug 10, 2005 10:44 pm
Location: Oregon

Collision detection between DirectX meshes?

Post by sniperwolf »

Anyone know of any good resources regarding collision detection in DirectX? I want something per-vertex, and hopefully not just one collision boundary per object [I'd like to have, for instance, boss characters with multiple target locations]. I was considering a way of reading the vertexes into an array when the object was loaded, and maybe finding a way to compare one object's array to another. I have no idea. :P
How do I wrote code?
ynohtna
Posts: 3
Joined: Fri Feb 18, 2005 1:45 pm
Location: Brighton, UK
Contact:

Post by ynohtna »

Collision detection between arbitrary meshes is a highly complex subject. Even more so if the solution must be robust and fast.

Sadly, simply comparing object vertex arrays won't work. If only! ;)

Questions you need to consider include: are these meshes 3D or 2D? Are the collision boundaries fully convex? Can you optimise your data formats for the collision algorithm? Do you want collision response? Do you need to handle swept volumes? Are you certain that a simpler solution (2D bounding volumes in a loose quad-tree, a tagged collision buffer, etc) would not be more appropriate?

Some good references can be found at: http://www.realtimerendering.com/#colldet.

Best of luck - the math can get quite hairy!
User avatar
sniperwolf
Posts: 39
Joined: Wed Aug 10, 2005 10:44 pm
Location: Oregon

Post by sniperwolf »

Well, the advantage is, there's no motion what so ever on the Z axis, so for all intents and purposes, I'm considering everything to be 2D [just rendered with 3D objects], with every vector's Z component to be 0 [well, everything that would matter in terms of collision].

As far as I can immediately tell, there are three reasons to detect collision in my engine thus far:

1. To tell if the player has touched a powerup item,
2. To tell if an enemy, or the player, has touched a projectile and needs to take damage, and
3. To tell if the player has touched the ceiling, ground, or other land and needs to take damage.

For now, for the sake of having something in place, I might just generate bounding boxes / spheres. It's not the prettiest way, but at least it'll give me something to work from. I was looking at your link, and I'll have to read more of it later - darn work! - but it looks very promising. Lots of options. I was entertaining the idea of one of those plug-in physics systems... as much as I wanted to write this entire thing myself, I'm already using FMOD for tracker music loading, I figure one more external system won't kill me. ;)
How do I wrote code?
User avatar
landshark
Posts: 2156
Joined: Wed Jan 26, 2005 5:27 am
Location: Chicago 'Burbs

Post by landshark »

I think you are better off with bounding volumes such as spheres, boxes, and cylinders (you should be able to get away with just boxes).

Here's a collision detection library, not sure of it's speed: http://photoneffect.com/coldet/
User avatar
sniperwolf
Posts: 39
Joined: Wed Aug 10, 2005 10:44 pm
Location: Oregon

Post by sniperwolf »

landshark wrote:I think you are better off with bounding volumes such as spheres, boxes, and cylinders (you should be able to get away with just boxes).

Here's a collision detection library, not sure of it's speed: http://photoneffect.com/coldet/
Yeah, that's what I was thinking.

The bullets / missiles are all either tube or sphere shaped as of right now. The lasers will all be tube shaped, I'm sure.

Ground and floating object collisions could easily be made boxes, without too much "Oh that was cheap, I didn't even touch it!" :)

Enemies and the player ship are the same, everything I have so far is relatively box shaped.

Now, for the sake of making this an actual "Engine", as in people developing games for it other than me, I'll eventually try to make a more refined solution. But, as they say, baby steps. :D

I'm working on a GUI and refining my sprite class right now, and after that I think I'll tackle the collision stuff. Getting ever closer to a public pre-pre-pre-pre alpha tech demo. :)
How do I wrote code?
Post Reply