本文整理汇总了C++中Graphic::CheckRayIntersection方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphic::CheckRayIntersection方法的具体用法?C++ Graphic::CheckRayIntersection怎么用?C++ Graphic::CheckRayIntersection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphic
的用法示例。
在下文中一共展示了Graphic::CheckRayIntersection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
Scene::IsLightObscured(const Point& obj_pos, const Point& light_pos, double obj_radius, Point* impact_point) const
{
Point dir = light_pos - obj_pos;
double len = dir.Normalize();
Scene* pThis = (Scene*) this; // cast-away const
Graphic* g = 0;
bool obscured = false;
ListIter<Graphic> g_iter = pThis->graphics;
while (++g_iter && !obscured) {
g = g_iter.value();
if (g->CastsShadow() && !g->Hidden() && !g->IsInfinite()) {
double gdist = (g->Location() - obj_pos).length();
if (gdist > 0.1 && // different than object being obscured
g->Radius() > obj_radius && // larger than object being obscured
(g->Radius()*400)/gdist > 10) { // projects to a resonable size
Point delta = (g->Location() - light_pos);
if (delta.length() > g->Radius() / 100) { // not the object that is emitting the light
Point impact;
obscured = g->CheckRayIntersection(obj_pos, dir, len, impact, false) ? true : false;
if (impact_point)
*impact_point = impact;
}
}
else if (obj_radius < 0 && gdist < 0.1) { // special case for camera (needed for cockpits)
Point delta = (g->Location() - light_pos);
if (delta.length() > g->Radius() / 100) { // not the object that is emitting the light
Point impact;
obscured = g->CheckRayIntersection(obj_pos, dir, len, impact, false) ? true : false;
}
}
}
}
g_iter.attach(pThis->foreground);
while (++g_iter && !obscured) {
g = g_iter.value();
if (g->CastsShadow() && !g->Hidden()) {
double gdist = (g->Location() - obj_pos).length();
if (gdist > 0.1 && // different than object being obscured
g->Radius() > obj_radius && // larger than object being obscured
(g->Radius()*400)/gdist > 10) { // projects to a resonable size
Point delta = (g->Location() - light_pos);
if (delta.length() > g->Radius() / 100) { // not the object that is emitting the light
Point impact;
obscured = g->CheckRayIntersection(obj_pos, dir, len, impact, false) ? true : false;
if (impact_point)
*impact_point = impact;
}
}
else if (obj_radius < 0 && gdist < 0.1) { // special case for camera (needed for cockpits)
Point delta = (g->Location() - light_pos);
if (delta.length() > g->Radius() / 100) { // not the object that is emitting the light
Point impact;
obscured = g->CheckRayIntersection(obj_pos, dir, len, impact, false) ? true : false;
}
}
}
}
return obscured;
}