3D car DirectX Bounding box problem

Started by
2 comments, last by 51mon 17 years, 6 months ago
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]
Advertisement
Model the box as a separate, named mesh component, and export with hierarchy.

Use the "LoadHierarchy" functions, and do filtering of the various sub-meshes you will encounter inside your load callback.
enum Bool { True, False, FileNotFound };
Sorry to sound like a noob but how do i do that ? Is there any other way of doing it?

[Edited by - Prog101 on October 6, 2006 1:40:36 PM]
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, &BBoxMax));
pAttr++;
}
pVB->Unlock();
SAFE_RELEASE( pVB );


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

This topic is closed to new replies.

Advertisement