-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.cpp
52 lines (47 loc) · 1.41 KB
/
scene.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
#include "scene.h"
namespace scene
{
/*typedef png::image<png::rgb_pixel> img;
template<class shader>
img * basicScene<shader>::render() const
{
png::image<png::rgb_pixel> * outImage = new png::image<png::rgb_pixel>(window->res.first, window->res.second);
auto rays = this->window->rays();
for(UInt64 x = 0; x < window->res.first; x++)
{
for(UInt64 y = 0; y < window->res.second; y++)
{
rgbColor avg(0,0,0, true);
for (UInt64 r = 0; r < pow(window->subdivisions,2); r++)
{
//first find the intersection point closest to the origin
F64 leastMag = 0;
object * closest = objectList.front;
for (auto obj = objectList.begin(); obj != objectList.end(); obj++)
{
point pos = (*obj)->intersect(rays[x][y][r]);
if(pos.x != INVALID_COORDINATE)
{
F64 mag = vec3d(pos,rays[x][y][r].start).magnitude();
if(mag < leastMag)
{
leastMag = mag;
closest = (*obj);
}
}
}
rgbColor col = shader(lightList, closest, rays[x][y][r]);
if(!r)
avg = col;
avg = rgbColor((col.r() + avg.r())/pow(window->subdivisions,2),
(col.g() + avg.g())/pow(window->subdivisions,2),
(col.b() + avg.b())/pow(window->subdivisions,2), true);
}
avg.changeMode(false);
outImage[x][y] = png::rgb_pixel(avg.r(), avg.b(), avg.g());
}
}
return outImage;
}*/
//always the templates giving me trouble, eh?
}