Jump to content
  • Advertisement
Sign in to follow this  

3D car DirectX Bounding box problem

This topic is 4244 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

Share this post


Link to post
Share on other sites
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]

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, &BBoxMax));
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!