piecepackr3d: 3D board game graphics

Build Status AppVeyor Build Status Coverage Status Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

Although piecepackr has basic 3D graphic support via a manually drawn oblique projection this package aims to extend support to 3D graphics using the rgl and rayrender packages. It also supports exporting images using the Wavefront OBJ file format as well as a function that saves png textures for use with James H. Vipond's piecepack OBJ files.

Examples

library("ppgames")
library("piecepackr")
library("piecepackr3d")

df <- ppgames::df_four_field_kono()
envir <- piecepackr::game_systems("dejavu3d")

rgl

piece3d draws pieces using rgl graphics.

library("rgl")
pmap_piece(df, piece3d, trans=op_transform, envir = envir, scale = 0.98, res = 150)

rgl render

piece creates rayrender objects.

rayrender

library("rayrender")
l <- pmap_piece(df, piece, trans=op_transform, envir = envir, scale = 0.98, res = 150)
scene <- do.call(dplyr::bind_rows, l)
render_scene(scene, lookat = c(2.5, 2.5, 0), lookfrom = c(0, -2, 13))

rayrender render

OBJ files

write_obj saves the specified piece as a Wavefront OBJ file (plus an associated MTL file and a png texture).

files <- write_obj("tile_face", suit=3, rank=3, cfg = envir$piecepack)
print(files)
$obj
[1] "/tmp/RtmpvhT4ZB/file11fa251def12.obj"

$mtl
[1] "/tmp/RtmpvhT4ZB/file11fa251def12.mtl"

$png
[1] "/tmp/RtmpvhT4ZB/file11fa251def12.png"

png textures for outside OBJ files

save_3d_textures saves png textures for use with James H. Vipond's piecepack OBJ files. Jame's OBJ models are much richer than the ones generated by write_obj, for instance his tiles have 49 vertices whereas mine only have 8 vertices.

save_3d_textures(cfg = envir$piecepack, directory = tempdir())

Tweaking piecepackr configurations for 3d graphics

Here are a couple of suggestions when making piecepackr configurations for 3d graphics:

  1. Don't use border lines. You can achieve this by setting border_color = "transparent".
  2. Note the height to width ratio of Jame's pawn belts are 265 to 189 whereas the default for piecepackr is 0.5 to 2.356194 (in order to fully wrap around a 3/4" pawn). You may consider setting belt_face.width=1, belt_face.height=265/189 if using save_3d_textures.
  3. You may want to put thought into your edge color for certain pieces like tiles and coins. To simulate a black laser-cut burned look perhaps use edge_color.tile = "black", edge_color.coin = "black".

Installation

remotes::install_github("piecepackr/piecepackr")
remotes::install_github("tylermorganwall/rayrender")
install.packages("rgl", repos="http://R-Forge.R-project.org")
remotes::install_github("piecepackr/piecepackr3d")


piecepackr/piecepackr3d documentation built on Feb. 8, 2020, 1:15 a.m.