R语言rayrender包,csg_elongate多边体变形球

2021-07-28  本文已影响0人  youmigo
1.png 2.png 3.png 4.png 5.png

R语言rayrender包,csg_elongate变形球体

# Wed Jun 16 00:44:42 2021 -

# 字符编码:UTF-8
# R 版本:R 4.1 x64 for window 10
# cgh163email@163.com
# 个人笔记不负责任,拎了个梨🍐🍈
#.rs.restartR()
require(rayrender)
rm(list = ls());gc()

# csg_elongate变形球体
generate_ground(material=diffuse(checkercolor="grey20",color="dodgerblue4")) %>%
  add_object(csg_object(csg_sphere(z=-3,x=-3),
                        material=glossy(color="purple"))) %>%
  add_object(csg_object(csg_elongate(csg_sphere(z=-3,x=3),x=3,z=-3, elongate = c(0.8,0,0)),
                        material=glossy(color="red"))) %>%
  add_object(csg_object(csg_elongate(csg_sphere(z=2),z=2, elongate = c(0.8,0,0.8)),
                        material=glossy(color="white"))) %>%
  add_object(sphere(y=10,radius=3,material=light(intensity=8))) %>%
  render_scene(clamp_value=10,fov=40,lookfrom=c(0,10,10))

# 遛空球体
generate_ground(material=diffuse(checkercolor="grey20",color="dodgerblue4")) %>%
  add_object(csg_object(csg_torus(z=-3,x=-3),
                        material=glossy(color="purple"))) %>%
  add_object(csg_object(csg_elongate(csg_torus(z=-3,x=3),x=3,z=-3, elongate = c(0.8,0,0)),
                        material=glossy(color="red"))) %>%
  add_object(csg_object(csg_elongate(csg_torus(z=2),z=2, elongate = c(0.8,0,0.8)),
                        material=glossy(color="white"))) %>%
  add_object(sphere(y=10,radius=3,material=light(intensity=8))) %>%
  render_scene(clamp_value=10,fov=40,lookfrom=c(0,10,10))

#凸起球体
generate_ground(material=diffuse(checkercolor="grey20",color="dodgerblue4")) %>%
  add_object(csg_object(csg_cylinder(start=c(-3,0,-3), end = c(-3,1,-3)),
                        material=glossy(color="purple"))) %>%
  add_object(csg_object(csg_elongate(csg_cylinder(start=c(3,0,-3), end = c(3,1,-3)), x=3, z=-3,
                                     elongate = c(0.8,0,0)),
                        material=glossy(color="red"))) %>%
  add_object(csg_object(csg_elongate(csg_cylinder(start=c(0,0,3), end = c(0,1,3)), z=3,
                                     elongate = c(0.8,0,0.8)),
                        material=glossy(color="white"))) %>%
  add_object(sphere(y=10,radius=3,material=light(intensity=8))) %>%
  render_scene(clamp_value=10,fov=40,lookfrom=c(0,10,10))

#多边体
generate_ground(material=diffuse(checkercolor="grey20",color="dodgerblue4")) %>%
  add_object(csg_object(csg_pyramid(z=-3,x=-3),
                        material=glossy(color="purple"))) %>%
  add_object(csg_object(csg_elongate(csg_pyramid(z=-3,x=3),x=3,z=-3, elongate = c(0.8,0,0)),
                        material=glossy(color="red"))) %>%
  add_object(csg_object(csg_elongate(csg_pyramid(z=2),z=2, elongate = c(0.8,0,0.8)),
                        material=glossy(color="white"))) %>%
  add_object(sphere(y=10,radius=3,material=light(intensity=8))) %>%
  render_scene(clamp_value=10,fov=40,lookfrom=c(0,10,10))

#更改伸长点以在棱锥体的一侧开始伸长:
#复杂多边体
generate_ground(material=diffuse(checkercolor="grey20",color="dodgerblue4")) %>%
  add_object(csg_object(csg_pyramid(z=-3,x=-3),
                        material=glossy(color="purple"))) %>%
  add_object(csg_object(csg_elongate(csg_pyramid(z=-3,x=3),x=2.75,z=-2.75, elongate = c(0.8,0,0)),
                        material=glossy(color="red"))) %>%
  add_object(csg_object(csg_elongate(csg_pyramid(z=2),z=2.25, elongate = c(0.8,0,0.8)),
                        material=glossy(color="white"))) %>%
  add_object(sphere(y=10,radius=3,material=light(intensity=8))) %>%
  render_scene(clamp_value=10,fov=40,
               lookfrom=c(5,5,10),lookat=c(0,0,-1.5))
# Wed Jun 16 00:48:34 2021 --
dev.copy(png, "5.png");dev.off()

上一篇下一篇

猜你喜欢

热点阅读