From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02156.html | 1564 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1564 insertions(+) create mode 100644 docs/doxygen/nel/a02156.html (limited to 'docs/doxygen/nel/a02156.html') diff --git a/docs/doxygen/nel/a02156.html b/docs/doxygen/nel/a02156.html new file mode 100644 index 00000000..6982f62e --- /dev/null +++ b/docs/doxygen/nel/a02156.html @@ -0,0 +1,1564 @@ + + +NeL: NLMISC::CAABBox class Reference + + + +
+

NLMISC::CAABBox Class Reference

#include <aabbox.h> +

+

Inheritance diagram for NLMISC::CAABBox: +

+ +NLMISC::CAABBoxExt + +

Detailed Description

+An Axis Aligned Bouding Box. Note: Center/HalfSize set to private, to have same manipulation for CAABBox and CAABBoxExt.
Author:
Lionel Berenguier

+Nevrax France

+
Date:
2000
+ +

+ +

+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 &center)
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 CVectorgetCenter () const
const CVectorgetHalfSize () 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.

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLMISC::CAABBox::CAABBox  )  [inline]
+
+ + + + + +
+   + + +

+Empty bbox Constructor. (for AABBoxExt::getRadius() correctness). +

+ +

+Definition at line 61 of file aabbox.h. +

+References HalfSize. +

+

00061 : Center(0,0,0), HalfSize(0,0,0) {}
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + +
bool NLMISC::CAABBox::clipBack const CPlane p  )  const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLMISC::CAABBox::clipFront const CPlane p  )  const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NLMISC::CAABBox::clipSegment CVector a,
CVector b
const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
CAABBox NLMISC::CAABBox::computeAABBoxUnion const CAABBox b1,
const CAABBox b2
[static]
+
+ + + + + +
+   + + +

+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(). +

+

00232 {       
+00233         CAABBox result;
+00234         CVector min, max;
+00235         CVector min1 = b1.getMin() 
+00236                     ,max1 = b1.getMax() 
+00237                         ,min2 = b2.getMin() 
+00238                     ,max2 = b2.getMax();
+00239         max.maxof(max1, max2);
+00240         min.minof(min1, min2);
+00241         result.setMinMax(min, max);
+00242         return result;
+00243 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLMISC::CAABBox::computeIntersection const CAABBox b1,
const CAABBox b2
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::extend const CVector v  ) 
+
+ + + + + +
+   + + +

+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)... +

+Definition at line 215 of file aabbox.cpp. +

+References getMax(), getMin(), NLMISC::CVector::maxof(), NLMISC::CVector::minof(), setMinMax(), and v. +

+Referenced by NL3D::CMiniCol::addFaces(), NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CShadowPolyReceiver::addTriangle(), NL3D::CZone::applyHeightField(), NL3D::CZone::build(), NL3D::CVisualCollisionManager::CMeshCol::build(), NLPACS::CEdgeQuad::build(), NLPACS::CChainQuad::build(), NL3D::CCameraCol::build(), NL3D::CShadowMap::buildClipInfoFromMatrix(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), NL3D::CSkeletonModel::computeCurrentBBox(), NL3D::CSkeletonModel::computeRenderedBBox(), NLPACS::computeRetriever(), NL3D::CInstanceLighter::computeSunContribution(), NLPACS::computeSurfaceQuadTree(), NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater(), NLPACS::CCollisionMeshBuild::computeTrivialTranslation(), NLPACS::CGlobalRetriever::doMove(), NL3D::CVegetableClipBlock::extendBBoxOnly(), NL3D::CTessBlock::extendSphereAdd(), NL3D::CPatchDLMContext::generate(), NL3D::CMiniCol::getGroundNormal(), NLPACS::CLocalRetriever::initFaceGrid(), NL3D::CQuadGridClipClusterQTreeNode::insertModel(), NL3D::CQuadGridClipManager::linkModel(), NL3D::makeBBox(), NLPACS::CGlobalRetriever::makeInstance(), NL3D::CCluster::makeVolume(), NLPACS::CGlobalRetriever::testBBoxMove(), NLPACS::CGlobalRetriever::testBBoxRot(), and NLPACS::CGlobalRetriever::testCylinderMove(). +

