#include <aabbox.h>
Inheritance diagram for NLMISC::CAABBoxExt:
Nevrax France
Definition at line 159 of file aabbox.h.
Misc | |
void | computeIntersection (const CAABBox &b1, const CAABBox &b2) |
void | makePyramid (CPlane planes[6]) const |
Build the equivalent polytope of planes. | |
CAABBox | computeAABBoxUnion (const CAABBox &b1, const CAABBox &b2) |
CAABBox | transformAABBox (const CMatrix &mat, const CAABBox &box) |
Public Member Functions | |
CAABBoxExt (const CAABBox &o) | |
Constructor from a normal BBox. | |
CAABBoxExt () | |
Empty bbox Constructor. | |
void | serial (NLMISC::IStream &f) |
Clip | |
bool | clipBack (const CPlane &p) const |
Is the bbox partially in back of the plane?? p MUST be normalized. | |
bool | clipFront (const CPlane &p) const |
Is the bbox partially in front of the plane?? p MUST be normalized. | |
bool | intersect (const CVector &a, const CVector &b, const CVector &c) const |
Does the bbox intersect the triangle ABC. | |
bool | intersect (const CAABBoxExt &box) const |
Does the bbox intersect the bbox box. | |
Gets. | |
CAABBox | getAABBox () const |
Return a simple Axis Aligned Bounding Box (no radius inside). | |
const CVector & | getCenter () const |
Return a simple Axis Aligned Bounding Box (no radius inside). | |
const CVector & | getHalfSize () const |
Return a simple Axis Aligned Bounding Box (no radius inside). | |
CVector | getMax () const |
Return a simple Axis Aligned Bounding Box (no radius inside). | |
CVector | getMin () const |
Return a simple Axis Aligned Bounding Box (no radius inside). | |
float | getRadius () const |
Return the (stored!!) radius of the bbox. | |
CVector | getSize () const |
Return the size of the bbox. | |
Builds. | |
CAABBoxExt & | operator= (const CAABBox &o) |
void | setCenter (const CVector ¢er) |
void | setHalfSize (const CVector &hs) |
void | setMinMax (const CVector &bmin, const CVector &bmax) |
Build the bbox, with a min/max style bbox. | |
void | setSize (const CVector &s) |
Set the size of the bbox (ie 2* the halfSize). | |
Protected Member Functions | |
void | updateRadius () |
Protected Attributes | |
float | RadiusMax |
float | RadiusMin |
Private Member Functions | |
Clip | |
bool | clipSegment (CVector &a, CVector &b) const |
clip the segment by the bbox. return false if don't intersect. a and b are modified. | |
bool | include (const CAABBox &box) const |
Does the bbox include entirely this bbox. | |
bool | include (const CVector &a) const |
Does the bbox include this point. | |
bool | intersect (const CVector &a, const CVector &b) const |
Does the bbox instersect the segment AB. | |
bool | intersect (const CBSphere &s) const |
Does the bbox instersect the sphere s. | |
bool | intersect (const CAABBox &box) const |
Does the bbox intersect the bbox box. | |
Builds. | |
void | extend (const CVector &v) |
Gets. | |
void | getMax (CVector &ret) const |
void | getMin (CVector &ret) const |
void | getSize (CVector &ret) const |
Private Attributes | |
CVector | Center |
The center of the bbox. | |
CVector | HalfSize |
The size/2 of the bbox. |
|
Empty bbox Constructor.
Definition at line 174 of file aabbox.h. References RadiusMax, and RadiusMin.
|
|
Constructor from a normal BBox.
Definition at line 176 of file aabbox.h. References RadiusMax, and RadiusMin.
|
|
Is the bbox partially in back of the plane?? p MUST be normalized.
Reimplemented from NLMISC::CAABBox. Definition at line 319 of file aabbox.cpp. References RadiusMax, and RadiusMin. Referenced by NL3D::CZone::clip(), NL3D::CQuadGridClipClusterQTreeNode::clip(), NL3D::CMeshMRMSkinnedGeom::clip(), NL3D::CMeshMRMGeom::clip(), and NL3D::CMeshGeom::clip().
00320 { 00321 // Assume normalized planes. 00322 00323 // if( SpherMax OUT ) return false. 00324 float d= p*Center; 00325 if(d>RadiusMax) 00326 return false; 00327 // if( SphereMin IN ) return true; 00328 if(d<RadiusMin) 00329 return true; 00330 00331 // else, standard clip box. 00332 return CAABBox::clipBack(p); 00333 } |
|
Is the bbox partially in front of the plane?? p MUST be normalized.
Reimplemented from NLMISC::CAABBox. Definition at line 301 of file aabbox.cpp. References RadiusMax, and RadiusMin. Referenced by NL3D::CZone::clip(), and NL3D::CQuadGridClipClusterQTreeNode::clip().
00302 { 00303 // Assume normalized planes. 00304 00305 // if( SpherMax OUT ) return false. 00306 float d= p*Center; 00307 if(d<-RadiusMax) 00308 return false; 00309 // if( SphereMin IN ) return true; 00310 if(d>-RadiusMin) 00311 return true; 00312 00313 // else, standard clip box. 00314 return CAABBox::clipFront(p); 00315 } |
|
clip the segment by the bbox. return false if don't intersect. a and b are modified.
Definition at line 156 of file aabbox.cpp. References NLMISC::CPlane::clipSegmentBack(), NLMISC::CAABBox::include(), NLMISC::CAABBox::makePyramid(), and uint.
00157 { 00158 // Trivial test. If both are in, they are inchanged 00159 if(include(a) && include(b)) 00160 return true; 00161 // Else, must clip the segment againts the pyamid. 00162 CPlane planes[6]; 00163 makePyramid(planes); 00164 CVector p0=a , p1=b; 00165 // clip the segment against all planes 00166 for(uint i=0;i<6;i++) 00167 { 00168 if(!planes[i].clipSegmentBack(p0, p1)) 00169 return false; 00170 } 00171 // get result 00172 a= p0; 00173 b= p1; 00174 return true; 00175 } |
|
Compute the union of 2 bboxs, that is the aabbox that contains the 2 others. Should end up in NLMISC Definition at line 231 of file aabbox.cpp. References NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), NLMISC::CVector::maxof(), min, and NLMISC::CAABBox::setMinMax(). Referenced by NL3D::CPSLocated::computeBBox(), NL3D::CSkeletonModel::computeWorldBBoxForShadow(), and NL3D::CParticleSystem::forceComputeBBox().
|
|
Compute the intersection of 2 bboxs. NB: this methods suppose the intersection exist, and doesn't check it (use intersect() to check). If !intersect, *this is still modified and the result bbox is big chit. Definition at line 247 of file aabbox.cpp. References NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), NLMISC::CVector::maxof(), NLMISC::CVector::minof(), and NLMISC::CAABBox::setMinMax().
00248 { 00249 CVector min1 = b1.getMin(), max1 = b1.getMax(), 00250 min2 = b2.getMin(), max2 = b2.getMax(); 00251 CVector minr, maxr; 00252 00253 // don't test if intersect or not. 00254 maxr.minof(max1, max2); 00255 minr.maxof(min1, min2); 00256 00257 setMinMax(minr, maxr); 00258 } |
|
|
Return a simple Axis Aligned Bounding Box (no radius inside).
Definition at line 206 of file aabbox.h. References getCenter(), getHalfSize(), NLMISC::CAABBox::setCenter(), and NLMISC::CAABBox::setHalfSize(). Referenced by NL3D::CLandscape::addZone(), NL3D::CZoneLighter::buildZoneInformation(), NL3D::CSegRemanenceShape::getAABBox(), NL3D::CMeshMRMSkinned::getAABBox(), NL3D::CMeshMRM::getAABBox(), NL3D::CMesh::getAABBox(), and NL3D::CLandscape::removeZone().
00206 { CAABBox box; box.setCenter(getCenter()); box.setHalfSize(getHalfSize()); return box; } |
|
Return a simple Axis Aligned Bounding Box (no radius inside).
Reimplemented from NLMISC::CAABBox. Definition at line 199 of file aabbox.h. Referenced by NL3D::CMiniCol::addZone(), NL3D::CLandscape::buildCollideFaces(), NL3D::CSegRemanenceShape::clip(), NL3D::CQuadGridClipClusterQTreeNode::clip(), NL3D::CMeshMRMSkinnedGeom::clip(), NL3D::CMeshMRMGeom::clip(), NL3D::CMeshGeom::clip(), NL3D::CZone::computeBBScaleBias(), getAABBox(), NL3D::CZoneLighter::light(), and NL3D::CQuadGridClipClusterQTreeNode::noFrustumClip().
00199 {return Center;} |
|
Return a simple Axis Aligned Bounding Box (no radius inside).
Reimplemented from NLMISC::CAABBox. Definition at line 200 of file aabbox.h. Referenced by NL3D::CZone::computeBBScaleBias(), and getAABBox().
00200 {return HalfSize;} |
|
Definition at line 89 of file aabbox.h. References NLMISC::CAABBox::HalfSize.
|
|
Return a simple Axis Aligned Bounding Box (no radius inside).
Reimplemented from NLMISC::CAABBox. Definition at line 198 of file aabbox.h. Referenced by InitZBuffer().
00198 {return CAABBox::getMax();}
|
|
Definition at line 88 of file aabbox.h. References NLMISC::CAABBox::HalfSize.
|
|
Return a simple Axis Aligned Bounding Box (no radius inside).
Reimplemented from NLMISC::CAABBox. Definition at line 197 of file aabbox.h. Referenced by InitZBuffer().
00197 {return CAABBox::getMin();}
|
|
Return the (stored!!) radius of the bbox.
Reimplemented from NLMISC::CAABBox. Definition at line 204 of file aabbox.h. References RadiusMax. Referenced by NL3D::CMiniCol::addZone(), NL3D::CLandscape::buildCollideFaces(), NL3D::CSegRemanenceShape::clip(), NL3D::CQuadGridClipClusterQTreeNode::clip(), NL3D::CMeshMRMSkinnedGeom::clip(), NL3D::CMeshMRMGeom::clip(), NL3D::CMeshGeom::clip(), NL3D::CMeshMRMSkinnedGeom::compileRunTime(), NL3D::CMeshMRMGeom::compileRunTime(), NL3D::CMeshGeom::compileRunTime(), and NL3D::CQuadGridClipClusterQTreeNode::noFrustumClip().
00204 {return RadiusMax;} |
|
Definition at line 94 of file aabbox.h. References NLMISC::CAABBox::HalfSize.
00094 {ret= HalfSize*2;} |
|
Return the size of the bbox.
Reimplemented from NLMISC::CAABBox. Definition at line 202 of file aabbox.h.
00202 {return HalfSize*2;} |
|
Does the bbox include entirely this bbox.
Definition at line 94 of file aabbox.cpp. References NLMISC::CAABBox::Center, NLMISC::CAABBox::HalfSize, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
00095 { 00096 if(Center.x+HalfSize.x < box.Center.x+box.HalfSize.x) return false; 00097 if(Center.x-HalfSize.x > box.Center.x-box.HalfSize.x) return false; 00098 if(Center.y+HalfSize.y < box.Center.y+box.HalfSize.y) return false; 00099 if(Center.y-HalfSize.y > box.Center.y-box.HalfSize.y) return false; 00100 if(Center.z+HalfSize.z < box.Center.z+box.HalfSize.z) return false; 00101 if(Center.z-HalfSize.z > box.Center.z-box.HalfSize.z) return false; 00102 return true; 00103 } |
|
Does the bbox include this point.
Definition at line 81 of file aabbox.cpp. References NLMISC::CAABBox::HalfSize, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. Referenced by NLPACS::CSurfaceQuadTree::addVertex(), NL3D::CLandscape::addZone(), NLMISC::CAABBox::clipSegment(), NL3D::CVegetableClipBlock::extendBBoxOnly(), NL3D::CTessBlock::extendSphereAdd(), NL3D::CMiniCol::getGroundNormal(), NLPACS::CSurfaceQuadTree::getInterpZ(), NLPACS::CSurfaceQuadTree::getLeaf(), NLMISC::CAABBox::intersect(), NLPACS::CGlobalRetriever::retrievePosition(), NL3D::CVisualCollisionEntity::testComputeLandscape(), and NLPACS::CGlobalRetriever::testPosition().
00082 { 00083 if(Center.x+HalfSize.x<a.x) return false; 00084 if(Center.x-HalfSize.x>a.x) return false; 00085 if(Center.y+HalfSize.y<a.y) return false; 00086 if(Center.y-HalfSize.y>a.y) return false; 00087 if(Center.z+HalfSize.z<a.z) return false; 00088 if(Center.z-HalfSize.z>a.z) return false; 00089 return true; 00090 } |
|
Does the bbox instersect the segment AB.
Definition at line 137 of file aabbox.cpp. References NLMISC::CPlane::clipSegmentBack(), NLMISC::CAABBox::include(), NLMISC::CAABBox::makePyramid(), and uint.
00138 { 00139 // Trivial test. 00140 if(include(a) || include(b)) 00141 return true; 00142 // Else, must test if the segment intersect the pyamid. 00143 CPlane planes[6]; 00144 makePyramid(planes); 00145 CVector p0=a , p1=b; 00146 // clip the segment against all planes 00147 for(uint i=0;i<6;i++) 00148 { 00149 if(!planes[i].clipSegmentBack(p0, p1)) 00150 return false; 00151 } 00152 return true; 00153 } |
|
Does the bbox instersect the sphere s.
Definition at line 178 of file aabbox.cpp. References NLMISC::CAABBox::HalfSize, s, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
00179 { 00180 if (Center.x + HalfSize.x < s.Center.x - s.Radius) return false; 00181 if (Center.y + HalfSize.y < s.Center.y - s.Radius) return false; 00182 if (Center.z + HalfSize.z < s.Center.z - s.Radius) return false; 00183 00184 if (Center.x - HalfSize.x > s.Center.x + s.Radius) return false; 00185 if (Center.y - HalfSize.y > s.Center.y + s.Radius) return false; 00186 if (Center.z - HalfSize.z > s.Center.z + s.Radius) return false; 00187 00188 return true; 00189 } |
|
Does the bbox intersect the bbox box.
Definition at line 107 of file aabbox.cpp. References NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. Referenced by NL3D::CPatch::addPatchBlocksInBBoxRecurs(), NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CPatch::addTrianglesInBBoxRecurs(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CVisualCollisionManager::CMeshCol::getCameraCollision(), NL3D::CMiniCol::getFaces(), and NL3D::CZoneLighter::makeQuadGridFromWaterShapes().
|
|
Does the bbox intersect the triangle ABC.
Reimplemented from NLMISC::CAABBox. Definition at line 219 of file aabbox.h.
00220 {return CAABBox::intersect(a,b,c);}
|
|
Does the bbox intersect the bbox box.
Definition at line 216 of file aabbox.h. Referenced by NL3D::CLandscape::buildCollideFaces().
00217 {return CAABBox::intersect(box);}
|
|
Build the equivalent polytope of planes.
Definition at line 194 of file aabbox.cpp. References NLMISC::CAABBox::HalfSize, and NLMISC::CPlane::make(). Referenced by NLMISC::CAABBox::clipSegment(), and NLMISC::CAABBox::intersect().
00195 { 00196 planes[0].make(CVector(-1,0,0), Center-HalfSize); 00197 planes[1].make(CVector(+1,0,0), Center+HalfSize); 00198 planes[2].make(CVector(0,-1,0), Center-HalfSize); 00199 planes[3].make(CVector(0,+1,0), Center+HalfSize); 00200 planes[4].make(CVector(0,0,-1), Center-HalfSize); 00201 planes[5].make(CVector(0,0,+1), Center+HalfSize); 00202 } |
|
Definition at line 191 of file aabbox.h. References NLMISC::CAABBox::getCenter(), NLMISC::CAABBox::getHalfSize(), and updateRadius().
00191 {Center= o.getCenter(); HalfSize= o.getHalfSize(); updateRadius(); return (*this);} |
|
Reimplemented from NLMISC::CAABBox. Definition at line 337 of file aabbox.cpp. References NLMISC::IStream::isReading(), and updateRadius().
00338 { 00339 CAABBox::serial(f); 00340 if(f.isReading()) 00341 updateRadius(); 00342 } |
|
extend the bbox so it contains v. Warning!! By default, a bbox is the vector 0,0,0. So set the first vertex with setCenter() or else the bbox will be the extension of v and (0,0,0)... Reimplemented from NLMISC::CAABBox. Definition at line 181 of file aabbox.h. Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), NL3D::CMeshGeom::build(), and NL3D::CSegRemanenceShape::CSegRemanenceShape().
00181 {Center= center;} |
|
extend the bbox so it contains v. Warning!! By default, a bbox is the vector 0,0,0. So set the first vertex with setCenter() or else the bbox will be the extension of v and (0,0,0)... Reimplemented from NLMISC::CAABBox. Definition at line 182 of file aabbox.h. References updateRadius(). Referenced by NL3D::CZone::computeBBScaleBias(), and NL3D::CSegRemanenceShape::CSegRemanenceShape().
00182 {HalfSize= hs; updateRadius();} |
|
Build the bbox, with a min/max style bbox.
Reimplemented from NLMISC::CAABBox. Definition at line 185 of file aabbox.h. References updateRadius().
00186 { 00187 Center= (bmin+bmax)/2; 00188 HalfSize= bmax-Center; 00189 updateRadius(); 00190 } |
|
Set the size of the bbox (ie 2* the halfSize).
Reimplemented from NLMISC::CAABBox. Definition at line 183 of file aabbox.h. References s, and updateRadius(). Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), and NL3D::CMeshGeom::build().
00183 {HalfSize= s/2; updateRadius();} |
|
Apply a matrix on an aabbox
Definition at line 262 of file aabbox.cpp. References NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), min, NLMISC::CVector::set(), NLMISC::CAABBox::setMinMax(), uint, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. Referenced by NL3D::CCluster::applyMatrix(), NL3D::CShadowMap::buildCasterCameraMatrix(), NL3D::CMeshInstance::computeWorldBBoxForShadow(), NL3D::CParticleSystem::forceComputeBBox(), NL3D::CZoneLighter::makeQuadGridFromWaterShapes(), and NL3D::CCluster::setWorldMatrix().
00263 { 00264 // TODO : optimize this a bit if possible... 00265 CAABBox result; 00266 00267 /* OMG. Old code was false!! 00268 if we have ht= M * h 00269 then CVector(-ht.x, ht.y, ht.z) != M * CVector(-h.x, h.y, h.z) !!!! 00270 */ 00271 // compute corners. 00272 CVector p[8]; 00273 CVector min= box.getMin(); 00274 CVector max= box.getMax(); 00275 p[0].set(min.x, min.y, min.z); 00276 p[1].set(max.x, min.y, min.z); 00277 p[2].set(min.x, max.y, min.z); 00278 p[3].set(max.x, max.y, min.z); 00279 p[4].set(min.x, min.y, max.z); 00280 p[5].set(max.x, min.y, max.z); 00281 p[6].set(min.x, max.y, max.z); 00282 p[7].set(max.x, max.y, max.z); 00283 CVector tmp; 00284 min = max = mat * p[0]; 00285 // transform corners. 00286 for(uint i=1;i<8;i++) 00287 { 00288 tmp= mat * p[i]; 00289 min.minof(min, tmp); 00290 max.maxof(max, tmp); 00291 } 00292 00293 result.setMinMax(min, max); 00294 00295 return result; 00296 } |
|
Definition at line 164 of file aabbox.h. References NLMISC::minof(), RadiusMax, RadiusMin, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. Referenced by operator=(), serial(), setHalfSize(), setMinMax(), and setSize().
|
|
The center of the bbox.
Definition at line 54 of file aabbox.h. Referenced by NLMISC::CAABBox::include(). |
|
|
Definition at line 162 of file aabbox.h. Referenced by CAABBoxExt(), clipBack(), clipFront(), getRadius(), and updateRadius(). |
|
Definition at line 162 of file aabbox.h. Referenced by CAABBoxExt(), clipBack(), clipFront(), and updateRadius(). |