Sign in to follow this  
Stowelly

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

Share this post


Link to post
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.

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