Inaccurate bounding box

Started by
1 comment, last by cozzie 10 years, 4 months ago

1466313_795805073779182_1936955470_n.jpg


Don't know why it happens, is it because i scale the model?


void Direct3D::buildAABBFarm()
{
D3DXCreateBox(pDevice, Farm.box.GetWidth(), Farm.box.GetHeight(), Farm.box.GetDepth(), &AABBFarm, 0);
 
 
}
 
void Direct3D::buildFarm()
{
LoadXFile("Main\\Models\\Farm.x", &Farm.mesh, Farm.mtrls, Farm.textures);
 
VertexPNT* v = 0;
 
Farm.mesh->LockVertexBuffer(0, (void**)&v);
 
D3DXComputeBoundingBox(&v->pos, Farm.mesh->GetNumVertices(), Farm.mesh->GetNumBytesPerVertex(), &Farm.box.minPt, &Farm.box.maxPt);
 
Farm.mesh->UnlockVertexBuffer();
 
D3DXMATRIX World;
D3DXMATRIX Scale;
 
D3DXMatrixTranslation(&World, -82.85f + 29.0f, 40.50f + 50.0f, 39.44f);
D3DXMatrixScaling(&Scale, 0.01f, 0.01f, 0.01f);
 
FarmWorld = Scale * World;
 
 
}
Advertisement

Any transformation applied to the model should be applied to the bounding box, assuming an object space bounding box.

Jep, also keep in mind that you "recalculate" it when you scale or rotate the obb.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

This topic is closed to new replies.

Advertisement