Skip to content

Commit

Permalink
rayvertex v0.10.6: Fix transmittance to default to zero and fix swap_…
Browse files Browse the repository at this point in the history
…yz() normals
  • Loading branch information
tylermorganwall committed Apr 20, 2024
1 parent e2d734a commit dc263a0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 20 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: rayvertex
Type: Package
Title: 3D Software Rasterizer
Version: 0.10.5
Date: 2024-03-29
Version: 0.10.6
Date: 2024-04-20
Authors@R: c(person("Tyler", "Morgan-Wall", email = "[email protected]",
role = c("aut", "cph", "cre"), comment = c(ORCID = "0000-0002-3131-3814")),
person("Syoyo", "Fujita", role=c("ctb", "cph")),
Expand Down
8 changes: 4 additions & 4 deletions R/material_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'@param diffuse Default `c(0.5,0.5,0.5)`. The diffuse color.
#'@param ambient Default `c(0,0,0)`. The ambient color.
#'@param specular Default `c(1,1,1)`. The specular color.
#'@param transmittance Default `c(1,1,1)`. The transmittance
#'@param transmittance Default `c(0,0,0)`. The transmittance.
#'@param emission Default `c(0,0,0)`. The emissive color.
#'@param shininess Default `50.0`. The shininess exponent.
#'@param ior Default `1.0`. The index of refraction. If this is not equal to `1.0`, the material will be refractive.
Expand Down Expand Up @@ -58,7 +58,7 @@ set_material = function(mesh, material = NULL, id = NULL,
diffuse = c(0.5,0.5,0.5),
ambient = c(0,0,0),
specular = c(1,1,1),
transmittance = c(1,1,1),
transmittance = c(0,0,0),
emission = c(0,0,0),
shininess = 50.0,
ior = 1.0,
Expand Down Expand Up @@ -366,7 +366,7 @@ change_material = function(mesh, id = NULL, sub_id = 1,
#'@param diffuse Default `c(0.5,0.5,0.5)`. The diffuse color.
#'@param ambient Default `c(0,0,0)`. The ambient color.
#'@param specular Default `c(1,1,1)`. The specular color.
#'@param transmittance Default `c(1,1,1)`. The transmittance
#'@param transmittance Default `c(0,0,0)`. The transmittance
#'@param emission Default `c(0,0,0)`. The emissive color.
#'@param shininess Default `50.0`. The shininess exponent.
#'@param ior Default `1.0`. The index of refraction. If this is not equal to `1.0`, the material will be refractive.
Expand Down Expand Up @@ -409,7 +409,7 @@ change_material = function(mesh, id = NULL, sub_id = 1,
material_list = function(diffuse = c(0.8,0.8,0.8),
ambient = c(0,0,0),
specular = c(1,1,1),
transmittance = c(1,1,1),
transmittance = c(0,0,0),
emission = c(0,0,0),
shininess = 50.0,
ior = 1.0,
Expand Down
20 changes: 15 additions & 5 deletions R/swap_yz.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#' Swap Y/Z Axis
#'
#' @param mesh The mesh to swap orientations.
#' @param mesh A raymesh object.
#'
#' @return Mesh with Y and Z axis exchanged
#' @export
#' @examples
#' # Flip a mesh
#' # Flip a mesh that's originally aligned along the y-axis
#' if(run_documentation()) {
#' sphere_mesh(position=c(-1,0,0)) |>
#' add_shape(swap_yz(sphere_mesh(position=c(0,1,0)))) |>
#' rasterize_scene()
#' cyl_mat = material_list(ambient="red", ambient_intensity=0.3,
#' diffuse="red", diffuse_intensity=0.7)
#' change_material(cylinder_mesh(length = 3, position=c(0,2,0), material = cyl_mat),
#' diffuse="green", ambient="green") |>
#' add_shape(swap_yz(cylinder_mesh(position=c(0,2,0), length=3, material = cyl_mat))) |>
#' rasterize_scene(lookfrom=c(10,10,10), lookat=c(0,0,0), fov=40,
#' light_info = directional_light(c(1,1,-1)),
#' line_info = generate_line(end=c(10,0,0)) |>
#' add_lines(generate_line(end=c(0,10,0),color="green")) |>
#' add_lines(generate_line(end=c(0,0,10),color="red")))
#' }
swap_yz = function(mesh) {
for(i in seq_along(mesh$vertices)) {
Expand All @@ -20,5 +27,8 @@ swap_yz = function(mesh) {
mesh$shapes[[i]]$norm_indices = mesh$shapes[[i]]$norm_indices[,3:1]
mesh$shapes[[i]]$tex_indices = mesh$shapes[[i]]$tex_indices[,3:1]
}
for(i in seq_along(mesh$normals)) {
mesh$normals[[i]] = mesh$normals[[i]][,c(1,3,2)]
}
return(mesh)
}
4 changes: 2 additions & 2 deletions man/material_list.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/set_material.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions man/swap_yz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc263a0

Please sign in to comment.