Archived

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

DevLiquidKnight

Bounding box collison detection in direct3d?

Recommended Posts

I have a fairly good understanding how a 3D collision detection works with 3d as far as a box like collsion detection method. What im not sure on how to do though is figure out how to place boxes across a mesh based on its vertex buffer? You like when you use AABB collision detection I know this method may not be the best to use, but sense im only looking to do something simple this will work for now. Does anyone know how I can determain where to place specific bounding boxes to the terrain based on its vertex buffer? I know this is kinda how AABB's work but im not entirely sure how to grab the vertex buffer data and read it in a sense that I can determain what area to place a node. I read some information on flipcode but I really need some better insight to this. So if anyone can help it would be great and im doing this with .x files just because its simple even though, yes I could use something better for a game but im not looking to get into something as complicated as that right now, just looking to make a simple 3d collsion detection using simple stuff I know to get the VB of a mesh you simply do something like: g_pMesh->GetVertexBuffer(&m_pLevelVB); after this how do I read the vb though? I also know i can use D3DXComputeBoundingBox ?? but Im not sure how to use it and what I can do with it it says it: Computes a coordinate-axis oriented bounding box. But how excatly can i use it? [edited by - DevLiquidKnight on March 20, 2004 8:11:45 PM]

Share this post


Link to post
Share on other sites
D3DXComputeBoundingBox is pretty straight forward. you pass your vertex data to it, with the number of vertices, and the format of the vertices, it returns the diagonal points of the box (Min and Max).

I''m not a directX specialist, but I''d guess you have the vertex buffer, grab the raw data from it (I assume GetPrivateData()), along with the vertex format, you''ll probably also need an index buffer associated with it, depending on the format of the data (triangle index list, triangle strips, fans, ...), then reconstruct the surface yo uare interested in, ect...

I''d suggest you build your own collison map outside the vertex data (basically pre-process the mesh and build your own collision mesh structure). You''ll need some space partitioning structures, ...

for a terrain, if it is based on a heightmap or grid, you can accelearte the collision detection by using the heightmap directly.

Share this post


Link to post
Share on other sites
yea i know and understand most of all that just not sure how to read the data if there was only some way to get each vertex individually from the mesh and then move to the next vertex ect.. Im not sure how to though..

Share this post


Link to post
Share on other sites