本文整理汇总了C++中BoxVolume::getMin方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxVolume::getMin方法的具体用法?C++ BoxVolume::getMin怎么用?C++ BoxVolume::getMin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxVolume
的用法示例。
在下文中一共展示了BoxVolume::getMin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extend
OSG_BASE_DLLMAPPING
void extend(BoxVolume &srcVol, const CylinderVolume &vol)
{
Pnt3f min, max;
if((!srcVol.isValid () && !srcVol.isEmpty()) ||
srcVol.isInfinite() ||
srcVol.isStatic () )
{
return;
}
if(!vol.isValid())
return;
if(srcVol.isEmpty())
{
if(vol.isEmpty())
{
return;
}
else
{
vol .getBounds(min, max);
srcVol.setBounds(min, max);
return;
}
}
else if(vol.isEmpty())
{
return;
}
vol.getBounds(min, max);
srcVol.setBounds(osgMin(min.x(), srcVol.getMin().x()),
osgMin(min.y(), srcVol.getMin().y()),
osgMin(min.z(), srcVol.getMin().z()),
osgMax(max.x(), srcVol.getMax().x()),
osgMax(max.y(), srcVol.getMax().y()),
osgMax(max.z(), srcVol.getMax().z()));
if(vol.isInfinite())
srcVol.setInfinite(true);
return;
}
示例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: intersect
OSG_BASE_DLLMAPPING
bool intersect(const BoxVolume &box, const SphereVolume &sphere)
{
// source:
// J. Arvo. A simple method for box-sphere intersection testing.
// In A. Glassner, editor, Graphics Gems, pp. 335-339,
// Academic Press, Boston, MA, 1990
bool retCode;
if(box.isEmpty() == true || sphere.isEmpty() == true)
{
retCode = false;
}
else if(box.isInfinite() == true || sphere.isInfinite() == true)
{
retCode = true;
}
else
{
Real32 s;
Real32 d = 0.f;
//find the square of the distance from the sphere to the box
for(Int32 i = 0; i < 3; i++)
{
if(sphere.getCenter()[i] < box.getMin()[i])
{
s = sphere.getCenter()[i] - box.getMin()[i];
d += s * s;
}
else if(sphere.getCenter()[i] > box.getMax()[i])
{
s = sphere.getCenter()[i] - box.getMax()[i];
d += s * s;
}
}
retCode = (d <= (sphere.getRadius() * sphere.getRadius()));
}
return retCode;
}
示例4: 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);
}