本文整理汇总了C++中BoxVolume类的典型用法代码示例。如果您正苦于以下问题:C++ BoxVolume类的具体用法?C++ BoxVolume怎么用?C++ BoxVolume使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoxVolume类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extend
OSG_BASE_DLLMAPPING
void extend(BoxVolume &srcVol, const Volume &vol)
{
const Volume *v = &vol;
const BoxVolume *box;
#ifndef OSG_2_PREP
const DynamicVolume *dynamic = dynamic_cast<const DynamicVolume *>(v);
if(dynamic)
{
v = &(dynamic->getInstance());
}
#endif
if((box = dynamic_cast<const BoxVolume *>(v)))
{
OSG::extend(srcVol, *box);
}
else
{
BoxVolume localBox;
Pnt3f min, max;
v->getBounds(min, max);
localBox.setBounds(min, max);
OSG::extend(srcVol, localBox);
}
}
示例2: doBuild
UInt32 ParticleBSPTree::doBuild(std::vector<Int32>::iterator begin,
std::vector<Int32>::iterator end,
UInt32 nodeindex,
GeoVectorProperty *pos)
{
// reached a leaf?
if(begin + 1 == end)
{
_tree[nodeindex].setValue(*begin);
return nodeindex + 1;
}
// find the bounding volume of the group
BoxVolume b;
Pnt3f p;
b.setEmpty();
for(std::vector<Int32>::iterator i = begin; i != end; ++i)
{
pos->getValue(p,*i);
b.extendBy(p);
}
// find the axis with the longest extension
Vec3f d = b.getMax() - b.getMin();
UInt8 axis = ParticleBSPNode::X;
Real32 maxval = d[0];
if(d[1] > maxval)
{
axis = ParticleBSPNode::Y;
maxval = d[1];
}
if(d[2] > maxval)
{
axis = ParticleBSPNode::Z;
maxval = d[2];
}
// sort in that axis
ParticleCompare comp(pos, axis);
std::sort(begin,end,comp);
// find median value
std::vector<Int32>::iterator mid = begin + (end - begin) / 2;
Pnt3f p2;
pos->getValue(p ,*mid);
pos->getValue(p2,(*mid)-1);
_tree[nodeindex].setSplit(axis, (p[axis] + p2[axis]) / 2.f);
return osgMax( doBuild(begin, mid, nodeindex * 2 , pos),
doBuild( mid, end, nodeindex * 2 + 1, pos) );
}
示例3: circumscribe
OSG_BEGIN_NAMESPACE
#if 0
/*! Return a sphere containing a given box */
void SphereVolume::circumscribe(const BoxVolume &box)
{
float radius = 0.5 * (box.getMax() - box.getMin()).length();
Vec3f center;
box.getCenter(center);
setValue(center, radius);
}
示例4: drawVolume
/*! \ingroup GrpSystemDrawablesGeometryFunctions
Draw the given BoxVolume using direct OpenGL calls.
*/
OSG_SYSTEMLIB_DLLMAPPING
void OSG::drawVolume(const BoxVolume &volume)
{
Pnt3f min,max;
volume.getBounds(min, max);
glBegin(GL_LINE_LOOP);
glVertex3f(min[0], min[1], min[2]);
glVertex3f(max[0], min[1], min[2]);
glVertex3f(max[0], max[1], min[2]);
glVertex3f(min[0], max[1], min[2]);
glVertex3f(min[0], min[1], min[2]);
glVertex3f(min[0], min[1], max[2]);
glVertex3f(max[0], min[1], max[2]);
glVertex3f(max[0], max[1], max[2]);
glVertex3f(min[0], max[1], max[2]);
glVertex3f(min[0], min[1], max[2]);
glEnd();
glBegin(GL_LINES);
glVertex3f(min[0], max[1], min[2]);
glVertex3f(min[0], max[1], max[2]);
glVertex3f(max[0], max[1], min[2]);
glVertex3f(max[0], max[1], max[2]);
glVertex3f(max[0], min[1], min[2]);
glVertex3f(max[0], min[1], max[2]);
glEnd();
return;
}
示例5: draw
Action::ResultE draw(DrawEnv *)
{
BoxVolume vol;
_node->getWorldVolume(vol);
Pnt3f Min,Max;
vol.getBounds(Min,Max);
Real32 Length(1.05f * (Max-Min).maxValue());
drawPhysicsBodyCoordinateSystem(_body, Length);
drawPhysicsBodyLinearVelocity(_body, Length);
drawPhysicsBodyAngularVelocity(_body, Length);
// self-destruct
delete this;
return Action::Continue;
}
示例6: getTravMask
void Node::updateVolume(void)
{
// still valid or static, nothing to do
if(_sfVolume.getValue().isValid () == true ||
_sfVolume.getValue().isStatic() == true ||
getTravMask() == 0x0000 )
{
return;
}
// be careful to not change the real volume. If two threads
// are updating the same aspect this will lead to chaos
BoxVolume vol = _sfVolume.getValue();
MFUnrecChildNodePtr::const_iterator cIt =
this->getMFChildren()->begin();
MFUnrecChildNodePtr::const_iterator cEnd =
this->getMFChildren()->end();
vol.setEmpty();
for(; cIt != cEnd; ++cIt)
{
if(*cIt != NULL && (*cIt)->getTravMask())
{
(*cIt)->updateVolume();
vol.extendBy((*cIt)->getVolume());
}
}
// test for null core. Shouldn't happen, but just in case...
if(getCore() != NULL)
{
getCore()->adjustVolume(vol);
}
// don't propagate the static flag from children
vol.setStatic(false);
editSField(VolumeFieldMask);
_sfVolume.setValue(vol);
}
示例7: isVisible
// test a single node
bool RenderPartition::isVisible(Node *pNode)
{
if(getFrustumCulling() == false)
return true;
if(_oDrawEnv.getStatCollector() != NULL)
{
_oDrawEnv.getStatCollector()->getElem(statCullTestedNodes)->inc();
}
// _oDrawEnv.getRTAction()->getStatistics()->getElem(statCullTestedNodes)->inc();
if(pNode->getVolume().isInfinite() == true)
return true;
BoxVolume vol;
pNode->updateVolume();
vol = pNode->getVolume();
vol.transform(topMatrix());
if(_oFrustum.intersect(vol))
{
// fprintf(stderr,"%p: node 0x%p vis\n", Thread::getCurrent(), node);
return true;
}
if(_oDrawEnv.getStatCollector() != NULL)
{
_oDrawEnv.getStatCollector()->getElem(statCulledNodes)->inc();
}
// _oDrawEnv.getRTAction()->getStatistics()->getElem(statCulledNodes)->inc();
// fprintf(stderr,"%p: node 0x%p invis\n", Thread::getCurrent(), node);
// _frustum.dump();
return false;
}
示例8: intersect
OSG_BASE_DLLMAPPING
bool intersect(const BoxVolume &box, const FrustumVolume &frustum)
{
Pnt3f min, max;
box.getBounds(min, max);
const Plane *frust = frustum.getPlanes();
// check each point of the box to the 6 planes
for(Int32 i = 0; i < 6; i++)
{
if(frust[i].isOutHalfSpace(min, max))
return false;
}
return true;
}
示例9: getWorldVolume
void Node::getWorldVolume(BoxVolume &result)
{
Matrix m;
if(getParent() != NULL)
{
getParent()->getToWorld(m);
}
else
{
m.setIdentity();
}
updateVolume();
result = getVolume();
result.transform(m);
}
示例10: intersect
bool Line::intersect(const BoxVolume &box,
Real &enter,
Real &exit ) const
{
Pnt3r low;
Pnt3r high;
box.getBounds(low, high);
Real r;
Real te;
Real tl;
Real in = 0.f;
Real out = Inf;
if(_dir[0] > TypeTraits<Real>::getDefaultEps())
{
r = 1.f / _dir[0];
te = (low [0] - _pos[0]) * r;
tl = (high[0] - _pos[0]) * r;
if(tl < out)
out = tl;
if(te > in)
in = te;
}
else if(_dir[0] < -TypeTraits<Real>::getDefaultEps())
{
r = 1.f / _dir[0];
te = (high[0] - _pos[0]) * r;
tl = (low [0] - _pos[0]) * r;
if(tl < out)
out = tl;
if(te > in)
in = te;
}
else if(_pos[0] < low[0] || _pos[0] > high[0])
{
return false;
}
if(_dir[1] > TypeTraits<Real>::getDefaultEps())
{
r = 1.f / _dir[1];
te = (low [1] - _pos[1]) * r;
tl = (high[1] - _pos[1]) * r;
if(tl < out)
out = tl;
if(te > in)
in = te;
if(in-out >= TypeTraits<Real>::getDefaultEps())
return false;
}
else if(_dir[1] < -TypeTraits<Real>::getDefaultEps())
{
r = 1.f / _dir[1];
te = (high[1] - _pos[1]) * r;
tl = (low [1] - _pos[1]) * r;
if(tl < out)
out = tl;
if(te > in)
in = te;
if(in-out >= TypeTraits<Real>::getDefaultEps())
return false;
}
else if(_pos[1] < low[1] || _pos[1] > high[1])
{
return false;
}
if(_dir[2] > TypeTraits<Real>::getDefaultEps())
{
r = 1.f / _dir[2];
te = (low [2] - _pos[2]) * r;
tl = (high[2] - _pos[2]) * r;
if(tl < out)
out = tl;
if(te > in)
in = te;
}
else if(_dir[2] < -TypeTraits<Real>::getDefaultEps())
{
r = 1.f / _dir[2];
//.........这里部分代码省略.........
示例11: collectDrawables
void SortLastWindow::collectDrawables(Node * const node,
DrawableListT &drawables)
{
Material *mat = NULL;
NodeCore *core = node->getCore();
if(core != NULL)
{
// handle material groups
MaterialGroup *matGrp = dynamic_cast<MaterialGroup *>(core);
if(matGrp != NULL)
{
mat = matGrp->getMaterial();
// ignore transparent material groups
if(mat != NULL && mat->isTransparent())
return;
}
// handle geometries
Geometry *geo = dynamic_cast<Geometry *>(core);
if(geo != NULL)
{
mat = geo->getMaterial();
// ignore transparent materials
if(mat == NULL || mat->isTransparent() == false)
{
DrawableInfo drawableInfo;
drawableInfo.node = node;
// get transformed volume
node->updateVolume();
BoxVolume volume;
node->getWorldVolume(volume);
// get min,max
volume.getBounds(drawableInfo.bMin, drawableInfo.bMax);
// num of indices
drawableInfo.load = 0;
GeoIntegralProperty *indicesPtr =
geo->getIndex(Geometry::PositionsIndex);
if(indicesPtr != NULL)
drawableInfo.load = indicesPtr->size();
// put to list
drawables.push_back(drawableInfo);
}
}
// handle poxy groups
ProxyGroup *proxy = dynamic_cast<ProxyGroup *>(core);
if(proxy != NULL)
{
DrawableInfo drawableInfo;
drawableInfo.node = node;
// get transformed volume
node->updateVolume();
BoxVolume volume;
node->getWorldVolume(volume);
// get min,max
volume.getBounds(drawableInfo.bMin, drawableInfo.bMax);
// num of indices
drawableInfo.load = proxy->getIndices();
// put to list
drawables.push_back(drawableInfo);
}
}
MFUnrecChildNodePtr::const_iterator nI;
for( nI = node->getMFChildren()->begin();
nI != node->getMFChildren()->end();
++nI)
{
collectDrawables(*nI, drawables);
}
}
示例12: selectedNodeChanged
void selectedNodeChanged(void)
{
_mgr->setHighlight(_SelectedNode);
//Update Details Panel
if(_SelectedNode == NULL)
{
_NodeNameValueLabel->setText("");
_NodeCoreTypeValueLabel->setText("");
_NodeMinValueLabel->setText("");
_NodeMaxValueLabel->setText("");
_NodeCenterValueLabel->setText("");
_NodeTriCountValueLabel->setText("");
_NodeTravMaskValueLabel->setText("");
}
else
{
const Char8 *NodeName = getName(_SelectedNode);
if(NodeName == NULL)
{
_NodeNameValueLabel->setText("Unnamed Node");
}
else
{
_NodeNameValueLabel->setText(NodeName);
}
_NodeCoreTypeValueLabel->setText(_SelectedNode->getCore()->getType().getCName());
BoxVolume DyVol;
_SelectedNode->getWorldVolume(DyVol);
Pnt3f Min,Max,Center;
DyVol.getBounds(Min,Max);
DyVol.getCenter(Center);
std::string TempText("");
TempText = boost::lexical_cast<std::string>(Min.x())
+ ", " +boost::lexical_cast<std::string>(Min.x())
+ ", " + boost::lexical_cast<std::string>(Min.x());
_NodeMinValueLabel->setText(TempText);
TempText = boost::lexical_cast<std::string>(Max.x())
+ ", " +boost::lexical_cast<std::string>(Max.x())
+ ", " + boost::lexical_cast<std::string>(Max.x());
_NodeMaxValueLabel->setText(TempText);
TempText = boost::lexical_cast<std::string>(Center.x())
+ ", " +boost::lexical_cast<std::string>(Center.x())
+ ", " + boost::lexical_cast<std::string>(Center.x());
_NodeCenterValueLabel->setText(TempText);
_NodeTravMaskValueLabel->setText(boost::lexical_cast<std::string>(_SelectedNode->getTravMask()));
//Tri Cound
TriCountGraphOpRefPtr TheTriGraphOp = TriCountGraphOp::create();
TheTriGraphOp->traverse(_SelectedNode);
_NodeTriCountValueLabel->setText(boost::lexical_cast<std::string>(TheTriGraphOp->getNumTri()));
}
}
示例13: pushVisibility
// visibility levels
bool RenderPartition::pushVisibility(Node * const pNode)
{
if(getFrustumCulling() == false)
return true;
FrustumVolume::PlaneSet inplanes = _visibilityStack.back();
if(inplanes == FrustumVolume::P_ALL)
{
_visibilityStack.push_back(inplanes);
return true;
}
Color3f col;
bool result = true;
FrustumVolume frustum = _oFrustum;
BoxVolume vol = pNode->getVolume();
// don't mess with infinite volumes
if(vol.isInfinite() == false)
{
pNode->updateVolume();
vol = pNode->getVolume();
#if 1
vol.transform(topMatrix());
#else
// not quite working
Matrix m = topMatrix();
m.invert();
frustum.transform(m);
#endif
}
if(_oDrawEnv.getStatCollector() != NULL)
{
_oDrawEnv.getStatCollector()->getElem(statCullTestedNodes)->inc();
}
if(intersect(frustum, vol, inplanes) == false)
{
result = false;
col.setValuesRGB(1,0,0);
if(_oDrawEnv.getStatCollector() != NULL)
{
_oDrawEnv.getStatCollector()->getElem(statCulledNodes)->inc();
}
}
else
{
if(inplanes == FrustumVolume::P_ALL)
{
col.setValuesRGB(0,1,0);
}
else
{
col.setValuesRGB(0,0,1);
}
}
if(getVolumeDrawing())
{
dropVolume(this, pNode, col);
}
_visibilityStack.push_back(inplanes);
return result;
}
示例14: splitDrawables
void SortLastWindow::splitDrawables(DrawableListT &src,
UInt32 groups,
bool cut)
{
BoxVolume vol;
// Real32 srcLoad=0;
Real32 dst1Load = 0;
Real32 dst2Load = 0;
DrawableListT::iterator dI;
UInt32 dIFront = 0;
UInt32 dIBack = 0;
UInt32 axis = 0;
Vec3f size;
DrawableListT dst1;
DrawableListT dst2;
UInt32 groups1 = 0;
UInt32 groups2 = 0;
// no group
if(groups == 0)
return;
// only one group
if(groups == 1)
{
editMFGroupLengths()->push_back(UInt32(src.size()));
for(dI = src.begin() ; dI != src.end() ; ++dI)
{
pushToGroupNodes(dI->node);
// srcLoad+=dI->load;
}
// printf("load:%f\n",srcLoad);
return;
}
groups1 = groups / 2;
groups2 = groups - groups1;
// collect all load and get summed volume
for(dI = src.begin() ; dI != src.end() ; ++dI)
{
vol.extendBy(dI->bMin);
vol.extendBy(dI->bMax);
}
// get longes axis
vol.getSize(size);
if(size[0] > size[1])
{
if(size[0] > size[2])
axis=0;
else
axis=2;
}
else
{
if(size[1] > size[2])
axis=1;
else
axis=2;
}
// sort by volume
if(axis == 0)
{
std::sort(src.begin(),src.end(), DrawableInfo::MaxXOrder());
}
else
{
if(axis == 1)
std::sort(src.begin(),src.end(), DrawableInfo::MaxYOrder());
else
std::sort(src.begin(),src.end(), DrawableInfo::MaxZOrder());
}
// split group
if(src.size())
{
dIFront = 0;
dIBack = UInt32(src.size()) - 1;
do
{
// printf("f %d b %d\n",dIFront,dIBack);
if(dst2Load < dst1Load)
{
dst2.push_back(src[dIBack]);
dst2Load += src[dIBack].load*groups/Real32(groups2);
dIBack--;
}
else
{
dst1.push_back(src[dIFront]);
dst1Load += src[dIFront].load*groups/Real32(groups1);
dIFront++;
//.........这里部分代码省略.........
示例15: Matrix
ActionBase::ResultE CubeMapGenerator::renderEnter(Action *action)
{
static Matrix transforms[] =
{
Matrix( 1, 0, 0, 0,
0, -1, 0, 0,
0, 0, -1, 0,
0, 0, 0, 1),
Matrix(-1, 0, 0, 0,
0, -1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1),
Matrix( 1, 0, 0, 0,
0, 0, -1, 0,
0, 1, 0, 0,
0, 0, 0, 1),
Matrix( 1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 0,
0, 0, 0, 1),
Matrix( 0, 0, -1, 0,
0, -1, 0, 0,
-1, 0, 0, 0,
0, 0, 0, 1),
Matrix( 0, 0, 1, 0,
0, -1, 0, 0,
1, 0, 0, 0,
0, 0, 0, 1)
};
RenderAction *a = dynamic_cast<RenderAction *>(action);
Action::ResultE returnValue = Action::Continue;
Background *pBack = a->getBackground();
Viewport *pPort = a->getViewport();
Node *pActNode = a->getActNode();
CubeMapGeneratorStageData *pData =
a->getData<CubeMapGeneratorStageData *>(_iDataSlotId);
if(pData == NULL)
{
pData = this->initData(a);
}
TraversalValidator::ValidationStatus eStatus = this->validateOnEnter(a);
if(eStatus == TraversalValidator::Run)
{
this->beginPartitionGroup(a);
{
FrameBufferObject *pTarget = this->getRenderTarget();
if(pTarget == NULL)
{
pTarget = pData->getRenderTarget();
}
Pnt3f oOrigin;
if(this->getOriginMode() == CubeMapGenerator::UseStoredValue)
{
oOrigin = this->getOrigin();
}
else if(this->getOriginMode() == CubeMapGenerator::UseBeacon)
{
fprintf(stderr, "CubemapGen::UseBeacon NYI\n");
}
else if(this->getOriginMode() ==
CubeMapGenerator::UseCurrentVolumeCenter)
{
BoxVolume oWorldVol;
commitChanges();
pActNode->updateVolume();
pActNode->getWorldVolume(oWorldVol);
oWorldVol.getCenter(oOrigin);
}
else if(this->getOriginMode() ==
CubeMapGenerator::UseParentsVolumeCenter)
{
fprintf(stderr, "CubemapGen::UseParentsCenter NYI\n");
}
Camera *pCam = pData->getCamera();
pActNode->setTravMask(0);
for(UInt32 i = 0; i < 6; ++i)
//.........这里部分代码省略.........