当前位置: 首页>>代码示例>>C++>>正文


C++ Bounds::GetCenter方法代码示例

本文整理汇总了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);
}
开发者ID:saggita,项目名称:r5ge,代码行数:29,代码来源:Intersect.cpp

示例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;}
}
开发者ID:alanzw,项目名称:JimEngine,代码行数:13,代码来源:OutdoorLevel.cpp

示例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;
}
开发者ID:saggita,项目名称:r5ge,代码行数:14,代码来源:Intersect.cpp


注:本文中的Bounds::GetCenter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。