本文整理汇总了C++中Drawable::GetRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ Drawable::GetRadius方法的具体用法?C++ Drawable::GetRadius怎么用?C++ Drawable::GetRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drawable
的用法示例。
在下文中一共展示了Drawable::GetRadius方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cull
static bool Cull(const Frustum & f, const Drawable & d)
{
const float radius = d.GetRadius();
Vec3 center = d.GetObjectCenter();
d.GetTransform().TransformVectorOut(center[0], center[1], center[2]);
for (int i = 0; i < 6; i++)
{
const float rd =
f.frustum[i][0] * center[0] +
f.frustum[i][1] * center[1] +
f.frustum[i][2] * center[2] +
f.frustum[i][3];
if (rd <= -radius)
return true;
}
return false;
}
示例2: FrustumCull
bool RenderInputScene::FrustumCull(const Drawable & d) const
{
const float radius = d.GetRadius();
if (radius > 0.0)
{
// get object center in world space
Vec3 objpos = d.GetObjectCenter();
d.GetTransform().TransformVectorOut(objpos[0], objpos[1], objpos[2]);
// get distance to camera
const float dx = objpos[0] - cam_position[0];
const float dy = objpos[1] - cam_position[1];
const float dz = objpos[2] - cam_position[2];
const float rc = dx * dx + dy * dy + dz * dz;
// test against camera position (assuming near plane is zero)
if (rc < radius * radius)
return false;
// test against camera far plane
const float temp_lod_far = lod_far + radius;
if (rc > temp_lod_far * temp_lod_far)
return true;
// test against all frustum planes
for (int i = 0; i < 6; i++)
{
const float rd = frustum.frustum[i][0] * objpos[0] +
frustum.frustum[i][1] * objpos[1] +
frustum.frustum[i][2] * objpos[2] +
frustum.frustum[i][3];
if (rd <= -radius)
return true;
}
}
return false;
}