-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcsg_object.Rd
100 lines (92 loc) · 3.87 KB
/
csg_object.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/csg_construct.R
\name{csg_object}
\alias{csg_object}
\title{Constructive Solid Geometry Object}
\usage{
csg_object(
object,
x = 0,
y = 0,
z = 0,
material = diffuse(),
angle = c(0, 0, 0),
order_rotation = c(1, 2, 3),
flipped = FALSE,
scale = c(1, 1, 1)
)
}
\arguments{
\item{object}{Object created with CSG interface.}
\item{x}{Default `0`. x-offset of the center of the object.}
\item{y}{Default `0`. y-offset of the center of the object.}
\item{z}{Default `0`. z-offset of the center of the object.}
\item{material}{Default \code{\link{diffuse}}. The material, called from one of the material
functions \code{\link{diffuse}}, \code{\link{metal}}, or \code{\link{dielectric}}.}
\item{angle}{Default `c(0, 0, 0)`. Angle of rotation around the x, y, and z axes, applied in the order specified in `order_rotation`.}
\item{order_rotation}{Default `c(1, 2, 3)`. The order to apply the rotations, referring to "x", "y", and "z".}
\item{flipped}{Default `FALSE`. Whether to flip the normals.}
\item{scale}{Default `c(1, 1, 1)`. Scale transformation in the x, y, and z directions. If this is a single value,
number, the object will be scaled uniformly.
Note: emissive objects may not currently function correctly when scaled.}
}
\value{
Single row of a tibble describing the sphere in the scene.
}
\description{
This object takes an object constructed using the `csg_*` functions. The object is drawn using
ray marching/sphere tracing.
}
\details{
Note: For dielectric objects, any other objects not included in the CSG object and
nested inside will be ignored.
}
\examples{
if(run_documentation()) {
#We will combine these three objects:
generate_ground(material=diffuse(checkercolor="grey20")) \%>\%
add_object(csg_object(csg_box(), material=glossy(color="red"))) \%>\%
add_object(csg_object(csg_sphere(radius=0.707), material=glossy(color="green"))) \%>\%
add_object(csg_object(csg_group(list(csg_cylinder(start=c(-1,0,0), end=c(1,0,0), radius=0.4),
csg_cylinder(start=c(0,-1,0), end=c(0,1,0), radius=0.4),
csg_cylinder(start=c(0,0,-1), end=c(0,0,1), radius=0.4))),
material=glossy(color="blue"))) \%>\%
add_object(sphere(y=5,x=3,radius=1,material=light(intensity=30))) \%>\%
render_scene(clamp_value=10, fov=15,lookfrom=c(5,5,10),
samples=16, sample_method="sobol_blue")
}
if(run_documentation()) {
#Standard CSG sphere + box - crossed cylinder combination:
generate_ground(material=diffuse(checkercolor="grey20")) \%>\%
add_object(csg_object(csg_combine(
csg_combine(
csg_box(),
csg_sphere(radius=0.707),
operation="intersection"),
csg_group(list(csg_cylinder(start=c(-1,0,0), end=c(1,0,0), radius=0.4),
csg_cylinder(start=c(0,-1,0), end=c(0,1,0), radius=0.4),
csg_cylinder(start=c(0,0,-1), end=c(0,0,1), radius=0.4))),
operation="subtract"),
material=glossy(color="red"))) \%>\%
add_object(sphere(y=5,x=3,radius=1,material=light(intensity=30))) \%>\%
render_scene(clamp_value=10, fov=10,lookfrom=c(5,5,10),
samples=16, sample_method="sobol_blue")
}
if(run_documentation()) {
#Blend them all instead:
generate_ground(material=diffuse(checkercolor="grey20")) \%>\%
add_object(csg_object(csg_combine(
csg_combine(
csg_box(),
csg_sphere(radius=0.707),
operation="blend"),
csg_group(list(csg_cylinder(start=c(-1,0,0), end=c(1,0,0), radius=0.4),
csg_cylinder(start=c(0,-1,0), end=c(0,1,0), radius=0.4),
csg_cylinder(start=c(0,0,-1), end=c(0,0,1), radius=0.4))),
operation="blend"),
material=glossy(color="purple"))) \%>\%
add_object(sphere(y=5,x=3,radius=1,material=light(intensity=30))) \%>\%
render_scene(clamp_value=10, fov=15,lookfrom=c(5,5,10),
samples=16, sample_method="sobol_blue")
}
}