Sign in to follow this  
awside

About the vertex buffer

Recommended Posts

Since directx doesn't handle our geo collison testing, but does handle rotation, translation and all that good stuff, how do we go about doing collison algorithms after the rotation and translation functions have taken place? Is it as simple as pulling up the array that holds all the vertex data we initially gave to the buffer? Basically....Where do we get the new vertex data since we allow directx to do all of the moving?

Share this post


Link to post
Share on other sites
You can't access that transformed data, because it occurs inside of the vertex shader. This means that the changes will not be reflected in your vertex buffer. To do that, you need to transform them in software. You can do this by using D3DXVec3TransformCoord().

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Typically for collisions you use a MUCH simpler mesh... fewer faces, few vertices, and no extra info like texture coords and vertex colors. This simple mesh isn't put into a VB ever. You can apply transforms to this simpler mesh as Circlesoft says, with D3DXVec3TransformCoord(Array)

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Typically for collisions you use a MUCH simpler mesh... fewer faces, few vertices, and no extra info like texture coords and vertex colors. This simple mesh isn't put into a VB ever. You can apply transforms to this simpler mesh as Circlesoft says, with D3DXVec3TransformCoord(Array)
If you want to do per-triangle collision detection, though, you're going to have to do transform the vertices in software. What you recommended is a very good idea, though. You need to test for collisions on multiple levels (before doing the full-blown test). Typically, it goes like this:

(1) Bounding sphere test
(2) Bounding box test
(3) Simple mesh test
(4) Full per-triangle mesh test

Share this post


Link to post
Share on other sites
So directx can help work as a lesser math engine as well then. But you have to use directX math functions on your software so it matchs the rendered version put out by directx?

And ya, I agree on your list of bounding tests.

Share this post


Link to post
Share on other sites
Quote:
Original post by awside
So directx can help work as a lesser math engine as well then. But you have to use directX math functions on your software so it matchs the rendered version put out by directx?
Yep, pretty much. Just use that D3DXVec3TransformCoord() function we mentioned and you should get the results that you want.

However, you have to look at the performance issues here:

-- To perform a single collision test
(1) Lock the vertex buffer
(2) Iterate through every single vertex, and transform it.
(3) Perform the actually collision detection test

And remember, if you are testing for collision between two meshes, you have to perform steps (1) and (2) twice. Needless to say, this is gonna be sllllooooooooooooooooooow.

Perhaps you should take a look into common per-triangle collision detection algorithms. I'm sure they could provide some really good insight as to how to detect collisions accurately, without bottlenecking your entire app.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this