save_piece_obj() saves Wavefront OBJ files (including associated MTL and texture image) of board game pieces.
Usage
save_piece_obj(
piece_side = "tile_face",
suit = 1,
rank = 1,
cfg = getOption("piecepackr.cfg", pp_cfg()),
...,
x = 0,
y = 0,
z = 0,
angle = 0,
axis_x = 0,
axis_y = 0,
width = NA,
height = NA,
depth = NA,
envir = getOption("piecepackr.envir"),
filename = tempfile(fileext = "%03d.obj"),
scale = 1,
res = 72
)Arguments
- piece_side
A string with piece and side separated by a underscore e.g. "coin_face"
- suit
Number of suit (starting from 1).
- rank
Number of rank (starting from 1)
- cfg
Piecepack configuration list or
pp_cfgobject, a list ofpp_cfgobjects, or a character vector referring to names inenviror a character vector referring to object names that can be retrieved bybase::dynGet().- ...
Ignored.
- x
Where to place piece on x axis of viewport
- y
Where to place piece on y axis of viewport
- z
z-coordinate of the piece. Has no effect if
op_scaleis0.- angle
Angle (on xy plane) to draw piece at
- axis_x
First coordinate of the axis unit vector.
- axis_y
Second coordinate of the axis unit vector.
- width
Width of piece
- height
Height of piece
- depth
Depth (thickness) of piece. Has no effect if
op_scaleis0.- envir
Environment (or named list) containing configuration list(s).
- filename
Name of Wavefront OBJ object. By default
tempfile(fileext = ".obj").- scale
Multiplicative scaling factor to apply to width, height, and depth.
- res
Resolution of the faces.
See also
See geometry_utils for a discussion of the 3D rotation parameterization.
Examples
if (all(capabilities(c("cairo", "png")))) {
cfg <- game_systems("sans", border = FALSE)$dominoes
files <- save_piece_obj("tile_face", suit = 3+1, rank=6+1, cfg = cfg)
print(files)
}
#> obj
#> 1 /tmp/Rtmp2VI9mg/file2d922e355d4859001.obj
#> mtl
#> 1 /tmp/Rtmp2VI9mg/file2d922e355d4859001.mtl
#> png
#> 1 /tmp/Rtmp2VI9mg/file2d922e355d4859001.png