+

00216 {
+00217         CVector         bmin= getMin(), bmax= getMax();
+00218 
+00219         bmin.minof(bmin, v);
+00220         bmax.maxof(bmax, v);
+00221         setMinMax(bmin, bmax);
+00222 }
+
+

+ + + + +
+ + + + + + + + + +
const CVector& NLMISC::CAABBox::getCenter  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Reimplemented in NLMISC::CAABBoxExt. +

+Definition at line 90 of file aabbox.h. +

+Referenced by NLPACS::CSurfaceQuadTree::addVertex(), NL3D::CSkeletonShape::clip(), NL3D::CZone::compile(), NLPACS::computeSurfaceQuadTree(), NLPACS::CCollisionMeshBuild::computeTrivialTranslation(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CTessBlock::extendSphereCompile(), NLPACS::CGlobalRetriever::findCollisionChains(), NL3D::CPatchDLMContext::generate(), NL3D::CSkeletonModel::generateShadowMap(), NL3D::CMeshInstance::generateShadowMap(), NLPACS::CGlobalRetriever::getBorders(), NL3D::CQuadGridClipClusterQTreeNode::init(), NL3D::CQuadGridClipClusterQTreeNode::insertModel(), NL3D::CInstanceLighter::light(), NL3D::CQuadGridClipManager::linkModel(), NLPACS::CRetrieverInstance::make(), NLMISC::CAABBoxExt::operator=(), NL3D::CShadowPolyReceiver::render(), NL3D::CShadowMapManager::renderProject(), NLPACS::CSurfaceQuadTree::translate(), NL3D::CClipTrav::traverse(), NL3D::CTransform::traverseLight(), and NL3D::CVegetableClipBlock::updateSphere(). +

+

00090 {return Center;}
+
+

+ + + + +
+ + + + + + + + + +
const CVector& NLMISC::CAABBox::getHalfSize  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Reimplemented in NLMISC::CAABBoxExt. +

+Definition at line 91 of file aabbox.h. +

+References HalfSize. +

+Referenced by NL3D::CPSUtil::addRadiusToAABBox(), NLPACS::CSurfaceQuadTree::addVertex(), NL3D::CLandscape::addZone(), NL3D::CCameraCol::build(), NL3D::CShadowMap::buildCasterCameraMatrix(), NLPACS::computeRetriever(), NLPACS::computeSurfaceQuadTree(), NL3D::CSkeletonModel::generateShadowMap(), NL3D::CMeshInstance::generateShadowMap(), NLPACS::CGlobalRetriever::getBorders(), NL3D::CQuadGridClipClusterQTreeNode::init(), NL3D::CQuadGridClipClusterQTreeNode::insertModel(), NL3D::CInstanceLighter::light(), NL3D::CQuadGridClipManager::linkModel(), NLPACS::CRetrieverInstance::make(), NLPACS::CGlobalRetriever::makeInstance(), NLMISC::CAABBoxExt::operator=(), NL3D::CLandscape::removeZone(), NL3D::CVisualCollisionEntity::testComputeLandscape(), NL3D::CClipTrav::traverse(), and NLSOUND::CClusteredSound::update(). +

+

00091 {return HalfSize;}
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::getMax CVector ret  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 89 of file aabbox.h. +

+References HalfSize. +

+

00089 {ret= Center+HalfSize;}
+
+

+ + + + +
+ + + + + + + + + +
CVector NLMISC::CAABBox::getMax  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Reimplemented in NLMISC::CAABBoxExt. +

+Definition at line 87 of file aabbox.h. +

+References HalfSize. +

+Referenced by NL3D::CVisualCollisionManager::CStaticGrid::add(), NL3D::CMiniCol::addFaces(), NL3D::CVisualCollisionManager::addMeshCollision(), NL3D::CShadowMapManager::addShadowReceiver(), NL3D::CShadowPolyReceiver::addTriangle(), NL3D::CLandscape::addZone(), NLPACS::CEdgeQuad::build(), NLPACS::CChainQuad::build(), NL3D::CLandscape::buildPatchBlocksInBBox(), NL3D::CLandscape::buildTrianglesInBBox(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), computeAABBoxUnion(), NL3D::CLandscape::computeDynamicLighting(), computeIntersection(), NL3D::CInstanceLighter::computeSunContribution(), NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater(), NL3D::CPSUtil::displayBBox(), extend(), NLSOUND::CClusteredSound::getAABoxNearestPos(), NL3D::CVisualCollisionManager::getCameraCollision(), NL3D::CShadowPolyReceiver::getCameraCollision(), NL3D::CMiniCol::getFaces(), NL3D::CQuadGridClipClusterQTreeNode::init(), NLPACS::CLocalRetriever::initFaceGrid(), intersect(), NLPACS::CGlobalRetriever::makeInstance(), NL3D::CZoneLighter::makeQuadGridFromWaterShapes(), NL3D::CClipTrav::registerCluster(), NL3D::CMiniCol::removeLandScapePart(), NL3D::CLandscape::removeZone(), NL3D::CShadowPolyReceiver::render(), NL3D::CShadowMapManager::renderProject(), NLPACS::CLocalRetriever::retrieveAccuratePosition(), NLPACS::CLocalRetriever::retrievePosition(), NL3D::CVisualCollisionManager::CStaticGrid::select(), NLPACS::CEdgeQuad::selectEdges(), NLPACS::CChainQuad::selectEdges(), NLPACS::CGlobalRetriever::selectInstances(), and transformAABBox(). +

+

00087 {return Center+HalfSize;}
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::getMin CVector ret  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 88 of file aabbox.h. +

+References HalfSize. +

+

00088 {ret= Center-HalfSize;}
+
+

+ + + + +
+ + + + + + + + + +
CVector NLMISC::CAABBox::getMin  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Reimplemented in NLMISC::CAABBoxExt. +

+Definition at line 86 of file aabbox.h. +

+References HalfSize. +

+Referenced by NL3D::CVisualCollisionManager::CStaticGrid::add(), NL3D::CMiniCol::addFaces(), NL3D::CVisualCollisionManager::addMeshCollision(), NL3D::CShadowMapManager::addShadowReceiver(), NL3D::CShadowPolyReceiver::addTriangle(), NL3D::CLandscape::addZone(), NLPACS::CEdgeQuad::build(), NLPACS::CChainQuad::build(), NL3D::CShadowMap::buildCasterCameraMatrix(), NL3D::CLandscape::buildPatchBlocksInBBox(), NL3D::CLandscape::buildTrianglesInBBox(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), computeAABBoxUnion(), NL3D::CLandscape::computeDynamicLighting(), computeIntersection(), NL3D::CInstanceLighter::computeSunContribution(), NL3D::CVisualCollisionManager::CStaticGrid::create(), NL3D::CPSUtil::displayBBox(), extend(), NLSOUND::CClusteredSound::getAABoxNearestPos(), NL3D::CVisualCollisionManager::getCameraCollision(), NL3D::CShadowPolyReceiver::getCameraCollision(), NL3D::CMiniCol::getFaces(), NL3D::CQuadGridClipClusterQTreeNode::init(), NLPACS::CLocalRetriever::initFaceGrid(), intersect(), NLPACS::CGlobalRetriever::makeInstance(), NL3D::CZoneLighter::makeQuadGridFromWaterShapes(), NL3D::CClipTrav::registerCluster(), NL3D::CMiniCol::removeLandScapePart(), NL3D::CLandscape::removeZone(), NL3D::CShadowPolyReceiver::render(), NL3D::CShadowMapManager::renderProject(), NLPACS::CLocalRetriever::retrieveAccuratePosition(), NLPACS::CLocalRetriever::retrievePosition(), NL3D::CVisualCollisionManager::CStaticGrid::select(), NLPACS::CEdgeQuad::selectEdges(), NLPACS::CChainQuad::selectEdges(), NLPACS::CGlobalRetriever::selectInstances(), and transformAABBox(). +

+

00086 {return Center-HalfSize;}
+
+

+ + + + +
+ + + + + + + + + + +
float NLMISC::CAABBox::getRadius void   )  const [inline]
+
+ + + + + +
+   + + +

