1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

add example darkroom/two_spheres.hpp

This commit is contained in:
bolero-MURAKAMI 2013-09-20 02:40:19 +09:00
parent 67c643820e
commit 3713351e3e
4 changed files with 103 additions and 4 deletions

View file

@ -0,0 +1,94 @@
/*=============================================================================
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)
=============================================================================*/
#ifndef EXAMPLE_DARKROOM_TWO_SPHERES_HPP
#define EXAMPLE_DARKROOM_TWO_SPHERES_HPP
#include <sprout/darkroom.hpp>
#include <sprout/math/constants.hpp>
namespace darkcult {
using namespace sprout::darkroom;
//
// object
//
SPROUT_STATIC_CONSTEXPR auto object = sprout::make_tuple(
objects::make_aa_plane(
sprout::darkroom::objects::aa_plane_direction::y,
-2.0,
materials::make_plaid_material_image(
colors::rgb_f(1.0, 0.0, 0.0),
colors::rgb_f(1.0, 1.0, 0.0),
0.0,
0.0
)
),
objects::make_sphere(
coords::vector3d(-1.0, 0.5, 7.5),
2.5,
materials::make_uniform_material_image(
colors::rgb_f(0.0, 0.0, 1.0),
0.2
)
),
objects::make_sphere(
coords::vector3d(1.0, -1.0, 4.0),
1.0,
materials::make_uniform_material_image(
colors::rgb_f(0.0, 1.0, 0.0),
0.2
)
)
);
//
// light
//
SPROUT_STATIC_CONSTEXPR auto light = lights::make_light_list(
lights::make_point_light(
coords::vector3d(-3.0, 5.0, 0.0),
colors::rgb_f(7.0, 7.0, 7.0)
),
lights::make_parallel_light(
coords::vector3d(0.0, 1.0, 0.0),
colors::rgb_f(0.1, 0.1, 0.1)
),
lights::make_parallel_light(
coords::vector3d(1.0, 0.5, 0.0),
colors::rgb_f(0.1, 0.1, 0.1)
),
lights::make_parallel_light(
coords::vector3d(-1.0, 0.5, 0.0),
colors::rgb_f(0.1, 0.1, 0.1)
),
lights::make_parallel_light(
coords::vector3d(0.0, 0.5, 1.0),
colors::rgb_f(0.1, 0.1, 0.1)
),
lights::make_parallel_light(
coords::vector3d(0.0, 0.5, -1.0),
colors::rgb_f(0.1, 0.1, 0.1)
)
);
//
// camera
//
SPROUT_STATIC_CONSTEXPR auto camera = cameras::make_simple_camera(
sprout::math::root_three<double>() / 2
);
//
// renderer
//
SPROUT_STATIC_CONSTEXPR auto renderer = renderers::make_whitted_style(
renderers::make_uniform_color(colors::rgb_f(0.0, 0.0, 0.0))
);
//
// raytracer
//
SPROUT_STATIC_CONSTEXPR auto raytracer = tracers::make_raytracer();
} // namespace darkcult
#endif // #ifndef EXAMPLE_DARKROOM_TWO_SPHERES_HPP

View file

@ -120,6 +120,7 @@ namespace sprout {
} }
// //
// root_two // root_two
// root_three
// half_root_two // half_root_two
// //
template<typename T> template<typename T>
@ -127,6 +128,10 @@ namespace sprout {
return 1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623L; return 1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623L;
} }
template<typename T> template<typename T>
inline SPROUT_CONSTEXPR T root_three() {
return 1.73205080756887729352744634150587236694280525381038062805580697945193301690880003708114618675724857567562614142L;
}
template<typename T>
inline SPROUT_CONSTEXPR T half_root_two() { inline SPROUT_CONSTEXPR T half_root_two() {
return 0.707106781186547524400844362104849039284835937688474036588339868995366239231053519425193767163820786367506923115L; return 0.707106781186547524400844362104849039284835937688474036588339868995366239231053519425193767163820786367506923115L;
} }

View file

@ -9,7 +9,7 @@
// DARKROOM_SOURCE // DARKROOM_SOURCE
// //
#ifndef DARKROOM_SOURCE #ifndef DARKROOM_SOURCE
# error DARKROOM_SOURCE not defined. for example: "scene.hpp" # error DARKROOM_SOURCE not defined. for example: "../../example/darkroom/two_spheres.hpp"
#else #else
# include DARKROOM_SOURCE # include DARKROOM_SOURCE
#endif #endif

View file

@ -9,7 +9,7 @@
# #
# requires: ImageMagick (http://www.imagemagick.org/script/index.php) # requires: ImageMagick (http://www.imagemagick.org/script/index.php)
# #
src="" src="../../example/darkroom/two_spheres.hpp"
stagedir="darkroom" stagedir="darkroom"
width=16 width=16
height=16 height=16
@ -46,7 +46,7 @@ echo ": tile-width = ${tile_width}"
echo ": tile-height = ${tile_height}" echo ": tile-height = ${tile_height}"
echo ": force = ${force}" echo ": force = ${force}"
if [ ! -f "${src}" ]; then if [ ! -f "${src}" -a ! -f "$(cd $(dirname $0); pwd)/${src}" ]; then
echo >&2 -e ": \e[31msource(${src}) is not exist.\e[m" echo >&2 -e ": \e[31msource(${src}) is not exist.\e[m"
exit 1 exit 1
fi fi
@ -96,4 +96,4 @@ popd
let elapsed=$SECONDS-$start let elapsed=$SECONDS-$start
echo ": elapsed = ${elapsed}s" echo ": elapsed = ${elapsed}s"
echo ": finished" echo ": finished."