# NOT RUN {
#Generate a segment in the cornell box.
# }
# NOT RUN {
generate_cornell() %>%
add_object(segment(start = c(100, 100, 100), end = c(455, 455, 455), radius = 50)) %>%
render_scene(lookfrom = c(278, 278, -800) ,lookat = c(278, 278, 0), fov = 40,
ambient_light = FALSE, samples = 400, parallel = TRUE, clamp_value = 5)
# }
# NOT RUN {
# Draw a line graph representing a normal distribution, but with metal:
xvals = seq(-3, 3, length.out = 30)
yvals = dnorm(xvals)
scene_list = list()
for(i in 1:(length(xvals) - 1)) {
scene_list[[i]] = segment(start = c(555/2 + xvals[i] * 80, yvals[i] * 800, 555/2),
end = c(555/2 + xvals[i + 1] * 80, yvals[i + 1] * 800, 555/2),
radius = 10,
material = metal())
}
scene_segments = do.call(rbind,scene_list)
# }
# NOT RUN {
generate_cornell() %>%
add_object(scene_segments) %>%
render_scene(lookfrom = c(278, 278, -800) ,lookat = c(278, 278, 0), fov = 40,
ambient_light = FALSE, samples = 400, parallel = TRUE, clamp_value = 5)
# }
# NOT RUN {
#Draw the outline of a cube:
cube_outline = segment(start = c(100, 100, 100), end = c(100, 100, 455), radius = 10) %>%
add_object(segment(start = c(100, 100, 100), end = c(100, 455, 100), radius = 10)) %>%
add_object(segment(start = c(100, 100, 100), end = c(455, 100, 100), radius = 10)) %>%
add_object(segment(start = c(100, 100, 455), end = c(100, 455, 455), radius = 10)) %>%
add_object(segment(start = c(100, 100, 455), end = c(455, 100, 455), radius = 10)) %>%
add_object(segment(start = c(100, 455, 455), end = c(100, 455, 100), radius = 10)) %>%
add_object(segment(start = c(100, 455, 455), end = c(455, 455, 455), radius = 10)) %>%
add_object(segment(start = c(455, 455, 100), end = c(455, 100, 100), radius = 10)) %>%
add_object(segment(start = c(455, 455, 100), end = c(455, 455, 455), radius = 10)) %>%
add_object(segment(start = c(455, 100, 100), end = c(455, 100, 455), radius = 10)) %>%
add_object(segment(start = c(455, 100, 455), end = c(455, 455, 455), radius = 10)) %>%
add_object(segment(start = c(100, 455, 100), end = c(455, 455, 100), radius = 10))
# }
# NOT RUN {
generate_cornell() %>%
add_object(cube_outline) %>%
render_scene(lookfrom = c(278, 278, -800) ,lookat = c(278, 278, 0), fov = 40,
ambient_light = FALSE, samples = 400, parallel = TRUE, clamp_value = 5)
# }
# NOT RUN {
#Shrink and rotate the cube
# }
# NOT RUN {
generate_cornell() %>%
add_object(group_objects(cube_outline, pivot_point = c(555/2, 555/2, 555/2),
group_angle = c(45,45,45), group_scale = c(0.5,0.5,0.5))) %>%
render_scene(lookfrom = c(278, 278, -800) ,lookat = c(278, 278, 0), fov = 40,
ambient_light = FALSE, samples = 400, parallel = TRUE, clamp_value = 5)
# }
Run the code above in your browser using DataLab