本文整理汇总了C++中BoundingBox::encapsulate方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::encapsulate方法的具体用法?C++ BoundingBox::encapsulate怎么用?C++ BoundingBox::encapsulate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox::encapsulate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: min
void
Light::_updateBoundingBox() noexcept
{
BoundingBox boundingBox;
if (!_shadowCamera)
{
Vector3 min(-_lightRange, -_lightRange, -_lightRange);
Vector3 max(_lightRange, _lightRange, _lightRange);
BoundingBox bound;
bound.encapsulate(min);
bound.encapsulate(max);
boundingBox.encapsulate(bound);
}
else
{
if (_lightType == LightType::LightTypeAmbient || _lightType == LightType::LightTypeEnvironment)
{
Vector3 min(-_lightRange, -_lightRange, -_lightRange);
Vector3 max(_lightRange, _lightRange, _lightRange);
BoundingBox bound;
bound.encapsulate(min);
bound.encapsulate(max);
boundingBox.encapsulate(bound);
}
else
{
float znear = _shadowCamera->getNear();
float zfar = _lightRange;
float3 corners[8];
corners[0].set(-znear, +znear, znear);
corners[1].set(+znear, +znear, znear);
corners[2].set(-znear, -znear, znear);
corners[3].set(+znear, -znear, znear);
corners[4].set(-zfar, +zfar, zfar);
corners[5].set(+zfar, +zfar, zfar);
corners[6].set(-zfar, -zfar, zfar);
corners[7].set(+zfar, -zfar, zfar);
BoundingBox bound;
bound.encapsulate(corners, 8);
bound.transform((float3x3)_shadowCamera->getTransform());
boundingBox.encapsulate(bound);
if (_lightType == LightType::LightTypeSun || _lightType == LightType::LightTypeDirectional)
{
float w = bound.size().x * 0.5f;
float h = bound.size().y * 0.5f;
_shadowCamera->setOrtho(float4(-w, w, -h, h));
_shadowCamera->setFar(zfar);
_shadowCamera->setCameraType(CameraType::CameraTypeOrtho);
}
else if (_lightType == LightType::LightTypeSpot)
{
_shadowCamera->setAperture(this->getSpotOuterCone().x * 2);
_shadowCamera->setFar(zfar);
_shadowCamera->setCameraType(CameraType::CameraTypePerspective);
}
else if (_lightType == LightType::LightTypePoint)
{
_shadowCamera->setAperture(90.0f);
_shadowCamera->setCameraType(CameraType::CameraTypePerspective);
}
}
}
this->setBoundingBox(boundingBox);
}