+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();}
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::getSize CVector ret  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 94 of file aabbox.h. +

+References HalfSize. +

+

00094 {ret= HalfSize*2;}
+
+

+ + + + +
+ + + + + + + + + + +
CVector NLMISC::CAABBox::getSize void   )  const [inline]
+
+ + + + + +
+   + + +

+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;}
+
+

+ + + + +
+ + + + + + + + + + +
bool NLMISC::CAABBox::include const CAABBox box  )  const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLMISC::CAABBox::include const CVector a  )  const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NLMISC::CAABBox::intersect const CVector a,
const CVector b
const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLMISC::CAABBox::intersect const CBSphere s  )  const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bool NLMISC::CAABBox::intersect const CVector a,
const CVector b,
const CVector c
const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLMISC::CAABBox::intersect const CAABBox box  )  const
+
+ + + + + +
+   + + +

+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(). +

+

00108 {
+00109         CVector mina = getMin(), maxa = getMax(),
+00110                         minb = box.getMin(), maxb = box.getMax();
+00111 
+00112         return ! ( mina.x > maxb.x ||
+00113                            mina.y > maxb.y ||
+00114                            mina.z > maxb.z ||
+00115                            minb.x > maxa.x ||
+00116                            minb.y > maxa.y ||
+00117                            minb.z > maxa.z);
+00118 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::makePyramid CPlane  planes[6]  )  const
+
+ + + + + +
+   + + +

