CQuadNode::CQuadNode(Vector3f vOrigin, float fHalfWidth) { m_vOrigin = vOrigin; m_fHalfWidth = fHalfWidth; for (int i=0; i<4; i++) m_pChildNode[i] = NULL; m_EntMap.clear(); // set the AABBox m_BBox.Center() = vOrigin; m_BBox.Extent(0) = m_BBox.Extent(1) = m_BBox.Extent(2) = fHalfWidth; m_BBox.Axis(0) = Vector3f(1,0,0); // axis aligned m_BBox.Axis(1) = Vector3f(0,1,0); m_BBox.Axis(2) = Vector3f(0,0,1); // set the bounding sphere //m_BSphere.Center() = vOrigin; // use diagonal of box to get bounding sphere //m_BSphere.Radius() = (Vector3f(max(m_BBox.Extent(0), m_BBox.Extent(2)), 0, max(m_BBox.Extent(0), m_BBox.Extent(2))) // + Vector3f(min(m_BBox.Extent(0), m_BBox.Extent(2)), 0, min(m_BBox.Extent(0), m_BBox.Extent(2)))).Length()/2.0f; //m_BSphere.Radius() = fHalfWidth*1.1f; //m_BSphere.Radius() = 1.0f; Vector3f vBox[8]; m_BBox.ComputeVertices(vBox); m_BSphere = ContSphereOfAABB(8, vBox); };
void BoundingSphere::GrowToContain( BoundingVolume * pBound ) { switch ( pBound->GetBoundType() ) { case Bounding_Box: { Vector3f akVector[8]; ( (BoundingBox *) pBound )->GetBox().ComputeVertices( akVector ); m_kSphere = MergeSpheres( m_kSphere, ContSphereOfAABB( 8, akVector ) ); break; } case Bounding_Sphere: { m_kSphere = MergeSpheres( m_kSphere,( (BoundingSphere *) pBound )->GetSphere() ); break; } default: break; } }