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


C++ Graphic::CastsShadow方法代码示例

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


在下文中一共展示了Graphic::CastsShadow方法的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;
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:76,代码来源:Scene.cpp


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