#include <aabbox.h>
Inheritance diagram for NLMISC::CAABBox:

Nevrax France
Definition at line 50 of file aabbox.h.
Clip | |
| bool | clipBack (const CPlane &p) const |
| Is the bbox partially in back of the plane?? | |
| bool | clipFront (const CPlane &p) const |
| Is the bbox partially in front of the plane?? | |
| 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 CVector &a, const CVector &b, const CVector &c) const |
| Does the bbox intersect the triangle ABC. | |
| bool | intersect (const CAABBox &box) const |
| Does the bbox intersect the bbox box. | |
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) |
Builds. | |
| void | extend (const CVector &v) |
| 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). | |
Gets. | |
| const CVector & | getCenter () const |
| const CVector & | getHalfSize () const |
| void | getMax (CVector &ret) const |
| CVector | getMax () const |
| void | getMin (CVector &ret) const |
| CVector | getMin () const |
| float | getRadius () const |
| Return the radius of the bbox. | |
| void | getSize (CVector &ret) const |
| CVector | getSize () const |
| Return the size of the bbox. | |
Public Member Functions | |
| CAABBox () | |
| Empty bbox Constructor. (for AABBoxExt::getRadius() correctness). | |
| void | serial (NLMISC::IStream &f) |
Protected Attributes | |
| CVector | Center |
| The center of the bbox. | |
| CVector | HalfSize |
| The size/2 of the bbox. | |
|
|
Empty bbox Constructor. (for AABBoxExt::getRadius() correctness).
Definition at line 61 of file aabbox.h. References HalfSize.
|
|
|
Is the bbox partially in back of the plane??
Reimplemented in NLMISC::CAABBoxExt. Definition at line 59 of file aabbox.cpp. References HalfSize, NLMISC::CVector::set(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. Referenced by NL3D::CParticleSystemModel::checkAgainstPyramid(), NL3D::CWaterShape::clip(), NL3D::CCluster::isIn(), and NL3D::CParticleSystemModel::traverseClip().
00060 {
00061 CVector hswap;
00062
00063 // The bbox is back of the plane if only one of his vertex is in back.
00064 if(p*(Center + HalfSize) < 0) return true;
00065 if(p*(Center - HalfSize) < 0) return true;
00066 hswap.set(-HalfSize.x, HalfSize.y, HalfSize.z);
00067 if(p*(Center + hswap) < 0) return true;
00068 if(p*(Center - hswap) < 0) return true;
00069 hswap.set(HalfSize.x, -HalfSize.y, HalfSize.z);
00070 if(p*(Center + hswap) < 0) return true;
00071 if(p*(Center - hswap) < 0) return true;
00072 hswap.set(HalfSize.x, HalfSize.y, -HalfSize.z);
00073 if(p*(Center + hswap) < 0) return true;
00074 if(p*(Center - hswap) < 0) return true;
00075
00076 return false;
00077 }
|
|
|
Is the bbox partially in front of the plane??
Reimplemented in NLMISC::CAABBoxExt. Definition at line 39 of file aabbox.cpp. References HalfSize, NLMISC::CVector::set(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
00040 {
00041 CVector hswap;
00042
00043 // The bbox is front of the plane if only one of his vertex is in front.
00044 if(p*(Center + HalfSize) > 0) return true;
00045 if(p*(Center - HalfSize) > 0) return true;
00046 hswap.set(-HalfSize.x, HalfSize.y, HalfSize.z);
00047 if(p*(Center + hswap) > 0) return true;
00048 if(p*(Center - hswap) > 0) return true;
00049 hswap.set(HalfSize.x, -HalfSize.y, HalfSize.z);
00050 if(p*(Center + hswap) > 0) return true;
00051 if(p*(Center - hswap) > 0) return true;
00052 hswap.set(HalfSize.x, HalfSize.y, -HalfSize.z);
00053 if(p*(Center + hswap) > 0) return true;
00054 if(p*(Center - hswap) > 0) return true;
00055
00056 return false;
00057 }
|
|
||||||||||||
|
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(), include(), 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 getMax(), getMin(), NLMISC::CVector::maxof(), min, and 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 getMax(), getMin(), NLMISC::CVector::maxof(), NLMISC::CVector::minof(), and 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 }
|
|
|
|
|
|
Definition at line 89 of file aabbox.h. References HalfSize.
|
|
|
|
Definition at line 88 of file aabbox.h. References HalfSize.
|
|
|
|
Return the radius of the bbox.
Reimplemented in NLMISC::CAABBoxExt. Definition at line 96 of file aabbox.h. References HalfSize, and NLMISC::CVector::norm(). Referenced by NL3D::CSkeletonShape::clip(), NL3D::CZone::compile(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CTessBlock::extendSphereCompile(), NL3D::CPatchDLMContext::generate(), NL3D::CTransformShape::getLightHotSpotInWorld(), and NL3D::CVegetableClipBlock::updateSphere().
00096 {return HalfSize.norm();}
|
|
|
Definition at line 94 of file aabbox.h. References HalfSize.
00094 {ret= HalfSize*2;}
|
|
|
Return the size of the bbox.
Reimplemented in NLMISC::CAABBoxExt. Definition at line 93 of file aabbox.h. References HalfSize. Referenced by NL3D::CShadowMap::buildCasterCameraMatrix(), NL3D::CVisualCollisionManager::CStaticGrid::create(), and NL3D::CQuadGridClipManager::profile().
00093 {return HalfSize*2;}
|
|
|
Does the bbox include entirely this bbox.
Definition at line 94 of file aabbox.cpp. References Center, 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 HalfSize, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. Referenced by NLPACS::CSurfaceQuadTree::addVertex(), NL3D::CLandscape::addZone(), clipSegment(), NL3D::CVegetableClipBlock::extendBBoxOnly(), NL3D::CTessBlock::extendSphereAdd(), NL3D::CMiniCol::getGroundNormal(), NLPACS::CSurfaceQuadTree::getInterpZ(), NLPACS::CSurfaceQuadTree::getLeaf(), 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(), include(), 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 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 triangle ABC.
Reimplemented in NLMISC::CAABBoxExt. Definition at line 121 of file aabbox.cpp. References NLMISC::CPolygon::clip(), NLMISC::CPolygon::getNumVertices(), include(), and makePyramid().
00122 {
00123 // Trivial test.
00124 if(include(a) || include(b) || include(c))
00125 return true;
00126 // Else, must test if the polygon intersect the pyamid.
00127 CPlane planes[6];
00128 makePyramid(planes);
00129 CPolygon poly(a,b,c);
00130 poly.clip(planes, 6);
00131 if(poly.getNumVertices()==0)
00132 return false;
00133 return true;
00134 }
|
|
|
Does the bbox intersect the bbox box.
Definition at line 107 of file aabbox.cpp. References getMax(), 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().
|
|
|
Build the equivalent polytope of planes.
Definition at line 194 of file aabbox.cpp. References HalfSize, and NLMISC::CPlane::make(). Referenced by clipSegment(), and 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 }
|
|
|
Reimplemented in NLMISC::CAABBoxExt. Definition at line 206 of file aabbox.cpp. References HalfSize, NLMISC::IStream::serial(), and NLMISC::IStream::serialVersion().
00207 {
00208 (void)f.serialVersion(0);
00209 f.serial(Center);
00210 f.serial(HalfSize);
00211 }
|
|
|
|
||||||||||||
|
Build the bbox, with a min/max style bbox.
Reimplemented in NLMISC::CAABBoxExt. Definition at line 71 of file aabbox.h. References HalfSize. Referenced by NL3D::CPatch::buildBBoxFromBezierPatch(), computeAABBoxUnion(), NL3D::CWaterShape::computeBBox(), NL3D::CPSLocated::computeBBox(), computeIntersection(), NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater(), NL3D::CSkeletonModel::computeWorldBBoxForShadow(), extend(), NLPACS::CLocalRetriever::retrieveAccuratePosition(), NLPACS::CLocalRetriever::retrievePosition(), transformAABBox(), and NL3D::CQuadGridClipManager::updateClustersFromCamera().
|
|
|
Set the size of the bbox (ie 2* the halfSize).
Reimplemented in NLMISC::CAABBoxExt. Definition at line 69 of file aabbox.h. Referenced by NL3D::CSkeletonShape::CSkeletonShape(), NLPACS::CSurfaceQuadTree::CSurfaceQuadTree(), and NL3D::CQuadGridClipClusterQTreeNode::init().
|
|
||||||||||||
|
Apply a matrix on an aabbox
Definition at line 262 of file aabbox.cpp. References getMax(), getMin(), min, NLMISC::CVector::set(), 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 }
|
|
|
The center of the bbox.
Definition at line 54 of file aabbox.h. Referenced by include(). |
|
|
The size/2 of the bbox.
Definition at line 56 of file aabbox.h. Referenced by CAABBox(), clipBack(), clipFront(), getHalfSize(), getMax(), getMin(), getRadius(), getSize(), include(), intersect(), makePyramid(), serial(), setHalfSize(), setMinMax(), and setSize(). |
1.3.6