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>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace darkroom {
|
|
|
|
namespace tracers {
|
|
|
|
//
|
|
|
|
// raytracer
|
|
|
|
//
|
|
|
|
template<typename Color = sprout::darkroom::colors::rgb_f>
|
|
|
|
class raytracer {
|
|
|
|
public:
|
|
|
|
typedef Color color_type;
|
|
|
|
public:
|
|
|
|
template<
|
|
|
|
typename Renderer,
|
|
|
|
typename Camera,
|
|
|
|
typename Objects,
|
|
|
|
typename Lights,
|
2011-12-12 08:23:54 +00:00
|
|
|
typename Unit2D
|
2011-11-26 06:20:35 +00:00
|
|
|
>
|
|
|
|
SPROUT_CONSTEXPR color_type operator()(
|
|
|
|
Renderer const& renderer,
|
|
|
|
Camera const& camera,
|
|
|
|
Objects const& objs,
|
|
|
|
Lights const& lights,
|
2011-12-12 08:23:54 +00:00
|
|
|
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
|
|
|
|
{
|
|
|
|
return renderer.template operator()<color_type>(
|
|
|
|
camera,
|
|
|
|
objs,
|
|
|
|
lights,
|
2011-12-12 08:23:54 +00:00
|
|
|
camera.template operator()(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
|