本文整理汇总了C++中CAABBox类的典型用法代码示例。如果您正苦于以下问题:C++ CAABBox类的具体用法?C++ CAABBox怎么用?C++ CAABBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAABBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transformAABBox
//==========================================================================
CAABBox CAABBox::transformAABBox(const CMatrix &mat, const CAABBox &box)
{
// TODO : optimize this a bit if possible...
CAABBox result;
/* OMG. Old code was false!!
if we have ht= M * h
then CVector(-ht.x, ht.y, ht.z) != M * CVector(-h.x, h.y, h.z) !!!!
*/
// compute corners.
CVector p[8];
CVector min= box.getMin();
CVector max= box.getMax();
p[0].set(min.x, min.y, min.z);
p[1].set(max.x, min.y, min.z);
p[2].set(min.x, max.y, min.z);
p[3].set(max.x, max.y, min.z);
p[4].set(min.x, min.y, max.z);
p[5].set(max.x, min.y, max.z);
p[6].set(min.x, max.y, max.z);
p[7].set(max.x, max.y, max.z);
CVector tmp;
min = max = mat * p[0];
// transform corners.
for(uint i=1;i<8;i++)
{
tmp= mat * p[i];
min.minof(min, tmp);
max.maxof(max, tmp);
}
result.setMinMax(min, max);
return result;
}
示例2: checkAttack
bool CActor::checkAttack( CVectorD &pos )
{
/*
if we're close to an actor then attack them
*/
CAABBox box;
box.setCenter(CVector(_x*0.001f, _y*0.001f, 0.0f));
box.setHalfSize(CVector(5.0f, 5.0f, 1.0f));
CMoveManager::Grid.clearSelection();
CMoveManager::Grid.select(box);
CMoveManager::TObstacleGrid::CIterator it;
for (it=CMoveManager::Grid.begin(); it!=CMoveManager::Grid.end(); ++it)
{
CObstacle &other = (*it);
// attacks player if close to me
CVector d = pos-other.Position;
d.z = 0.0f;
if (other.Id.getType() == RYZOMID::player && d.norm() <= _AttackDistance)
{
nlinfo("Actor <%s> attacks player because _AttackDistance = %f and separation = %f", _name.c_str(), _AttackDistance, d.norm());
doFight(other.Id);
return true;
}
}
return false;
}
示例3: initPACS
///////////////
// FUNCTIONS //
///////////////
//-----------------------------------------------
// initPACS :
// Initialize PACS.
//-----------------------------------------------
void initPACS(const char* rbank, const char* gr, NLMISC::IProgressCallback &/* progress */)
{
// Check old PACS is well released.
nlassertex(RB==0, ("RB should be Null before the init."));
nlassertex(GR==0, ("GR should be Null before the init."));
nlassertex(PACS==0, ("PACS should be Null before the init."));
if(rbank != 0 && gr != 0)
{
RB = NLPACS::URetrieverBank::createRetrieverBank(rbank, false);
GR = NLPACS::UGlobalRetriever::createGlobalRetriever(gr, RB);
if (GR)
{
CAABBox cbox = GR->getBBox();
uint gw = (uint)(cbox.getHalfSize().x*2.0 / RYZOM_ENTITY_SIZE_MAX) + 1;
uint gh = (uint)(cbox.getHalfSize().y*2.0 / RYZOM_ENTITY_SIZE_MAX) + 1;
PACS = UMoveContainer::createMoveContainer(GR, gw, gh, RYZOM_ENTITY_SIZE_MAX, 2);
}
else
nlwarning("Could not create global retriever for %s, %s", rbank, gr);
}
// Try to create a PACS with another method.
if(PACS == 0)
PACS = UMoveContainer::createMoveContainer(15000.0, -25000.0, 20000.0, -20000.0, 16, 16, RYZOM_ENTITY_SIZE_MAX, 2);
// Set the static world image.
if(PACS)
PACS->setAsStatic(staticWI);
else
nlwarning("initPACS: cannot create PACS at all.");
}// initPACS //
示例4:
CAABBox NLPACS::CSurfElement::getBBox() const
{
CAABBox box;
box.setCenter((*Vertices)[Tri[0]]);
box.extend((*Vertices)[Tri[1]]);
box.extend((*Vertices)[Tri[2]]);
return box;
}
示例5:
//==========================================================================
void CAABBox::computeIntersection(const CAABBox &b1, const CAABBox &b2)
{
CVector min1 = b1.getMin(), max1 = b1.getMax(),
min2 = b2.getMin(), max2 = b2.getMax();
CVector minr, maxr;
// don't test if intersect or not.
maxr.minof(max1, max2);
minr.maxof(min1, min2);
setMinMax(minr, maxr);
}
示例6: getMin
// ***************************************************************************
bool CAABBox::intersect(const CAABBox &box) const
{
CVector mina = getMin(), maxa = getMax(),
minb = box.getMin(), maxb = box.getMax();
return ! ( mina.x > maxb.x ||
mina.y > maxb.y ||
mina.z > maxb.z ||
minb.x > maxa.x ||
minb.y > maxa.y ||
minb.z > maxa.z);
}
示例7: getSnappedBBox
static CAABBox getSnappedBBox(CVector v0, CVector v1, CVector v2, const CAABBox &bbox)
{
snapAccuracyBit(v0);
snapAccuracyBit(v1);
snapAccuracyBit(v2);
CAABBox box;
box.setCenter(v0);
box.extend(v1);
box.extend(v2);
return box;
}
示例8:
// ***************************************************************************
NLMISC::CAABBox CVisualCollisionMesh::computeWorldBBox(const CMatrix &instanceMatrix)
{
CAABBox ret;
if(!_Vertices.empty())
{
ret.setCenter(instanceMatrix*_Vertices[0]);
for(uint i=1;i<_Vertices.size();i++)
{
ret.extend(instanceMatrix*_Vertices[i]);
}
}
return ret;
}
示例9: getZoneBBoxById
CAABBox getZoneBBoxById(uint16 id)
{
CAABBox bbox;
uint x, y;
const float zdim = 160.0f;
x = id%256;
y = id/256;
bbox.setMinMax(CVector(zdim*x, -zdim*(y+1), -10000.0f),
CVector(zdim*(x+1), -zdim*y, +10000.0f));
return bbox;
}
示例10: getAABBox
// ***************************************************************************
void CTransformShape::getLightHotSpotInWorld(CVector &modelPos, float &modelRadius) const
{
/*
// get the untransformed bbox from the model.
CAABBox bbox;
getAABBox(bbox);
// get transformed center pos of bbox
modelPos= getWorldMatrix() * bbox.getCenter();
// If the model is a big lightable, must take radius from aabbox, else suppose 0 radius.
if(isBigLightable())
{
// get size of the bbox (bounding sphere)
modelRadius= bbox.getRadius();
}
else
{
// Assume 0 radius => faster computeLinearAttenuation()
modelRadius= 0;
}
*/
// This method works well for Big Trees.
// TODO: generalize, saving a LightHotSpot per shape.
// get pos of object. Ie the hotSpot is the pivot.
modelPos= getWorldMatrix().getPos();
// If the model is a big lightable, must take radius from aabbox, else suppose 0 radius.
if(isBigLightable())
{
// get the untransformed bbox from the model.
CAABBox bbox;
getAABBox(bbox);
// get size of the bbox (bounding sphere)
modelRadius= bbox.getRadius();
}
else
{
// Assume 0 radius => faster computeLinearAttenuation()
modelRadius= 0;
}
}
示例11: computeSurfaceQuadTree
void computeSurfaceQuadTree(CInteriorSurface &surface, CSurfaceQuadTree &quad)
{
uint i, j;
CAABBox box;
bool first = true;
for (i=0; i<surface.Faces.size(); ++i)
{
for (j=0; j<3; ++j)
{
const CVector &v = surface.CollisionMeshBuild->Vertices[surface.CollisionMeshBuild->Faces[surface.Faces[i]].V[j]];
if (first)
box.setCenter(v), first=false;
else
box.extend(v);
}
}
quad.clear();
quad.init(4.0f, 6, box.getCenter(), std::max(box.getHalfSize().x, box.getHalfSize().y));
for (i=0; i<surface.Faces.size(); ++i)
{
for (j=0; j<3; ++j)
{
const CVector &v = surface.CollisionMeshBuild->Vertices[surface.CollisionMeshBuild->Faces[surface.Faces[i]].V[j]];
quad.addVertex(v);
}
}
quad.compile();
}
示例12: nlinfo
/*
* render()
*/
void CPrimChecker::render(CPrimZone *zone, uint8 bits)
{
if (zone->VPoints.size() < 3)
return;
string name;
if (zone->getPropertyByName("name", name) && Verbose)
nlinfo("Rendering CPrimZone '%s'", name.c_str());
// get the bouding box of the CPrimZone
CAABBox box;
box.setCenter(zone->VPoints[0]);
box.setHalfSize(CVector::Null);
uint i;
for (i=1; i<zone->VPoints.size(); ++i)
box.extend(zone->VPoints[i]);
sint32 xmin, ymin, xmax, ymax;
xmin = (sint32)(floor(box.getMin().x));
ymin = (sint32)(floor(box.getMin().y));
xmax = (sint32)(ceil(box.getMax().x));
ymax = (sint32)(ceil(box.getMax().y));
// Fill grid with points that belong to the CPrimZone
sint32 x, y;
for (y=ymin; y<=ymax; ++y)
for (x=xmin; x<=xmax; ++x)
if (zone->contains(CVector((float)x, (float)y, 0.0f)))
_Grid.set(x, y, bits);
}
示例13: computeAABBoxUnion
CAABBox CAABBox::computeAABBoxUnion(const CAABBox &b1, const CAABBox &b2)
{
CAABBox result;
CVector min, max;
CVector min1 = b1.getMin()
,max1 = b1.getMax()
,min2 = b2.getMin()
,max2 = b2.getMax();
max.maxof(max1, max2);
min.minof(min1, min2);
result.setMinMax(min, max);
return result;
}
示例14: CVector
// ***************************************************************************
void CQuadGridClipClusterQTreeNode::init(CQuadGridClipCluster *owner, uint level, bool rootNode, const NLMISC::CAABBox &pivot)
{
Owner= owner;
RootNode= rootNode;
PivotBBox= pivot;
// If not a leaf, create sons
if(level>0)
{
LeafNode= false;
// split pivot for sons
CAABBox pivotSon;
pivotSon.setSize(PivotBBox.getHalfSize());
float xMin= PivotBBox.getMin().x/2;
float yMin= PivotBBox.getMin().y/2;
float xMax= PivotBBox.getMax().x/2;
float yMax= PivotBBox.getMax().y/2;
float xCenter= PivotBBox.getCenter().x/2;
float yCenter= PivotBBox.getCenter().y/2;
// LeftDown
pivotSon.setCenter( CVector(xMin+xCenter,yMin+yCenter,0) );
Sons[NL3D_QCC_LEFT_DOWN]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_LEFT_DOWN]->init(owner, level-1, false, pivotSon);
// RightDown
pivotSon.setCenter( CVector(xMax+xCenter,yMin+yCenter,0) );
Sons[NL3D_QCC_RIGHT_DOWN]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_RIGHT_DOWN]->init(owner, level-1, false, pivotSon);
// LeftUp
pivotSon.setCenter( CVector(xMin+xCenter,yMax+yCenter,0) );
Sons[NL3D_QCC_LEFT_UP]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_LEFT_UP]->init(owner, level-1, false, pivotSon);
// RithgUp
pivotSon.setCenter( CVector(xMax+xCenter,yMax+yCenter,0) );
Sons[NL3D_QCC_RIGHT_UP]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_RIGHT_UP]->init(owner, level-1, false, pivotSon);
}
else
{
LeafNode= true;
}
// Create the distMax list only if root or leaf. No models in interleaved branches.
if( LeafNode)
ListNode.Models.resize(Owner->_NumDistTotal);
}
示例15: main
int main(int argc, char **argv)
{
// Filter addSearchPath
NLMISC::createDebug();
InfoLog->addNegativeFilter("adding the path");
createDebug();
try
{
// Init
init();
uint i, j, k;
for (i=0; i<IGs.size(); ++i)
{
// load ig associated to the zone
string igName = IGs[i]+".ig";
CIFile igStream(CPath::lookup(igName));
CInstanceGroup ig;
igStream.serial(ig);
CAABBox igBBox;
bool boxSet = false;
nlinfo("Generating BBOX for %s", igName.c_str());
// search in group for water instance
for (j=0; j<ig._InstancesInfos.size(); ++j)
{
/*
Ben: c'est degueulasse, mais c'est les coders a la 3D, y savent pas coder
Hld: ouai, mais ca marche pas ton truc, alors p'tet qu'on sait pas coder mais toi non plus :p Special Dedicace to SupaGreg!
string shapeName = ig._InstancesInfos[j].Name+".shape";
*/
string shapeName = ig._InstancesInfos[j].Name;
if (CFile::getExtension (shapeName) == "")
shapeName += ".shape";
if (NonWaterShapes.find(shapeName) != NonWaterShapes.end())
continue;
string shapeNameLookup = CPath::lookup (shapeName, false, false);
if (!shapeNameLookup.empty())
{
CIFile f;
if (f.open (shapeNameLookup))
{
CShapeStream shape;
shape.serial(f);
CWaterShape *wshape = dynamic_cast<CWaterShape *>(shape.getShapePointer());
if (wshape == NULL)
{
NonWaterShapes.insert(shapeName);
continue;
}
CMatrix matrix;
ig.getInstanceMatrix(j, matrix);
CPolygon wpoly;
wshape->getShapeInWorldSpace(wpoly);
for (k=0; k<wpoly.Vertices.size(); ++k)
{
if (boxSet)
{
igBBox.extend(matrix * wpoly.Vertices[k]);
}
else
{
igBBox.setCenter(matrix * wpoly.Vertices[k]);
boxSet = true;
}
}
}
else
{
nlwarning ("Can't load shape %s", shapeNameLookup.c_str());
}
}
else
{
NonWaterShapes.insert(shapeName);
}
}
if (boxSet)
{
Boxes.push_back(CIGBox(igName, igBBox));
nlinfo("Bbox: (%.1f,%.1f)-(%.1f,%.1f)", igBBox.getMin().x, igBBox.getMin().y, igBBox.getMax().x, igBBox.getMax().y);
}
}
COFile output(Output);
output.serialCont(Boxes);
}
catch (Exception &e)
//.........这里部分代码省略.........