-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
65 lines (50 loc) · 1.3 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <Siv3D.hpp> // OpenSiv3D v0.2.4
#include "Scene.hpp"
#include "ImagePlane.hpp"
#include "SceneRenderer.hpp"
#include "Constants.hpp"
#include "Lambertian.hpp"
#include "Metal.hpp"
// Sceneのパラメータ設定
RayT::Scene buildScene()
{
constexpr RayT::Camera camera({ 0, 0, 2 }, { 400, 200 });
constexpr RayT::ImagePlane imagePlane({ 0, 0, 0 }, { 4, 2 });
RayT::Scene scene(camera, imagePlane);
// 左の赤い球
scene.spheres.emplace_back(
Vec3(-1.2, 0, 0), .5,
std::make_shared<RayT::Lambertian>(ColorF(.7, .3, .9))
);
// 中央の黄色い球
scene.spheres.emplace_back(
Vec3(0, 0, 0), .5,
std::make_shared<RayT::Metal>(ColorF(.9, .7, .3), 0)
);
// 右の緑色の球
scene.spheres.emplace_back(
Vec3(1.2, 0, 0), .5,
std::make_shared<RayT::Metal>(ColorF(.3, .9, .7), .3)
);
// 下の大きな球
scene.spheres.emplace_back(
Vec3(0, -100.5, 0), 100,
std::make_shared<RayT::Lambertian>(ColorF(.8, .8, 0))
);
return scene;
}
void Main()
{
Window::Resize(400, 200);
const RayT::Scene scene = buildScene();
// 処理時間の計測
const MillisecClock clock;
const Image image = RayT::SceneRenderer(scene).render(RayT::Constants::Samples);
// 計測結果を出力
clock.print();
const Texture texture(image);
while (System::Update())
{
texture.draw();
}
}