本文整理汇总了C++中nlmisc::CAABBox类的典型用法代码示例。如果您正苦于以下问题:C++ CAABBox类的具体用法?C++ CAABBox怎么用?C++ CAABBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAABBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawBBox
// *********************************************************************************************************
void CDisplayerVisualEntity::drawBBox(const NLMISC::CMatrix &modelMatrix, const NLMISC::CAABBox &bbox, NLMISC::CRGBA colOverZ, NLMISC::CRGBA colUnderZ)
{
//H_AUTO(R2_CDisplayerVisualEntity_drawBBox)
//nlwarning("bbox = (%f, %f, %f) - (%f, %f, %f), color = (%d, %d, %d, %d)", bbox.getMin().x, bbox.getMin().y, bbox.getMin().z,
// bbox.getMax().x, bbox.getMax().y, bbox.getMax().z, (int) colOverZ.R, (int) colOverZ.G, (int) colOverZ.B, (int) colOverZ.A);
// for z-precision, work with camera at (0, 0, 0)
static volatile bool fixMatrixPos = false;
CMatrix oldViewMatrix = Driver->getViewMatrix();
Driver->setModelMatrix(modelMatrix);
CMatrix viewMat = oldViewMatrix;
if (fixMatrixPos)
{
viewMat.setPos(CVector::Null);
}
Driver->setViewMatrix(viewMat);
// draw below zbuffer
UMaterial::ZFunc oldZfunc = GenericMat.getZFunc();
bool oldZWrite = GenericMat.getZWrite();
GenericMat.setZFunc(UMaterial::greater);
GenericMat.setZWrite(false);
::drawBox(bbox.getMin(), bbox.getMax(), colUnderZ );
GenericMat.setZFunc(oldZfunc);
GenericMat.setZWrite(oldZWrite);
::drawBox(bbox.getMin(), bbox.getMax(), colOverZ);
Driver->setViewMatrix(oldViewMatrix);
}
示例2: sizeof
// ***************************************************************************
void CVisualCollisionMesh::CStaticGrid::create(uint nbQuads, uint nbElts, const NLMISC::CAABBox &gridBBox)
{
/* ***********************************************
* WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance
* It can be loaded/called through CAsyncFileManager for instance
* ***********************************************/
nlassert(nbQuads>0 && isPowerOf2(nbQuads));
// init the grid
_GridSize= nbQuads;
_GridSizePower= getPowerOf2(nbQuads);
_Grid.resize(_GridSize*_GridSize);
// start with 0 elt in each case
memset(_Grid.getPtr(), 0, _Grid.size() * sizeof(CCase));
// init the Elt Build
_EltBuild.resize(nbElts);
// total size is 0
_GridDataSize= 0;
// bbox init
_GridPos= gridBBox.getMin();
_GridScale= gridBBox.getSize();
_GridScale.x= _GridSize / _GridScale.x;
_GridScale.y= _GridSize / _GridScale.y;
// reset intersection data
_ItSession= 0;
}
示例3:
// ***************************************************************************
void CQuadGridClipClusterQTreeNode::insertModel(const NLMISC::CAABBox &worldBBox, uint distSetup, CTransformShape *model)
{
// if leaf node, insert the model in the list
if( LeafNode )
{
if(Empty)
{
Empty= false;
BBox= worldBBox;
}
else
{
// extend the bbox with 2 corners of the incoming bbox (sufficient for an AABBox).
BBox.extend( worldBBox.getCenter() + worldBBox.getHalfSize() );
BBox.extend( worldBBox.getCenter() - worldBBox.getHalfSize() );
}
// insert in list
ListNode.insertModel(distSetup, model);
}
// else, recurs insert in branch
else
{
// choose what son according to pivot.
CQuadGridClipClusterQTreeNode *selectSon;
if( worldBBox.getCenter().y<PivotBBox.getCenter().y )
{
if( worldBBox.getCenter().x<PivotBBox.getCenter().x )
selectSon= Sons[NL3D_QCC_LEFT_DOWN];
else
selectSon= Sons[NL3D_QCC_RIGHT_DOWN];
}
else
{
if( worldBBox.getCenter().x<PivotBBox.getCenter().x )
selectSon= Sons[NL3D_QCC_LEFT_UP];
else
selectSon= Sons[NL3D_QCC_RIGHT_UP];
}
// insert in this cluster
selectSon->insertModel(worldBBox, distSetup, model);
// extend my boox according to this son cluster.
if(Empty)
{
Empty= false;
BBox= selectSon->BBox;
}
else
{
// extend the bbox with 2 corners of the son bbox (sufficient for an AABBox).
BBox.extend( selectSon->BBox.getCenter() + selectSon->BBox.getHalfSize() );
BBox.extend( selectSon->BBox.getCenter() - selectSon->BBox.getHalfSize() );
}
}
// update bboxExt
BBoxExt= BBox;
}
示例4: getSelectBox
// *********************************************************************************************************
NLMISC::CAABBox CDisplayerVisualEntity::getSelectBox() const
{
//H_AUTO(R2_NLMISC_CAABBox )
if (!_Entity)
{
if (_PlaceHolder)
{
return _PlaceHolder->getSelectBox();
}
return CDisplayerVisual::getSelectBox();
}
if (getSelectionType() == ISelectableObject::LocalSelectBox ||
getSelectionType() == ISelectableObject::GroundProjected
)
{
if (_Entity->isAsyncLoading())
{
NLMISC::CAABBox result;
result.setCenter(CVector::Null);
result.setHalfSize(CVector::Null);
return result;
}
return getEditor().getLocalSelectBox(*_Entity);
}
else
{
return getEditor().getSelectBox(*_Entity);
}
}
示例5: updatePrecomputedBBoxParams
void CParticleSystemPage::updatePrecomputedBBoxParams()
{
NLMISC::CAABBox b;
_Node->getPSPointer()->computeBBox(b);
_ui.xDoubleSpinBox->setValue(b.getHalfSize().x);
_ui.yDoubleSpinBox->setValue(b.getHalfSize().y);
_ui.zDoubleSpinBox->setValue(b.getHalfSize().z);
}
示例6: decBbox
void CParticleSystemPage::decBbox()
{
NLMISC::CAABBox b;
_Node->getPSPointer()->computeBBox(b);
b.setHalfSize(0.9f * b.getHalfSize());
_Node->getPSPointer()->setPrecomputedBBox(b);
updatePrecomputedBBoxParams();
}
示例7: drawBBox
// *********************************************************************************************************
void CDisplayerVisualShape::drawBBox(NLMISC::CRGBA color) const
{
//H_AUTO(R2_CDisplayerVisualShape_drawBBox)
if (getRotateInProgress()) return; // no drawn while drawing (bbox moved one frame too late, must solve this)
NLMISC::CAABBox bbox;
_Instance.getShapeAABBox(bbox);
Driver->setModelMatrix(_BBoxMatrix);
::drawBox(bbox.getMin(), bbox.getMax(), color);
}
示例8: getSelectBox
// *********************************************************************************************************
NLMISC::CAABBox CDisplayerVisualShape::getSelectBox() const
{
//H_AUTO(R2_CDisplayerVisualShape_getSelectBox)
if (_Instance.empty()) return CDisplayerVisual::getSelectBox();
// TODO nico : cache the bbox
NLMISC::CAABBox bbox;
_Instance.getShapeAABBox(bbox);
bbox.setMinMax(_Scale * bbox.getMin(), _Scale * bbox.getMax());
return bbox;
}
示例9: setZBbox
void CParticleSystemPage::setZBbox(double value)
{
NLMISC::CAABBox b;
_Node->getPSPointer()->computeBBox(b);
NLMISC::CVector h;
h.x = b.getHalfSize().x;
h.y = b.getHalfSize().y;
h.z = value;
b.setHalfSize(h);
_Node->getPSPointer()->setPrecomputedBBox(b);
}
示例10:
// ***************************************************************************
void CTransformShape::getAABBox(NLMISC::CAABBox &bbox) const
{
if(Shape)
{
Shape->getAABBox(bbox);
}
else
{
bbox.setCenter(CVector::Null);
bbox.setHalfSize(CVector::Null);
}
}
示例11:
// ***************************************************************************
uint CVisualCollisionMesh::CStaticGrid::select(const NLMISC::CAABBox &bbox, std::vector<uint16> &res)
{
/* ***********************************************
* WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance
* It can be loaded/called through CAsyncFileManager for instance
* ***********************************************/
// increment the intersection session
_ItSession++;
// enlarge the result array as needed
if(res.size()<_Sessions.size())
res.resize(_Sessions.size());
// the number of selected element
uint numSel= 0;
// compute the 2D bbox
CVector minp= bbox.getMin() - _GridPos;
CVector maxp= bbox.getMax() - _GridPos;
sint xmin= (sint)floorf(minp.x*_GridScale.x);
sint ymin= (sint)floorf(minp.y*_GridScale.y);
sint xmax= (sint)ceilf(maxp.x*_GridScale.x);
sint ymax= (sint)ceilf(maxp.y*_GridScale.y);
clamp(xmin, 0, (sint)_GridSize-1);
clamp(ymin, 0, (sint)_GridSize-1);
clamp(xmax, xmin+1, (sint)_GridSize);
clamp(ymax, ymin+1, (sint)_GridSize);
// for each case touched, increment NumElts
for(uint y=ymin;y<(uint)ymax;y++)
{
for(uint x=xmin;x<(uint)xmax;x++)
{
CCase &gcase= _Grid[(y<<_GridSizePower)+x];
// for each element in this case
for(uint i= gcase.Start;i<gcase.Start + gcase.NumElts;i++)
{
uint elt= _GridData[i];
// if not alread inserted in the dest
if(_Sessions[elt]!=_ItSession)
{
// mark as intersected
_Sessions[elt]= _ItSession;
// append
res[numSel++]= elt;
}
}
}
}
// return the number of selected elements
return numSel;
}
示例12:
///===========================================================================
void CParticleSystemShape::getAABBox(NLMISC::CAABBox &bbox) const
{
if (!_UsePrecomputedBBox)
{
bbox.setCenter(NLMISC::CVector::Null);
bbox.setHalfSize(NLMISC::CVector(1, 1, 1));
}
else
{
bbox = _PrecomputedBBox;
}
}
示例13: isInProjection
// *********************************************************************************************************
bool CDisplayerVisualEntity::isInProjection(const NLMISC::CVector2f &pos) const
{
//H_AUTO(R2_CDisplayerVisualEntity_isInProjection)
if (getActualSelectionDisplayMode() == CircleSelection) return false;
nlassert(getSelectionType() == LocalSelectBox || getSelectionType() == GroundProjected);
CVector localPos = getInvertedMatrix() * pos;
NLMISC::CAABBox selectBox = getSelectBox();
CVector pmin = selectBox.getMin();
CVector pmax = selectBox.getMax();
if (localPos.x < pmin.x || localPos.x > pmax.x ||
localPos.y < pmin.y || localPos.y > pmax.y) return false;
return true;
}
示例14: evalIconInScenePos
// *********************************************************************************************************
void CDisplayerVisual::evalIconInScenePos(NLMISC::CVector &dest) const
{
//H_AUTO(R2_CDisplayerVisual_evalIconInScenePos)
NLMISC::CAABBox selectBox = getSelectBox();
float radius = std::max(selectBox.getHalfSize().x, selectBox.getHalfSize().y);
// use middle front of bbox for icon pos
NLMISC::CVector result = getWorldPos().asVector() - radius * MainCam.getMatrix().getJ() + selectBox.getHalfSize().z * CVector::K;
static volatile bool wantAssert = true;
if (!isValidDouble(result.x) || !isValidDouble(result.y) ||!isValidDouble(result.z))
{
nlassert(!wantAssert);
return;
}
dest = result;
}
示例15:
//============================================
void CWaveMakerShape::getAABBox(NLMISC::CAABBox &bbox) const
{
// its just a point
bbox.setCenter(NLMISC::CVector::Null);
bbox.setHalfSize(NLMISC::CVector::Null);
}