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


C++ LightSource::get_color方法代码示例

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


在下文中一共展示了LightSource::get_color方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render_direct

//Outputs the color of the object as enlightened by at the point where `ray` hits it.
rt::color Object::render_direct(const Ray & ray, Scene & scene, const LightSource & light_source) {
    rt::color basic = compose(light_source.get_color(), color);
    Impact imp = get_impact(ray);
    Ray to_light(imp.point, light_source.get_origin());
    double scalar = -(ray.get_direction() | imp.normale);
    if (((light_source.get_origin()-imp.point) | imp.normale) <= 0) {
        return rt::color::BLACK;
    }
    std::list<Object *> others;
    Object* interceptor = scene.get_interceptor(to_light, &others);
    // In case there has been mixups due to rounding errors and the object catches
    // its own ray back to the light when it shouldn't (which is NOT always the case)
    // detect it
    if (interceptor) {
        if (interceptor != this && interceptor->intersects(ray) < (imp.point - light_source.get_origin()).norm())
            return rt::color::BLACK;
        if (intersects(to_light) >= OWNRAY_EPSILON)
            return rt::color::BLACK;
        if (others.size() > 1)
            return rt::color::BLACK;
    }
    return rt::color(
            static_cast<unsigned char>(scalar*basic.get_red()),
            static_cast<unsigned char>(scalar*basic.get_green()),
            static_cast<unsigned char>(scalar*basic.get_blue())
        );
}
开发者ID:laarmen,项目名称:ray_tracer,代码行数:28,代码来源:object.cpp


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