Jump to content
  • Advertisement
Sign in to follow this  
Stowelly

issues with bounding box alignment

This topic is 4383 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

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
Advertisement
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
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!