Learn R Programming

rayvertex (version 0.12.0)

generate_cornell_mesh: Cornell Box 3D Model

Description

Cornell Box 3D Model

Usage

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

Value

List describing the mesh.

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.

Examples

Run this code
if(run_documentation()) {
#Generate and render the default Cornell box and add an object.
generate_cornell_mesh() |> 
  rasterize_scene()
}
if(run_documentation()) {
#Add an object to the scene
generate_cornell_mesh() |> 
  add_shape(obj_mesh(r_obj(),position=c(555/2,555/2,555/2),scale=300,angle=c(0,180,0))) |> 
  rasterize_scene()
}
if(run_documentation()) {
#Turn off the ceiling so the default directional light reaches inside the box
generate_cornell_mesh(ceiling=FALSE) |> 
  add_shape(obj_mesh(r_obj(),position=c(555/2,555/2,555/2),scale=300,angle=c(0,180,0))) |> 
  rasterize_scene()
}
if(run_documentation()) {
#Adjust the light to the front
generate_cornell_mesh(ceiling=FALSE) |> 
  add_shape(obj_mesh(r_obj(),position=c(555/2,555/2,555/2),scale=300,angle=c(0,180,0))) |> 
  rasterize_scene(light_info = directional_light(direction=c(0,1,-1)))
  }
if(run_documentation()) {
#Change the color palette
generate_cornell_mesh(ceiling=FALSE,leftcolor="purple", rightcolor="yellow") |> 
  add_shape(obj_mesh(r_obj(),position=c(555/2,555/2,555/2),scale=300,angle=c(0,180,0))) |> 
  rasterize_scene(light_info = directional_light(direction=c(0,1,-1)))
}

Run the code above in your browser using DataLab