2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
|
|
|
Copyright (c) 2011-2013 Bolero MURAKAMI
|
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2011-11-26 06:20:35 +00:00
|
|
|
#ifndef SPROUT_DARKROOM_TRACERS_RAYTRACER_HPP
|
|
|
|
#define SPROUT_DARKROOM_TRACERS_RAYTRACER_HPP
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/darkroom/colors/rgb.hpp>
|
2013-09-24 06:08:36 +00:00
|
|
|
#include <sprout/darkroom/cameras/calculate.hpp>
|
|
|
|
#include <sprout/darkroom/renderers/calculate.hpp>
|
2011-11-26 06:20:35 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace darkroom {
|
|
|
|
namespace tracers {
|
|
|
|
//
|
|
|
|
// raytracer
|
|
|
|
//
|
2013-03-26 17:02:16 +00:00
|
|
|
template<typename Color = sprout::darkroom::colors::rgb_f_t>
|
2011-11-26 06:20:35 +00:00
|
|
|
class raytracer {
|
|
|
|
public:
|
|
|
|
typedef Color color_type;
|
|
|
|
public:
|
2012-10-05 15:58:56 +00:00
|
|
|
template<typename Renderer, typename Camera, typename Objects, typename Lights, typename Unit2D>
|
2011-11-26 06:20:35 +00:00
|
|
|
SPROUT_CONSTEXPR color_type operator()(
|
2012-10-05 15:58:56 +00:00
|
|
|
Renderer const& renderer, Camera const& camera, Objects const& objs, Lights const& lights,
|
|
|
|
Unit2D const& x, Unit2D const& y, Unit2D const& width, Unit2D const& height,
|
2011-11-26 06:20:35 +00:00
|
|
|
std::size_t depth_max = 8
|
|
|
|
) const
|
|
|
|
{
|
2013-09-24 06:08:36 +00:00
|
|
|
return sprout::darkroom::renderers::calculate<color_type>(
|
|
|
|
renderer,
|
2012-10-05 15:58:56 +00:00
|
|
|
camera, objs, lights,
|
2013-09-24 06:08:36 +00:00
|
|
|
sprout::darkroom::cameras::calculate(camera, x, y, width, height),
|
2011-11-26 06:20:35 +00:00
|
|
|
depth_max
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
2012-08-13 14:55:30 +00:00
|
|
|
//
|
|
|
|
// make_raytracer
|
|
|
|
//
|
|
|
|
inline SPROUT_CONSTEXPR sprout::darkroom::tracers::raytracer<>
|
|
|
|
make_raytracer() {
|
|
|
|
return sprout::darkroom::tracers::raytracer<>();
|
|
|
|
}
|
|
|
|
template<typename Color>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::darkroom::tracers::raytracer<Color>
|
|
|
|
make_raytracer() {
|
|
|
|
return sprout::darkroom::tracers::raytracer<Color>();
|
|
|
|
}
|
2011-11-26 06:20:35 +00:00
|
|
|
} // namespace tracers
|
|
|
|
} // namespace darkroom
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DARKROOM_TRACERS_RAYTRACER_HPP
|