Public Group

# Extract 6 planes from bounding box

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

## Recommended Posts

I need to create six planes from axis aligned bounding box, so that each plane normal points inside "cube" it creates. If you know what i mean?

I think i got it right for normals that point outside? Do i?

struct Plane
{
float nx, ny, nz, d;

};

std::array<Plane, 6> ExtractPlanesFromBBox(D3DXVECTOR3 bMin, D3DXVECTOR3 bMax)

{

std::array<Plane, 6> out;

D3DXVECTOR3 center = (bMax + bMin) * 0.5f;

D3DXVECTOR3 extent = (bMax - bMin) * 0.5f;

// up

out[0].d  = center.y + extent.y;

out[0].nx = 0.0f;

out[0].ny = 1.0f;

out[0].nz = 0.0f;

// down

out[1].d  = center.y - extent.y;

out[1].nx = 0.0f;

out[1].ny = -1.0f;

out[1].nz = 0.0f;

// left

out[2].d  = center.x - extent.x;

out[2].nx = 1.0f;

out[2].ny = 0.0f;

out[2].nz = 0.0f;

// right

out[3].d  = center.x + extent.x;

out[3].nx = -1.0f;

out[3].ny = 0.0f;

out[3].nz = 0.0f;

// back

out[4].d  = center.z - extent.z;

out[4].nx = 0.0f;

out[4].ny = 0.0f;

out[4].nz = 1.0f;

// front

out[5].d  = center.z + extent.z;

out[5].nx = 0.0f;

out[5].ny = 0.0f;

out[5].nz = -1.0f;

return out;
}


But normals to point inside, i don't know how to calculate 'd' ? Please advise.

##### Share on other sites

Compute it the same way you would compute the bounding frustum for an Orthographic view. Using the max and min of the box you can compute all 6 sides of the box.

• 16
• 11
• 11
• 9
• 49
• ### Forum Statistics

• Total Topics
631394
• Total Posts
2999749
×