Skip to content

Commit 3afe80e

Browse files
committed
Pull scenes 7 & 9 from book 2
These were `cornell_balls` and `cornell_final`, two scenes not referenced in the book. Resolves #653 Resolves #620
1 parent 82796b2 commit 3afe80e

File tree

2 files changed

+21
-78
lines changed

2 files changed

+21
-78
lines changed

books/RayTracingTheNextWeek.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,7 +2969,7 @@
29692969

29702970
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
29712971
shared_ptr<hittable> box1 = make_shared<box>(point3(0, 0, 0), point3(165, 330, 165), white);
2972-
box1 = make_shared<rotate_y>(box1, 15);
2972+
box1 = make_shared<rotate_y>(box1, 15);
29732973
box1 = make_shared<translate>(box1, vec3(265,0,295));
29742974
objects.add(box1);
29752975

@@ -3180,7 +3180,7 @@
31803180
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
31813181

31823182
shared_ptr<hittable> box1 = make_shared<box>(point3(0,0,0), point3(165,330,165), white);
3183-
box1 = make_shared<rotate_y>(box1, 15);
3183+
box1 = make_shared<rotate_y>(box1, 15);
31843184
box1 = make_shared<translate>(box1, vec3(265,0,295));
31853185

31863186
shared_ptr<hittable> box2 = make_shared<box>(point3(0,0,0), point3(165,165,165), white);
@@ -3192,6 +3192,22 @@
31923192

31933193
return objects;
31943194
}
3195+
3196+
...
3197+
3198+
int main() {
3199+
...
3200+
switch (0) {
3201+
...
3202+
default:
3203+
case 7:
3204+
world = cornell_smoke();
3205+
lookfrom = point3(278, 278, -800);
3206+
lookat = point3(278, 278, 0);
3207+
vfov = 40.0;
3208+
break;
3209+
...
3210+
}
31953211
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31963212
[Listing [cornell-smoke]: <kbd>[main.cc]</kbd> Cornell box, with smoke]
31973213
</div>

src/TheNextWeek/main.cc

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ hittable_list cornell_box() {
160160
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
161161

162162
shared_ptr<hittable> box1 = make_shared<box>(point3(0,0,0), point3(165,330,165), white);
163-
box1 = make_shared<rotate_y>(box1, 15);
163+
box1 = make_shared<rotate_y>(box1, 15);
164164
box1 = make_shared<translate>(box1, vec3(265,0,295));
165165
objects.add(box1);
166166

@@ -173,34 +173,6 @@ hittable_list cornell_box() {
173173
}
174174

175175

176-
hittable_list cornell_balls() {
177-
hittable_list objects;
178-
179-
auto red = make_shared<lambertian>(color(.65, .05, .05));
180-
auto white = make_shared<lambertian>(color(.73, .73, .73));
181-
auto green = make_shared<lambertian>(color(.12, .45, .15));
182-
auto light = make_shared<diffuse_light>(color(5, 5, 5));
183-
184-
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
185-
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
186-
objects.add(make_shared<xz_rect>(113, 443, 127, 432, 554, light));
187-
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
188-
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
189-
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
190-
191-
auto boundary = make_shared<sphere>(point3(160,100,145), 100, make_shared<dielectric>(1.5));
192-
objects.add(boundary);
193-
objects.add(make_shared<constant_medium>(boundary, 0.1, color(1,1,1)));
194-
195-
shared_ptr<hittable> box1 = make_shared<box>(point3(0,0,0), point3(165,330,165), white);
196-
box1 = make_shared<rotate_y>(box1, 15);
197-
box1 = make_shared<translate>(box1, vec3(265,0,295));
198-
objects.add(box1);
199-
200-
return objects;
201-
}
202-
203-
204176
hittable_list cornell_smoke() {
205177
hittable_list objects;
206178

@@ -217,7 +189,7 @@ hittable_list cornell_smoke() {
217189
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
218190

219191
shared_ptr<hittable> box1 = make_shared<box>(point3(0,0,0), point3(165,330,165), white);
220-
box1 = make_shared<rotate_y>(box1, 15);
192+
box1 = make_shared<rotate_y>(box1, 15);
221193
box1 = make_shared<translate>(box1, vec3(265,0,295));
222194

223195
shared_ptr<hittable> box2 = make_shared<box>(point3(0,0,0), point3(165,165,165), white);
@@ -231,37 +203,6 @@ hittable_list cornell_smoke() {
231203
}
232204

233205

234-
hittable_list cornell_final() {
235-
hittable_list objects;
236-
237-
auto pertext = make_shared<noise_texture>(0.1);
238-
239-
auto mat = make_shared<lambertian>(make_shared<image_texture>("earthmap.jpg"));
240-
241-
auto red = make_shared<lambertian>(color(.65, .05, .05));
242-
auto white = make_shared<lambertian>(color(.73, .73, .73));
243-
auto green = make_shared<lambertian>(color(.12, .45, .15));
244-
auto light = make_shared<diffuse_light>(color(7, 7, 7));
245-
246-
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
247-
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
248-
objects.add(make_shared<xz_rect>(123, 423, 147, 412, 554, light));
249-
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
250-
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
251-
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
252-
253-
shared_ptr<hittable> boundary2 =
254-
make_shared<box>(point3(0,0,0), point3(165,165,165), make_shared<dielectric>(1.5));
255-
boundary2 = make_shared<rotate_y>(boundary2, -18);
256-
boundary2 = make_shared<translate>(boundary2, vec3(130,0,65));
257-
258-
objects.add(boundary2);
259-
objects.add(make_shared<constant_medium>(boundary2, 0.2, color(0.9, 0.9, 0.9)));
260-
261-
return objects;
262-
}
263-
264-
265206
hittable_list final_scene() {
266207
hittable_list boxes1;
267208
auto ground = make_shared<lambertian>(color(0.48, 0.83, 0.53));
@@ -397,27 +338,13 @@ int main() {
397338
break;
398339

399340
case 7:
400-
world = cornell_balls();
401-
lookfrom = point3(278, 278, -800);
402-
lookat = point3(278, 278, 0);
403-
vfov = 40.0;
404-
break;
405-
406-
case 8:
407341
world = cornell_smoke();
408342
lookfrom = point3(278, 278, -800);
409343
lookat = point3(278, 278, 0);
410344
vfov = 40.0;
411345
break;
412346

413-
case 9:
414-
world = cornell_final();
415-
lookfrom = point3(278, 278, -800);
416-
lookat = point3(278, 278, 0);
417-
vfov = 40.0;
418-
break;
419-
420-
case 10:
347+
case 8:
421348
world = final_scene();
422349
lookfrom = point3(478, 278, -600);
423350
lookat = point3(278, 278, 0);

0 commit comments

Comments
 (0)