# issues with bounding box alignment

## Recommended Posts

ok ive created a bounding box for each of my objects in the scene using the following code
pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)&v);

D3DXComputeBoundingBox(
(D3DXVECTOR3*)v,
pMesh->MeshData.pMesh->GetNumVertices(),
D3DXGetFVFVertexSize(pMesh->MeshData.pMesh->GetFVF()),
&boundMin,
&boundMax);

ComputeBoundingSphere(pMesh->MeshData.pMesh,&boundingSphere);

pMesh->MeshData.pMesh->UnlockVertexBuffer();

pTempMesh = NULL;

D3DXCreateBox(
device,
boundMax.x - boundMin.x  ,
boundMax.y - boundMin.y,
boundMax.z - boundMin.z,
&pTempMesh,
0);
}
it translates using the same translation matrix as the object, now on some of the meshes (tiny.x and a sphere i exported from 3ds max) the bounding box renders corectly covering the whole of the shapes but on 2 of the other shapes in my scene (a box i exported from 3ds max and a teapot i exported from max) the box seems to be very unaligned, (ive centred the objects in max by using the X,Y,Z params at the bottom of the screen (not sure if theres another way to do it that im missing) heres a screenshot of what is currently happening ive tried to get a look where all objects are visible http://img358.imageshack.us/img358/653/bounds3tv.jpg

bump

##### Share on other sites
would creating a bounding mesh in max relative to the object and then exporting them solve this?

##### Share on other sites
Since the models from MS work, but bot the ones you are exporting, my guess is that your models are exported with a right hand coord system (the default for 3dsmax), but DX default is using a left handed system and this might be throwing things off. I switched to the Panda exporter which lets you choose left handed, and it fixed a lot of my problems.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628275
• Total Posts
2981760

• 10
• 11
• 17
• 10
• 9