pig: Pig Object

View source: R/pig.R

pigR Documentation

Pig Object

Description

Builds an earless, low-poly mesh pig from compact data included in rayrender. The skiing outfit includes goggles, a scarf and skis; the spider variant has eight legs, four eyes and procedural copper-colored hair curves.

Usage

pig(
  x = 0,
  y = 0,
  z = 0,
  emotion = "neutral",
  spider = FALSE,
  angle = c(0, 0, 0),
  order_rotation = c(1, 2, 3),
  scale = c(1, 1, 1),
  diffuse_sigma = 0,
  ski = FALSE,
  hair_count = 12000,
  hair_length = 1,
  hair_seed = 8,
  hair_material = NULL
)

Arguments

x

Default 0. x-coordinate offset of the pig.

y

Default 0. y-coordinate offset of the pig.

z

Default 0. z-coordinate offset of the pig.

emotion

Default "neutral". Facial expression: neutral, skeptical, worried, angry, surprised, or excited. cheerful is an alias for neutral. When omitted with ski = TRUE, the expression is excited.

spider

Default FALSE. Generate an eight-legged, four-eyed spider pig.

angle

Default c(0, 0, 0). Rotation in degrees about the x, y and z axes.

order_rotation

Default c(1, 2, 3). Order of the rotation axes.

scale

Default c(1, 1, 1). Uniform scalar or x/y/z scale factors.

diffuse_sigma

Default 0. Oren-Nayar roughness for diffuse surfaces, including the skin. Does not affect glossy eyes, lenses or hair.

ski

Default FALSE. Add the ski outfit and skiing pose. If both ski and spider are TRUE, warns "spiders can't ski" and generates the spider without ski gear.

hair_count

Default 12000. Number of procedural spider hair curves. Set to zero for a bare spider mesh. Ignored for a regular or skiing pig.

hair_length

Default 1. Multiplier for spider hair lengths.

hair_seed

Default 8. Reproducible spider hair seed; preserves the caller's random-number state.

hair_material

Default NULL. Use the built-in rust/copper hair palette. Supply a single hair() material to override the entire coat.

Details

Geometry, expression heads and the ski pose are assembled in memory; no OBJ paths, downloads, Blender or rgl installation are required. The character faces +X, uses Y up, and retains the rotation/scale pivot at c(0, 1, 0). Feet or skis rest approximately at y - 0.6 before rotation and scaling. The mask and goggles can obscure eyebrows in skiing poses. Hair uses tapered bezier_curve() objects with hair() materials. A finite bounce limit, such as max_depth = 12, is useful for dense fur.

Value

A scene tibble containing mesh objects and, for a hairy spider, curves.

Examples


generate_ground(depth = -0.6) |>
  add_object(pig()) |>
  render_scene(lookfrom = c(8, 5, 8), lookat = c(0, 1, 0), samples = 64)

generate_ground(depth = -0.6, material = glossy(color="white")) |>
  add_object(pig(ski = TRUE)) |>
  render_scene(lookfrom = c(8, 5, 8),
               lookat = c(0, 1, 0),
               fov=40,samples = 64)

generate_ground(depth = -0.6) |>
  add_object(pig(spider = TRUE)) |>
  render_scene(lookfrom = c(10, 7, 8), lookat = c(0, 1, 0),
               samples = 64, max_depth = 12)


rayrender documentation built on Sept. 16, 2026, 9:08 a.m.

Related to pig in rayrender...