本文整理汇总了C++中Box3f::getCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ Box3f::getCenter方法的具体用法?C++ Box3f::getCenter怎么用?C++ Box3f::getCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box3f
的用法示例。
在下文中一共展示了Box3f::getCenter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void VUTOctreeNode::init( const Box3f & bbox, unsigned int maxIndicesPerOctel )
{
m_box = bbox;
m_center = bbox.getCenter();
m_data = new VUTOctreeIndices( maxIndicesPerOctel );
m_nodes = NULL;
}
示例2: intersect
bool Line::intersect( const Box3f& box, Vec3f& enter, Vec3f& exit ) const
{
if (box.isEmpty())
{
return false;
}
const Vec3f &pos = getPosition(), &dir = getDirection();
const Vec3f &max = box.getMax(), &min = box.getMin();
Vec3f points[8], inter, bary;
Plane plane;
int i, v0, v1, v2;
bool front = false, valid, validIntersection = false;
//
// First, check the distance from the ray to the center
// of the box. If that distance is greater than 1/2
// the diagonal distance, there is no intersection
// diff is the vector from the closest point on the ray to the center
// dist2 is the square of the distance from the ray to the center
// radi2 is the square of 1/2 the diagonal length of the bounding box
//
float t = (box.getCenter() - pos).dot(dir);
Vec3f diff(pos + dir * t - box.getCenter());
float dist2 = diff.dot(diff);
float radi2 = (max - min).dot(max - min) * 0.25f;
if (dist2 > radi2)
{
return false;
}
// set up the eight coords of the corners of the box
for(i = 0; i < 8; i++)
{
points[i].setValue(i & 01 ? min[0] : max[0],
i & 02 ? min[1] : max[1],
i & 04 ? min[2] : max[2]);
}
// intersect the 12 triangles.
for(i = 0; i < 12; i++)
{
switch(i)
{
case 0: v0 = 2; v1 = 1; v2 = 0; break; // +z
case 1: v0 = 2; v1 = 3; v2 = 1; break;
case 2: v0 = 4; v1 = 5; v2 = 6; break; // -z
case 3: v0 = 6; v1 = 5; v2 = 7; break;
case 4: v0 = 0; v1 = 6; v2 = 2; break; // -x
case 5: v0 = 0; v1 = 4; v2 = 6; break;
case 6: v0 = 1; v1 = 3; v2 = 7; break; // +x
case 7: v0 = 1; v1 = 7; v2 = 5; break;
case 8: v0 = 1; v1 = 4; v2 = 0; break; // -y
case 9: v0 = 1; v1 = 5; v2 = 4; break;
case 10: v0 = 2; v1 = 7; v2 = 3; break; // +y
case 11: v0 = 2; v1 = 6; v2 = 7; break;
default:
assert(false && "Must never happened");
v0 = v1 = v2 = 0; // to remove a warning.
}
valid = intersect( points[v0], points[v1], points[v2],
inter, bary, front);
if ( valid )
{
if (front)
{
enter = inter;
validIntersection = valid;
}
else
{
exit = inter;
validIntersection = valid;
}
}
}
return validIntersection;
}