Sign in to follow this  
Prog101

3D car DirectX Bounding box problem

Recommended Posts

Hi there, i am creating a 3D car demo (DirectX/c++) and i am having a little trouble with my bounding box volumes, when i create it for the car i pass the mesh through to my model class and that works fine for the car but when i try it for the ground i get nothing. I have put a link on for you to download the code and project, you will see when you run it that the car is in a bounding box, but the ground is not. How can i get around this? http://homepage.ntlworld.com/j.power40/html/zipfiles/3DCar.zip [Edited by - Prog101 on October 6, 2006 1:03:41 PM]

Share this post


Link to post
Share on other sites
This kind of code might be helpful for you:

HRESULT hr;
D3DXATTRIBUTERANGE *pAttr;
DWORD dwNumAttr;
pMesh->GetAttributeTable(NULL, &dwNumAttr);
pAttr = new D3DXATTRIBUTERANGE[dwNumAttr];
pMesh->GetAttributeTable(pAttr, &dwNumAttr);
IDirect3DVertexBuffer9* pVB = NULL;
void* pVertices;
V_RETURN(pMesh->GetVertexBuffer(&pVB));
V_RETURN(pVB->Lock(0, 0, &pVertices, D3DLOCK_READONLY));
for(int i=0;i<dwNumAttr;i++)
{
V_RETURN(D3DXComputeBoundingBox((D3DXVECTOR3*)((BYTE*)pVertices+(pAttr->VertexStart*pMesh->GetNumBytesPerVertex())), pAttr->VertexCount, pMesh->GetNumBytesPerVertex(), &BBoxMin[i], &BBoxMax[i]));
pAttr++;
}
pVB->Unlock();
SAFE_RELEASE( pVB );


It goes through all the meshes attribute groups / materials and calculates there bounding boxes.

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