+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 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::serial NLMISC::IStream f  ) 
+
+ + + + + +
+   + + +

+ +

+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 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::setCenter const CVector center  )  [inline]
+
+ + + + + +
+   + + +

+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 in NLMISC::CAABBoxExt. +

+Definition at line 66 of file aabbox.h. +

+Referenced by NL3D::CMiniCol::addFaces(), NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CShadowPolyReceiver::addTriangle(), NL3D::CZone::applyHeightField(), NL3D::CZone::build(), NL3D::CVisualCollisionManager::CMeshCol::build(), NLPACS::CEdgeQuad::build(), NLPACS::CChainQuad::build(), NL3D::CCameraCol::build(), NL3D::CShadowMap::buildClipInfoFromMatrix(), NL3D::CPatchDLMPointLight::compile(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), NL3D::CSkeletonModel::computeCurrentBBox(), NL3D::CSkeletonModel::computeRenderedBBox(), NLPACS::computeRetriever(), NL3D::CInstanceLighter::computeSunContribution(), NLPACS::computeSurfaceQuadTree(), NLPACS::CCollisionMeshBuild::computeTrivialTranslation(), NL3D::CSkeletonShape::CSkeletonShape(), NLPACS::CSurfaceQuadTree::CSurfaceQuadTree(), NL3D::CVisualCollisionEntity::doComputeLandscape(), NLPACS::CGlobalRetriever::doMove(), NL3D::CVegetableClipBlock::extendSphere(), NL3D::CTessBlock::extendSphereFirst(), NLPACS::CGlobalRetriever::findCollisionChains(), NL3D::CParticleSystem::forceComputeBBox(), NL3D::CPatchDLMContext::generate(), NL3D::CWaveMakerShape::getAABBox(), NL3D::CTransformShape::getAABBox(), NL3D::CTransform::getAABBox(), NL3D::IShape::getAABBox(), NL3D::CParticleSystemShape::getAABBox(), NL3D::CFlareShape::getAABBox(), NLMISC::CAABBoxExt::getAABBox(), NLPACS::IQuadNode::getBBox(), NLPACS::CGlobalRetriever::getBorders(), NL3D::CMiniCol::getGroundNormal(), NL3D::CTransform::getReceiverBBox(), NL3D::CLandscapeModel::getReceiverBBox(), H_AUTO_DECL(), NLPACS::CSurfaceQuadTree::init(), NL3D::CQuadGridClipClusterQTreeNode::init(), NLPACS::CLocalRetriever::initFaceGrid(), NL3D::CInstanceLighter::light(), NL3D::CQuadGridClipManager::linkModel(), NLPACS::CRetrieverInstance::make(), NL3D::makeBBox(), NL3D::CCluster::makeVolume(), NLPACS::CGlobalRetriever::refreshLrAround(), NLPACS::CGlobalRetriever::refreshLrAroundNow(), NL3D::CMiniCol::removeLandScapePart(), NL3D::CShadowPolyReceiver::render(), NL3D::CShadowMapManager::renderProject(), NLPACS::CGlobalRetriever::retrievePosition(), NLPACS::CGlobalRetriever::testBBoxMove(), NLPACS::CGlobalRetriever::testBBoxRot(), NLPACS::CGlobalRetriever::testCylinderMove(), and NLPACS::CSurfaceQuadTree::translate(). +

