本文整理汇总了C++中BoundingBox::GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::GetCenter方法的具体用法?C++ BoundingBox::GetCenter怎么用?C++ BoundingBox::GetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox::GetCenter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetCameraFocus
void ModelBrowserTool::SetCameraFocus()
{
BoundingBox boundingBox = mModel->GetBoundingBox();
Vector3f boxCenter = boundingBox.GetCenter();
// Cubify the bounding box.
BoundingBox boundingCube = boundingBox;
Float maxValue = Maths::Max(boundingCube.Max().x, Maths::Max(boundingCube.Max().y, boundingCube.Max().z));
Float minValue = Maths::Min(boundingCube.Min().x, Maths::Min(boundingCube.Min().y, boundingCube.Min().z));
boundingCube.SetMax( Vector3f(maxValue, maxValue, maxValue) );
boundingCube.SetMin( Vector3f(minValue, minValue, minValue) );
// Recenter
Vector3f cubeCenter = boundingCube.GetCenter();
Vector3f offset = cubeCenter - boxCenter;
cubeCenter -= offset;
boundingCube(0) -= offset;
boundingCube(1) -= offset;
Float fovAngle = Maths::ToRadians(mCamera.GetFovAngle());
Float halfFov = fovAngle / 2.0f;
Float sin = Maths::Sin(halfFov);
Float cos = Maths::Cos(halfFov);
// Compute the camera position and viewing position.
Float halfPos = cubeCenter.y - boundingCube.Min().y;
Float zPos = boundingBox.Max().z + (cos * halfPos / sin);
mCamera.SetPosition(Vector3f(boxCenter.x, boxCenter.y, zPos));
mObjectCenter = Vector3f(boxCenter.x, boxCenter.y, boxCenter.z);
}
示例2: SetRayCastObjectBoundingBox
void ObjectController::SetRayCastObjectBoundingBox( const BoundingBox& bound )
{
if(m_pRayCastBox!=NULL){
Float3 vPos = bound.GetCenter();
Float3 vScale = bound.GetHalfSize();
m_pRayCastBox->m_WorldMatrix = Float44(vPos,vScale,Float4(0,0,0,1));
}
}