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


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

本文整理汇总了C++中Bound::GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ Bound::GetCenter方法的具体用法?C++ Bound::GetCenter怎么用?C++ Bound::GetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bound的用法示例。


在下文中一共展示了Bound::GetCenter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Merge

VOID Bound::Merge( const Bound& Other )
{
    Sphere OtherSphere;
    OtherSphere.Center = Other.GetCenter();
    OtherSphere.Radius = Other.GetMaxRadius();

    if( m_Type == Bound::No_Bound )
    {
        SetSphere( OtherSphere );
        return;
    }

    Sphere ThisSphere;
    if( m_Type != Bound::Sphere_Bound )
    {
        // convert this bound into a sphere
        ThisSphere.Center = GetCenter();
        ThisSphere.Radius = GetMaxRadius();
    }
    else
    {
        ThisSphere = GetSphere();
    }

    XMVECTOR vThisCenter = XMLoadFloat3( &ThisSphere.Center );
    XMVECTOR vOtherCenter = XMLoadFloat3( &OtherSphere.Center );
    XMVECTOR vThisToOther = XMVectorSubtract( vOtherCenter, vThisCenter );
    XMVECTOR vDistance = XMVector3LengthEst( vThisToOther );

    FLOAT fCombinedDiameter = XMVectorGetX( vDistance ) + ThisSphere.Radius + OtherSphere.Radius;
    if( fCombinedDiameter <= ( ThisSphere.Radius * 2 ) )
    {
        SetSphere( ThisSphere );
        return;
    }
    if( fCombinedDiameter <= ( OtherSphere.Radius * 2 ) )
    {
        SetSphere( OtherSphere );
        return;
    }

    XMVECTOR vDirectionNorm = XMVector3Normalize( vThisToOther );

    XMVECTOR vRadius = XMVectorSet( ThisSphere.Radius, OtherSphere.Radius, 0, 0 );
    XMVECTOR vThisRadius = XMVectorSplatX( vRadius );
    XMVECTOR vOtherRadius = XMVectorSplatY( vRadius );
    XMVECTOR vCombinedDiameter = vThisRadius + vDistance + vOtherRadius;
    XMVECTOR vMaxDiameter = XMVectorMax( vCombinedDiameter, vThisRadius * 2 );
    vMaxDiameter = XMVectorMax( vMaxDiameter, vOtherRadius * 2 );
    XMVECTOR vMaxRadius = vMaxDiameter * 0.5f;
    ThisSphere.Radius = XMVectorGetX( vMaxRadius );
    vMaxRadius -= vThisRadius;
    XMVECTOR vCombinedCenter = vThisCenter + vMaxRadius * vDirectionNorm;
    XMStoreFloat3( &ThisSphere.Center, vCombinedCenter );
    SetSphere( ThisSphere );
}
开发者ID:CodeAsm,项目名称:ffplay360,代码行数:56,代码来源:AtgBound.cpp

示例2: GrowToContain

//----------------------------------------------------------------------------
void Bound::GrowToContain (const Bound& bound)
{
	if (bound.GetRadius() == 0.0f)
	{
		// The node is a dummy node and cannot affect growth.
		return;
	}

	if (GetRadius() == 0.0f)
	{
		mCenter = bound.GetCenter();
		mRadius = bound.GetRadius();
		
		return;
	}

	AVector centerDiff = bound.mCenter - mCenter;
	float lengthSqr = centerDiff.SquaredLength();
	float radiusDiff = bound.mRadius - mRadius;
	float radiusDiffSqr = radiusDiff*radiusDiff;

	if (radiusDiffSqr >= lengthSqr)
	{
		if (radiusDiff >= 0.0f)
		{
			mCenter = bound.mCenter;
			mRadius = bound.mRadius;
		}
		return;
	}

	float length = Mathf::Sqrt(lengthSqr);
	if (length > Mathf::ZERO_TOLERANCE)
	{
		float coeff = (length + radiusDiff)/(2.0f*length);
		mCenter += coeff*centerDiff;
	}

	mRadius = 0.5f*(length + mRadius + bound.mRadius);
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:41,代码来源:PX2Bound.cpp

示例3: WriteAggregate

bool OutStream::WriteAggregate (const Bound& datum)
{
    APoint center = datum.GetCenter();
    float radius = datum.GetRadius();
    return WriteAggregate(center) && Write(radius);
}
开发者ID:rasslingcats,项目名称:calico,代码行数:6,代码来源:Wm5SpecializedIO.cpp

示例4: UpdateCtrl

//----------------------------------------------------------------------------
void BoundCtrl::UpdateCtrl()
{
	mCtrlsGroup->SetActiveChild(1);

	int numObjscts = PX2_SELECTION.GetNumObjects();

	if (numObjscts > 0)
	{
		Bound bound;
		int firstBound = true;

		APoint pos;

		for (int i = 0; i < numObjscts; i++)
		{
			Object *obj = PX2_SELECTION.GetObjectAt(i);
			Actor *actor = DynamicCast<Actor>(obj);
			Movable *movable = DynamicCast<Movable>(obj);

			if (movable)
			{
				mCtrlsGroup->SetActiveChild(0);
				pos += movable->WorldTransform.GetTranslate();

				if (0.0f != movable->WorldBound.GetRadius())
				{
					if (firstBound)
					{
						bound = movable->WorldBound;
						firstBound = false;
					}
					else
					{
						bound.GrowToContain(movable->WorldBound);
					}
				}
			}
		}

		pos = pos / (float)numObjscts;

		float radius = bound.GetRadius();
		if (0.0f == radius)
		{
			radius = 1.0f;

			mCtrlsGroup->WorldTransform.SetUniformScale(radius);
			mCtrlsGroup->WorldTransform.SetTranslate(pos);
		}
		else
		{
			mCtrlsGroup->WorldTransform.SetUniformScale(radius);
			mCtrlsGroup->WorldTransform.SetTranslate(bound.GetCenter());
		}
	}
	else
	{
		mCtrlsGroup->SetActiveChild(1);
	}

	mCtrlsGroup->Update(Time::GetTimeInSeconds(), false);
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:63,代码来源:PX2SceneNodeCtrl.cpp


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