Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DevLiquidKnight

Detecting collisons in directx 9??

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

Advertisement
Don''t think you''re going to find that. A *.X file can contain (as far as I know) pre-computed keyframe animation, but does not have any logic for collision detection. You could, for example, simulate a collision in 3ds max, record the results to keyframes, then export those keyframes to the *.X file. Then, in your app load the keyframes and play them back have the appearance that a collision was detected in the app, when in fact it was computed totally outside of the *.X file and the game app.

That said, you can store geometry in the *.X file that would be a proxy collision body, for example, an artist-built oriented bounding box.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Is there some other way someone can do this using a 3ds file then? Maybe anyone who has used a 3ds file importer of some sort has found something along this line that could post

Share this post


Link to post
Share on other sites
you don''t get collision detection from the models/files, you include it yourself in your code... i could have missunderstood the question. i sure hope so.

Share this post


Link to post
Share on other sites
Yea, I know you don''t get them from the file themself. Im trying to figure out how to use the data I get from the file to setup the collsion detection in the code ? Maybe ill try to find a tutorial on somthing like setting up a bounding box on the camera to detect for collisons or somthing?

Share this post


Link to post
Share on other sites
.x file or not, all you need is a list of triangles.

there are 100s of ways to make it work but you can summurise it to a few steps.

1) bind a tree to the triangle list. This is not necessary, but if you don''t want the thing to run at 2 fps...BSP tree, AABBtrees, lots of trees...

2) Decide what kind of volume you want for the camera. The simplest is a sphere.

3) have a tree/sphere algorithm, that returns either the first triangle hit, or a list of triangles near the sphere.

4) test collision between the sphere and the triangle(s). That should return either, points of intersection, or the time of collision, if you use a swept test.

5) apply a response to the sphere, to make it bounce on the geometry.

you can have a look at this as an example.

Share this post


Link to post
Share on other sites
quote:
Original post by DevLiquidKnight
Yea, I know you don''t get them from the file themself. Im trying to figure out how to use the data I get from the file to setup the collsion detection in the code ? Maybe ill try to find a tutorial on somthing like setting up a bounding box on the camera to detect for collisons or somthing?


Oh, that clears thing up a bit. Hopefully you will find oliii''s summary post helpful. There are a couple of good articles over at gamasutra as well:

Gamasutra


Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
DX9 does come with some helper routines for collision detection using meshes.

Bounding volume generation:
D3DXFrameCalculateBoundingSphere, D3DXComputeBoundingBox, D3DXComputeBoundingSphere

Intersection test functions:
D3DXIntersect, D3DXIntersectSubset, D3DXIntersectTri, D3DXSphereBoundProbe, D3DXBoxBoundProbe.

You won''t get automatic collision detection, you will still have to figure out how to use these functions to your advantage, but they return quite a lot of information such as the closest intersection point, the triangle that was intersected for the ray/mesh tests, the subset that was intersected, even the u,v texture coordinates of the intersection.

As long as you don''t mind making your collision detection system dependent on DX, these are quite useful

Peace

Share this post


Link to post
Share on other sites
The fasted way to see if 2 3D objects collide, is to use Sphere collision detection.

You can use D3DXComputeBoundingSphere , to get the radius(1) of your xfile object and then set a radius(2) for your camera.
After this, calc. the distance from your camera to the object.
Now you can check if they collide :

if (distance > radius1 + radius2 ) then
Collide
else
No Collide


Hope that helps

Share this post


Link to post
Share on other sites

  • 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!