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_MATERIALS_MATERIAL_HPP
|
|
|
|
#define SPROUT_DARKROOM_MATERIALS_MATERIAL_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/tuple/tuple.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
#include <sprout/darkroom/access/access.hpp>
|
|
|
|
#include <sprout/darkroom/colors/rgb.hpp>
|
2013-09-24 06:08:36 +00:00
|
|
|
#include <sprout/darkroom/materials/calculate.hpp>
|
2011-11-26 06:20:35 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace darkroom {
|
|
|
|
namespace materials {
|
|
|
|
//
|
|
|
|
// color
|
|
|
|
// reflection
|
|
|
|
//
|
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR auto
|
|
|
|
color(T&& t)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
|
|
|
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
|
|
|
}
|
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR auto
|
|
|
|
reflection(T&& t)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
|
|
|
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2013-09-24 06:08:36 +00:00
|
|
|
// calculate_material
|
2011-11-26 06:20:35 +00:00
|
|
|
//
|
2011-12-12 19:01:10 +00:00
|
|
|
template<typename Material, typename Unit>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR auto
|
2013-09-24 06:08:36 +00:00
|
|
|
calculate_material(Material const& mat, Unit const& u, Unit const& v)
|
2012-10-05 15:58:56 +00:00
|
|
|
-> decltype(sprout::tuples::make_tuple(
|
2013-09-24 06:08:36 +00:00
|
|
|
sprout::darkroom::materials::calculate(sprout::darkroom::materials::color(mat), u, v),
|
|
|
|
sprout::darkroom::materials::calculate(sprout::darkroom::materials::reflection(mat), u, v)
|
2012-10-05 15:58:56 +00:00
|
|
|
))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::tuples::make_tuple(
|
2013-09-24 06:08:36 +00:00
|
|
|
sprout::darkroom::materials::calculate(sprout::darkroom::materials::color(mat), u, v),
|
|
|
|
sprout::darkroom::materials::calculate(sprout::darkroom::materials::reflection(mat), u, v)
|
2011-11-26 06:20:35 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// make_material_image
|
|
|
|
//
|
|
|
|
template<typename ColorImage, typename ReflectionImage>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::tuples::tuple<ColorImage, ReflectionImage>
|
2011-11-26 06:20:35 +00:00
|
|
|
make_material_image(ColorImage const& col, ReflectionImage const& ref) {
|
|
|
|
return sprout::tuples::make_tuple(col, ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// material
|
|
|
|
//
|
2013-03-26 17:02:16 +00:00
|
|
|
typedef sprout::tuples::tuple<sprout::darkroom::colors::rgb_f_t, double> material;
|
2011-11-26 06:20:35 +00:00
|
|
|
} // namespace materials
|
|
|
|
} // namespace darkroom
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DARKROOM_MATERIALS_MATERIAL_HPP
|