Cornell Box 3D Model

generate_cornell_mesh(
  leftcolor = "#1f7326",
  rightcolor = "#a60d0d",
  roomcolor = "#bababa",
  ceiling = TRUE,
  light = TRUE
)

Arguments

leftcolor

Default `#1f7326` (green).

rightcolor

Default `#a60d0d` (red).

roomcolor

Default `#bababa` (light grey).

ceiling

Default `TRUE`. Whether to render the ceiling.

light

Default `TRUE`. Whether to render a point light near the ceiling.

Value

List describing the mesh.

Examples

# \dontshow{
options("cores"=1)
# }
#Generate and render the default Cornell box and add an object.
# \donttest{
generate_cornell_mesh() %>% 
  rasterize_scene()
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’
# }
#Add an object to the scene
# \donttest{
generate_cornell_mesh() %>% 
  add_shape(obj_mesh(r_obj(),position=c(555/2,0,555/2),scale=150,angle=c(0,180,0))) %>% 
  rasterize_scene()
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’
# }
#Turn off the ceiling so the default directional light reaches inside the box
# \donttest{
generate_cornell_mesh(ceiling=FALSE) %>% 
  add_shape(obj_mesh(r_obj(),position=c(555/2,0,555/2),scale=150,angle=c(0,180,0))) %>% 
  rasterize_scene()
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’
# }
#Adjust the light to the front
# \donttest{
generate_cornell_mesh(ceiling=FALSE) %>% 
  add_shape(obj_mesh(r_obj(),position=c(555/2,0,555/2),scale=150,angle=c(0,180,0))) %>% 
  rasterize_scene(light_info = directional_light(direction=c(0,1,-1)))
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’
# }
#Change the color palette
# \donttest{
generate_cornell_mesh(ceiling=FALSE,leftcolor="purple", rightcolor="yellow") %>% 
  add_shape(obj_mesh(r_obj(),position=c(555/2,0,555/2),scale=150,angle=c(0,180,0))) %>% 
  rasterize_scene(light_info = directional_light(direction=c(0,1,-1)))
#> Setting default values for Cornell box: lookfrom `c(278,278,-800)` lookat `c(278,278,0)` fov `40` .
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘terra’
# }