+

00066 {Center= center;}
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::setHalfSize const CVector hs  )  [inline]
+
+ + + + + +
+   + + +

+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 in NLMISC::CAABBoxExt. +

+Definition at line 67 of file aabbox.h. +

+References HalfSize. +

+Referenced by NL3D::CPSUtil::addRadiusToAABBox(), NL3D::CLandscape::addZone(), NL3D::CZone::applyHeightField(), NL3D::CZone::build(), NL3D::CCameraCol::build(), NL3D::CShadowMap::buildCasterCameraMatrix(), NL3D::CShadowMap::buildClipInfoFromMatrix(), NL3D::CPatchDLMPointLight::compile(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), NL3D::CSkeletonModel::computeCurrentBBox(), NL3D::CSkeletonModel::computeRenderedBBox(), NLPACS::computeRetriever(), NL3D::CVisualCollisionEntity::CVisualCollisionEntity(), NL3D::CVisualCollisionEntity::doComputeLandscape(), NL3D::CVegetableClipBlock::extendSphere(), NL3D::CTessBlock::extendSphereFirst(), NL3D::CParticleSystem::forceComputeBBox(), NL3D::CWaveMakerShape::getAABBox(), NL3D::CTransformShape::getAABBox(), NL3D::CTransform::getAABBox(), NL3D::IShape::getAABBox(), NL3D::CParticleSystemShape::getAABBox(), NL3D::CFlareShape::getAABBox(), NLMISC::CAABBoxExt::getAABBox(), NLPACS::IQuadNode::getBBox(), NLPACS::CGlobalRetriever::getBorders(), NL3D::CTransform::getReceiverBBox(), NL3D::CLandscapeModel::getReceiverBBox(), H_AUTO_DECL(), NLPACS::CSurfaceQuadTree::init(), NL3D::CInstanceLighter::light(), NLPACS::CRetrieverInstance::make(), NLPACS::CGlobalRetriever::refreshLrAround(), NLPACS::CGlobalRetriever::refreshLrAroundNow(), NL3D::CMiniCol::removeLandScapePart(), NL3D::CLandscape::removeZone(), and NLPACS::CGlobalRetriever::retrievePosition(). +

+

00067 {HalfSize= hs;}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLMISC::CAABBox::setMinMax const CVector bmin,
const CVector bmax
[inline]
+
+ + + + + +
+   + + +

+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(). +

+

00072         {
+00073                 Center= (bmin+bmax)/2;
+00074                 HalfSize= bmax-Center;
+00075         }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CAABBox::setSize const CVector s  )  [inline]
+
+ + + + + +
+   + + +

+Set the size of the bbox (ie 2* the halfSize). +

+ +

+Reimplemented in NLMISC::CAABBoxExt. +

+Definition at line 69 of file aabbox.h. +

+References HalfSize, and s. +

+Referenced by NL3D::CSkeletonShape::CSkeletonShape(), NLPACS::CSurfaceQuadTree::CSurfaceQuadTree(), and NL3D::CQuadGridClipClusterQTreeNode::init(). +

+

00069 {HalfSize= s/2;}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
CAABBox NLMISC::CAABBox::transformAABBox const CMatrix mat,
const CAABBox box
[static]
+
+ + + + + +
+   + + +

+Apply a matrix on an aabbox

Returns:
an aabbox, bigger or equal to parameter, after the matrix multiplication
+ +

+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 }
+
+


Field Documentation

+

+ + + + +
+ + +
CVector NLMISC::CAABBox::Center [protected] +
+
+ + + + + +
+   + + +

+The center of the bbox. +

+ +

+Definition at line 54 of file aabbox.h. +

+Referenced by include().

+

+ + + + +
+ + +
CVector NLMISC::CAABBox::HalfSize [protected] +
+
+ + + + + +
+   + + +

+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().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 13:00:55 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1