本文整理汇总了C++中Bounds::GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ Bounds::GetCenter方法的具体用法?C++ Bounds::GetCenter怎么用?C++ Bounds::GetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bounds
的用法示例。
在下文中一共展示了Bounds::GetCenter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RayBounds
bool Intersect::RayBounds (const Vector3f& origin, const Vector3f& dir, const Bounds& bounds)
{
const Vector3f& max = bounds.GetMax();
const Vector3f& center = bounds.GetCenter();
Vector3f ext (max - center);
Vector3f diff (origin - center);
if (Float::Abs(diff.x) > ext.x && Float::IsProductPositive(diff.x, dir.x)) return false;
if (Float::Abs(diff.y) > ext.y && Float::IsProductPositive(diff.y, dir.y)) return false;
if (Float::Abs(diff.z) > ext.z && Float::IsProductPositive(diff.z, dir.z)) return false;
Vector3f adir (Float::Abs(dir.x), Float::Abs(dir.y), Float::Abs(dir.z));
float a = dir.y * diff.z - dir.z * diff.y;
float b = ext.y * adir.z + ext.z * adir.y;
if (Float::Abs(a) > b) return false;
a = dir.z * diff.x - dir.x * diff.z;
b = ext.x * adir.z + ext.z * adir.x;
if (Float::Abs(a) > b) return false;
a = dir.x * diff.y - dir.y * diff.x;
b = ext.x * adir.y + ext.y * adir.x;
return !(Float::Abs(a) > b);
}
示例2: GetQChildBounds
void GetQChildBounds(const Bounds &bounds, int childnum, Bounds &child)
{
Vect center = bounds.GetCenter();
child.Max.y = bounds.Max.y;
child.Min.y = bounds.Min.y;
if(childnum > 1) {child.Min.z = center.z; child.Max.z = bounds.Max.z; childnum -= 2;}
else {child.Min.z = bounds.Min.z; child.Max.z = center.z;}
if(childnum == 1) {child.Min.x = center.x; child.Max.x = bounds.Max.x;}
else {child.Min.x = bounds.Min.x; child.Max.x = center.x;}
}
示例3: BoundsSphere
bool Intersect::BoundsSphere (const Bounds& bounds, const Vector3f& pos, float radius)
{
const Vector3f& center = bounds.GetCenter();
Vector3f dir (center - pos);
float mag = dir.Magnitude();
if (mag > radius)
{
dir /= mag;
dir *= radius;
return bounds.Contains(pos + dir);
}
return true;
}