Skip to content

Commit c1a502c

Browse files
Added scale transformation for all objects
1 parent 83fdb92 commit c1a502c

20 files changed

+809
-478
lines changed

R/RcppExports.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
22
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

4-
render_scene_rcpp <- function(nx, ny, ns, fov, ambient_light, lookfromvec, lookatvec, aperture, camera_up, type, radius, shape, x, y, z, properties, velocity, moving, n, bghigh, bglow, shutteropen, shutterclose, ischeckered, checkercolors, noise, isnoise, noisephase, noiseintensity, noisecolorlist, angle, isimage, filelocation, islight, lightintensity, isflipped, focus_distance, isvolume, voldensity, parallel, implicit_sample, order_rotation_list, clampval, isgrouped, group_pivot, group_translate, group_angle, group_order_rotation, tri_normal_bools, is_tri_color, tri_color_vert, fileinfo, toneval, progress_bar, numbercores, debugval, hasbackground, background) {
5-
.Call(`_rayrender_render_scene_rcpp`, nx, ny, ns, fov, ambient_light, lookfromvec, lookatvec, aperture, camera_up, type, radius, shape, x, y, z, properties, velocity, moving, n, bghigh, bglow, shutteropen, shutterclose, ischeckered, checkercolors, noise, isnoise, noisephase, noiseintensity, noisecolorlist, angle, isimage, filelocation, islight, lightintensity, isflipped, focus_distance, isvolume, voldensity, parallel, implicit_sample, order_rotation_list, clampval, isgrouped, group_pivot, group_translate, group_angle, group_order_rotation, tri_normal_bools, is_tri_color, tri_color_vert, fileinfo, toneval, progress_bar, numbercores, debugval, hasbackground, background)
4+
render_scene_rcpp <- function(nx, ny, ns, fov, ambient_light, lookfromvec, lookatvec, aperture, camera_up, type, radius, shape, x, y, z, properties, velocity, moving, n, bghigh, bglow, shutteropen, shutterclose, ischeckered, checkercolors, noise, isnoise, noisephase, noiseintensity, noisecolorlist, angle, isimage, filelocation, islight, lightintensity, isflipped, focus_distance, isvolume, voldensity, parallel, implicit_sample, order_rotation_list, clampval, isgrouped, group_pivot, group_translate, group_angle, group_order_rotation, group_scale, tri_normal_bools, is_tri_color, tri_color_vert, fileinfo, filebasedir, toneval, progress_bar, numbercores, debugval, hasbackground, background, scale_list) {
5+
.Call(`_rayrender_render_scene_rcpp`, nx, ny, ns, fov, ambient_light, lookfromvec, lookatvec, aperture, camera_up, type, radius, shape, x, y, z, properties, velocity, moving, n, bghigh, bglow, shutteropen, shutterclose, ischeckered, checkercolors, noise, isnoise, noisephase, noiseintensity, noisecolorlist, angle, isimage, filelocation, islight, lightintensity, isflipped, focus_distance, isvolume, voldensity, parallel, implicit_sample, order_rotation_list, clampval, isgrouped, group_pivot, group_translate, group_angle, group_order_rotation, group_scale, tri_normal_bools, is_tri_color, tri_color_vert, fileinfo, filebasedir, toneval, progress_bar, numbercores, debugval, hasbackground, background, scale_list)
66
}
77

R/group_objects.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#' applied in the order specified in `order_rotation`.
99
#' @param group_order_rotation Default `c(1,2,3)`. The order to apply the rotations,
1010
#' referring to "x", "y", and "z".
11+
#' @param group_scale Default `c(1,1,1)`. Scaling factor for x, y, and z directions for all objects in group.
1112
#'
1213
#' @return Tibble of grouped object locations and properties.
1314
#' @export
@@ -43,7 +44,8 @@
4344
#' samples=500, fov=50, parallel=TRUE, clamp_value=5)
4445
#' }
4546
group_objects = function(scene, pivot_point=c(0,0,0), group_translate = c(0,0,0),
46-
group_angle = c(0,0,0), group_order_rotation = c(1,2,3)) {
47+
group_angle = c(0,0,0), group_order_rotation = c(1,2,3),
48+
group_scale = c(1,1,1)) {
4749
if(missing(pivot_point)) {
4850
pivot_point = c(mean(scene$x), mean(scene$y), mean(scene$z))
4951
}
@@ -55,5 +57,6 @@ group_objects = function(scene, pivot_point=c(0,0,0), group_translate = c(0,0,0)
5557
scene$group_translate = list(group_translate)
5658
scene$group_angle = list(group_angle)
5759
scene$group_order_rotation = list(group_order_rotation)
60+
scene$group_scale = list(group_scale)
5861
return(scene)
5962
}

R/objects.R

+330-291
Large diffs are not rendered by default.

R/render_scene.R

+9-4
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ render_scene = function(scene, width = 400, height = 400, fov = 20, samples = 10
188188
light_bool = !is.na(scene$lightintensity)
189189
light_prop_vec = scene$lightintensity
190190

191-
if(!any(light_bool) && missing(ambient_light)) {
191+
if(!any(light_bool) && missing(ambient_light) && missing(backgroundimage)) {
192192
ambient_light = TRUE
193193
}
194194

@@ -222,6 +222,7 @@ render_scene = function(scene, width = 400, height = 400, fov = 20, samples = 10
222222
group_angle = scene$group_angle
223223
group_order_rotation = scene$group_order_rotation
224224
group_translate = scene$group_translate
225+
group_scale = scene$group_scale
225226

226227
#triangle normal handler
227228
tri_normal_bools = purrr::map2_lgl(shapevec,proplist,.f = ~.x == 6 && all(!is.na(.y)))
@@ -232,6 +233,7 @@ render_scene = function(scene, width = 400, height = 400, fov = 20, samples = 10
232233
fileinfovec = scene$fileinfo
233234
fileinfovec[is.na(fileinfovec)] = ""
234235
objfilenamevec = purrr::map_chr(fileinfovec, path.expand)
236+
objbasedirvec = purrr::map_chr(objfilenamevec, dirname)
235237

236238
#bg image handler
237239
if(!is.null(backgroundimage)) {
@@ -242,6 +244,9 @@ render_scene = function(scene, width = 400, height = 400, fov = 20, samples = 10
242244
backgroundstring = ""
243245
}
244246

247+
#scale handler
248+
scale_factor = scene$scale_factor
249+
245250
assertthat::assert_that(all(c(length(xvec),length(yvec),length(zvec),length(rvec),length(typevec),length(proplist)) == length(xvec)))
246251
assertthat::assert_that(all(!is.null(typevec)))
247252
for(i in 1:length(xvec)) {
@@ -289,11 +294,11 @@ render_scene = function(scene, width = 400, height = 400, fov = 20, samples = 10
289294
isvolume=fog_bool, voldensity = fog_vec , parallel=parallel,
290295
implicit_sample = implicit_vec, order_rotation_list = order_rotation_list, clampval = clamp_value,
291296
isgrouped = group_bool, group_pivot=group_pivot, group_translate = group_translate,
292-
group_angle = group_angle, group_order_rotation = group_order_rotation,
297+
group_angle = group_angle, group_order_rotation = group_order_rotation, group_scale = group_scale,
293298
tri_normal_bools = tri_normal_bools, is_tri_color = is_tri_color, tri_color_vert= tri_color_vert,
294-
fileinfo = objfilenamevec, toneval = toneval,
299+
fileinfo = objfilenamevec, filebasedir = objbasedirvec, toneval = toneval,
295300
progress_bar = progress, numbercores = numbercores, debugval = debugval,
296-
hasbackground = hasbackground, background = backgroundstring)
301+
hasbackground = hasbackground, background = backgroundstring, scale_list = scale_factor)
297302
full_array = array(0,c(ncol(rgb_mat$r),nrow(rgb_mat$r),3))
298303
full_array[,,1] = t(rgb_mat$r)
299304
full_array[,,2] = t(rgb_mat$g)

man/cube.Rd

+16-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/cylinder.Rd

+19-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/disk.Rd

+19-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ellipsoid.Rd

+18-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)