About the vertex buffer

Started by
5 comments, last by circlesoft 19 years, 5 months ago
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?
Advertisement
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().
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
So I need to translate the vertices inside the buffer and the vertices inside my array so I can see the vertices location inside my software?
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)
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
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
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.
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.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )

This topic is closed to new replies.

Advertisement