, pivots: list, speed: float, drop: float}> */ private static array $cache = []; /** The cache key of a creature / a human (its look: species, faction, child, variant, held item, companion). */ public static function keyOf(Creature|Npc $e): string { if ($e instanceof Creature) { return $e->species . (($e->data['companion'] ?? false) ? ':c' : ''); } $child = (bool) ($e->data['child'] ?? false); $variant = (int) ($e->data['look'] ?? $e->id) & 7; $held = $e->data['held'] ?? $e->data['weapon'] ?? null; $held = is_string($held) ? $held : self::defaultHeld($e->faction, $variant, $child); return 'npc:' . $e->faction . ':' . ($child ? 'child' : 'adult') . ':' . $variant . ':' . ($held ?? ''); } private static function defaultHeld(string $faction, int $variant, bool $child): ?string { if ($child) { return null; } return match ($faction) { 'rodeur' => ['spear', 'club', 'machete', 'crossbow'][$variant & 3], 'ouvi' => $variant % 3 === 0 ? null : ($variant & 1 ? 'harpoon' : 'spear'), 'hermit' => 'staff', 'colonist' => 'flare_gun', 'haldi' => $variant === 5 ? 'staff' : null, default => null, }; } /** @return array{mesh: Mesh, rig: string, parents: list, pivots: list, speed: float, drop: float} */ public static function get(string $key): array { if (isset(self::$cache[$key])) { return self::$cache[$key]; } $b = new Build(); $parts = explode(':', $key); [$rig, $speed, $drop] = match ($parts[0]) { 'grazer' => self::grazer($b), 'stalker' => self::stalker($b, 1.0, isset($parts[1])), 'stalker_cub' => self::stalker($b, 0.48, isset($parts[1])), 'river_croc' => self::croc($b), 'crawler' => self::crawler($b), 'lava_crab' => self::crab($b), 'burrower' => self::burrower($b), 'fish' => self::fish($b), 'glacier_brute' => self::brute($b), 'climber' => self::climber($b), 'bird' => self::bird($b), 'swarm' => self::swarm($b), 'npc' => self::human($b, $parts[1] ?? 'other', ($parts[2] ?? '') === 'child', (int) ($parts[3] ?? 0), ($parts[4] ?? '') !== '' ? $parts[4] : null), default => self::generic($b), }; $b->m->color = [1.0, 1.0, 1.0]; return self::$cache[$key] = ['mesh' => $b->m, 'rig' => $rig, 'parents' => $b->parents, 'pivots' => $b->pivots, 'speed' => $speed, 'drop' => $drop]; } // ---- skeleton maths ----------------------------------------------------------------------------- /** * Model space 3x4 matrices of the bones (rows, BONES * 12 floats: the uniform u_bones). * @param list $parents @param list $pivots @param list $angles * @return list */ public static function matrices(array $parents, array $pivots, array $angles): array { $W = []; $out = []; for ($b = 0; $b < self::BONES; $b++) { $ax = $angles[$b * 3]; $ay = $angles[$b * 3 + 1]; $az = $angles[$b * 3 + 2]; $px = $pivots[$b * 3]; $py = $pivots[$b * 3 + 1]; $pz = $pivots[$b * 3 + 2]; if ($ax == 0.0 && $ay == 0.0 && $az == 0.0) { $r = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]; } else { $cx = cos($ax); $sx = sin($ax); $cy = cos($ay); $sy = sin($ay); $cz = cos($az); $sz = sin($az); // Ry * Rx * Rz $rxz = [$cz, -$sz, 0.0, $cx * $sz, $cx * $cz, -$sx, $sx * $sz, $sx * $cz, $cx]; $r = [ $cy * $rxz[0] + $sy * $rxz[6], $cy * $rxz[1] + $sy * $rxz[7], $cy * $rxz[2] + $sy * $rxz[8], $rxz[3], $rxz[4], $rxz[5], -$sy * $rxz[0] + $cy * $rxz[6], -$sy * $rxz[1] + $cy * $rxz[7], -$sy * $rxz[2] + $cy * $rxz[8], ]; } // local: about the pivot $tx = $px - ($r[0] * $px + $r[1] * $py + $r[2] * $pz); $ty = $py - ($r[3] * $px + $r[4] * $py + $r[5] * $pz); $tz = $pz - ($r[6] * $px + $r[7] * $py + $r[8] * $pz); $p = $parents[$b] ?? -1; if ($p >= 0 && isset($W[$p])) { $q = $W[$p]; $m = [ $q[0] * $r[0] + $q[1] * $r[3] + $q[2] * $r[6], $q[0] * $r[1] + $q[1] * $r[4] + $q[2] * $r[7], $q[0] * $r[2] + $q[1] * $r[5] + $q[2] * $r[8], $q[0] * $tx + $q[1] * $ty + $q[2] * $tz + $q[3], $q[4] * $r[0] + $q[5] * $r[3] + $q[6] * $r[6], $q[4] * $r[1] + $q[5] * $r[4] + $q[6] * $r[7], $q[4] * $r[2] + $q[5] * $r[5] + $q[6] * $r[8], $q[4] * $tx + $q[5] * $ty + $q[6] * $tz + $q[7], $q[8] * $r[0] + $q[9] * $r[3] + $q[10] * $r[6], $q[8] * $r[1] + $q[9] * $r[4] + $q[10] * $r[7], $q[8] * $r[2] + $q[9] * $r[5] + $q[10] * $r[8], $q[8] * $tx + $q[9] * $ty + $q[10] * $tz + $q[11], ]; } else { $m = [$r[0], $r[1], $r[2], $tx, $r[3], $r[4], $r[5], $ty, $r[6], $r[7], $r[8], $tz]; } $W[$b] = $m; array_push($out, ...$m); } return $out; } // ---- poses -------------------------------------------------------------------------------------- /** * The local angles (x, y, z radians per bone) of a pose, and the body's lift / roll / pitch. * @return array{0: list, 1: float, 2: float, 3: float} [angles, lift (m), roll (rad), pitch (rad)] */ public static function pose(string $rig, string $state, float $anim, float $speed): array { $a = array_fill(0, self::BONES * 3, 0.0); $moving = in_array($state, ['walk', 'wander', 'flee', 'hunt', 'run', 'chase', 'follow', 'patrol', 'swim', 'steal'], true); $fast = in_array($state, ['flee', 'hunt', 'run', 'chase', 'steal'], true); $attack = $state === 'attack'; $dead = $state === 'dead'; $p = $anim * $speed * ($fast ? 1.8 : 1.0) * 2 * M_PI; $s = $moving ? sin($p) : 0.0; $c = $moving ? cos($p) : 0.0; $lift = 0.0; $roll = 0.0; $pitch = 0.0; $breath = sin($anim * 1.9) * 0.025; $set = static function (int $b, float $x, float $y = 0.0, float $z = 0.0) use (&$a): void { $a[$b * 3] = $x; $a[$b * 3 + 1] = $y; $a[$b * 3 + 2] = $z; }; switch ($rig) { case 'quad': case 'croc': $croc = $rig === 'croc'; $amp = $fast ? 0.7 : 0.42; if ($moving) { // trot (walk) or bound (run): diagonal pairs / front and back pairs $pb = $fast ? $p + 0.0 : $p + M_PI; $legs = [[self::FLU, self::FLL, $p], [self::BRU, self::BRL, $fast ? $p + M_PI * 0.9 : $p], [self::FRU, self::FRL, $fast ? $p + 0.4 : $pb], [self::BLU, self::BLL, $fast ? $p + M_PI * 1.2 : $pb]]; foreach ($legs as $k => [$u, $l, $ph]) { $front = $k === 0 || $k === 2; if ($croc) { $set($u, -sin($ph) * 0.5, sin($ph) * 0.5 * ($u === self::FLU || $u === self::BLU ? 1 : -1), 0.0); $set($l, max(0.0, cos($ph)) * 0.5); } else { $set($u, -sin($ph) * $amp); $set($l, ($front ? 1 : -0.6) * (0.15 + max(0.0, cos($ph)) * ($fast ? 1.1 : 0.75))); } } $lift = abs(cos($p * ($fast ? 1.0 : 2.0) / ($fast ? 1.0 : 2.0))) * ($fast ? 0.08 : 0.025); $set(self::CHEST, $fast ? sin($p) * 0.12 : 0.0, $croc ? sin($p) * 0.18 : 0.0); $set(self::BODY, 0.0, $croc ? -sin($p) * 0.14 : 0.0); $set(self::NECK, ($fast ? 0.25 : 0.05) + sin($p * 2) * 0.05); $set(self::HEAD, $fast ? -0.15 : 0.0); $set(self::TAIL1, $fast ? -0.2 : 0.1, sin($p) * ($croc ? 0.35 : 0.25)); $set(self::TAIL2, 0.1, sin($p - 0.8) * ($croc ? 0.45 : 0.3)); $set(self::TAIL3, 0.0, sin($p - 1.6) * 0.5); } else { // idle: breathing; grazers lower their head to graze now and then, others look around $graze = max(0.0, sin($anim * 0.35)) ; $set(self::CHEST, $breath); $set(self::NECK, $croc ? 0.0 : 0.15 + $graze * 1.0, sin($anim * 0.5) * 0.3 * (1 - $graze)); $set(self::HEAD, $croc ? 0.0 : $graze * 0.4 + sin($anim * 3.1) * 0.03 * $graze); $set(self::TAIL1, 0.15, sin($anim * 1.3) * 0.25); $set(self::TAIL2, 0.15, sin($anim * 1.3 - 0.9) * 0.3); $set(self::TAIL3, 0.0, sin($anim * 1.3 - 1.8) * 0.3); $set(self::EARL, 0.0, 0.0, sin($anim * 2.3) * 0.2); $set(self::EARR, 0.0, 0.0, -sin($anim * 1.7 + 1) * 0.2); $set(self::JAW, $croc ? max(0.0, sin($anim * 0.4)) * 0.35 : 0.0); } if ($attack) { $k = max(0.0, sin($anim * 7.0)); if ($croc) { $set(self::JAW, 0.15 + 0.6 * (1 - $k)); $set(self::NECK, -0.25 * $k); $set(self::CHEST, 0.0, sin($anim * 7.0) * 0.25); } else { // a pounce: the chest rises, forelegs reach, jaw wide, head forward $set(self::CHEST, -0.35 * $k); $set(self::FLU, -1.0 * $k); $set(self::FRU, -0.9 * $k); $set(self::FLL, 0.6 * $k); $set(self::FRL, 0.6 * $k); $set(self::NECK, -0.1); $set(self::HEAD, -0.25 * $k); $set(self::JAW, 0.55 * $k + 0.1); $set(self::TAIL1, -0.3, sin($anim * 5.0) * 0.4); $pitch = -0.12 * $k; } } if ($dead) { $roll = M_PI / 2; $set(self::FLU, -0.3); $set(self::FRU, -0.5); $set(self::BLU, 0.3); $set(self::BRU, 0.5); $set(self::FLL, 0.4); $set(self::BLL, -0.3); $set(self::NECK, 0.3, 0.0, 0.4); $set(self::HEAD, 0.3); $set(self::JAW, 0.3); $set(self::TAIL1, 0.4); if ($croc) { $roll = M_PI * 0.95; } } break; case 'insect': case 'crab': $crab = $rig === 'crab'; for ($k = 0; $k < 6; $k++) { $u = 2 + $k; $l = 8 + $k; $side = $k % 2 ? -1.0 : 1.0; $ph = $p + ($k % 2) * M_PI + intdiv($k, 2) * 2.1; $swing = $moving ? sin($ph) * ($crab ? 0.25 : 0.45) : 0.0; $raise = $moving ? max(0.0, cos($ph)) * 0.35 : 0.0; // crabs walk sideways: their legs swing about z instead if ($crab) { $set($u, $swing, 0.0, -$side * $raise); } else { $set($u, 0.0, $swing, -$side * $raise); } $set($l, 0.0, 0.0, $side * $raise * 0.6 + ($dead ? $side * 0.9 : 0.0)); } $set(1, sin($anim * 2.0) * 0.04, sin($anim * 1.3) * 0.08); $set(14, sin($anim * 2.0) * 0.08); $set(15, sin($anim * 2.3) * 0.1); $set(16, 0.0, 0.2 + sin($anim * 1.7) * 0.1, 0.0); $set(17, 0.0, -0.2 - sin($anim * 1.5) * 0.1, 0.0); $set(18, 0.0, -0.3 * max(0.0, sin($anim * 2.0))); $set(19, 0.0, 0.3 * max(0.0, sin($anim * 2.2))); $lift = $moving ? abs(sin($p * 2)) * 0.015 : 0.0; if ($attack) { $k = max(0.0, sin($anim * 9.0)); $set(1, -0.3 * $k); $set(14, -0.8 * $k); $set(15, -0.9 * $k); $set(16, -0.9 * $k, 0.4); $set(17, -0.9 * $k, -0.4); $set(18, 0.0, -0.6 * $k); $set(19, 0.0, 0.6 * $k); $pitch = -0.15 * $k; } if ($dead) { $roll = M_PI; } break; case 'worm': case 'fish': $fish = $rig === 'fish'; $n = $fish ? 4 : 8; for ($b = 0; $b < $n; $b++) { $w = $fish ? ($moving ? 0.35 : 0.15) * ($b / 3 + 0.3) : ($moving ? 0.17 : 0.04); $set($b, $fish ? 0.0 : sin($p * 0.6 - $b * 0.7) * ($moving ? 0.06 : 0.0), sin(($fish ? $anim * 9.0 : $p * 0.7) - $b * 0.9) * $w); } if ($attack && !$fish) { $k = max(0.0, sin($anim * 6.0)); $set(7, -0.8 * $k); $set(6, -0.5 * $k); $set(5, -0.3 * $k); $set(8, 0.6 * $k); } if ($dead) { $roll = M_PI / 2 + ($fish ? M_PI / 2 : 0.0); } break; case 'bird': $flying = $state !== 'idle' && !$dead; if ($flying) { $f = sin($anim * ($fast ? 16.0 : 11.0)); $glide = max(0.0, sin($anim * 0.7)) > 0.6 ? 0.25 : 1.0; $set(2, 0.0, 0.0, 0.75 * $f * $glide); $set(3, 0.0, 0.0, 0.45 * sin($anim * 11.0 - 0.8) * $glide); $set(4, 0.0, 0.0, -0.75 * $f * $glide); $set(5, 0.0, 0.0, -0.45 * sin($anim * 11.0 - 0.8) * $glide); $set(6, sin($anim * 3.0) * 0.1); $set(7, 1.2); $set(8, 1.2); $lift = 0.06 * $f * $glide; } else { // perched: wings folded, pecks and looks around $set(2, 0.0, 0.2, -1.2); $set(3, 0.0, 0.0, 1.9); $set(4, 0.0, -0.2, 1.2); $set(5, 0.0, 0.0, -1.9); $peck = max(0.0, sin($anim * 2.4)) ** 4; $set(1, $peck * 0.9, sin($anim * 0.9) * 0.6); } if ($dead) { $roll = M_PI / 2; $set(2, 0.0, 0.0, 0.2); $set(4, 0.0, 0.0, -0.2); } break; case 'swarm': for ($b = 0; $b < 12; $b++) { $set($b, sin($anim * (1.7 + $b * 0.21) + $b) * 0.5, $anim * (2.5 + $b * 0.37) + $b); } if ($dead) { $lift = -0.8; } break; case 'biped': case 'ape': $ape = $rig === 'ape'; $amp = $fast ? 0.75 : 0.42; $lean = $ape ? 0.35 : 0.0; $set(self::SPINE, $lean + $breath + ($fast ? 0.18 : 0.04), $moving ? -$s * 0.1 : 0.0); $set(self::PELVIS, 0.0, $moving ? $s * 0.09 : 0.0); $set(self::SKULL, -$lean * 0.8 + ($moving ? 0.0 : sin($anim * 0.4) * 0.05), $moving ? $s * 0.05 : sin($anim * 0.31) * 0.35); $set(self::LTH, -$s * $amp, 0.0, 0.02); $set(self::RTH, $s * $amp, 0.0, -0.02); $set(self::LSH, 0.08 + max(0.0, $c) * ($fast ? 1.2 : 0.7)); $set(self::RSH, 0.08 + max(0.0, -$c) * ($fast ? 1.2 : 0.7)); $set(self::LFOOT, $moving ? -max(0.0, $c) * 0.3 + $s * 0.15 : 0.0); $set(self::RFOOT, $moving ? -max(0.0, -$c) * 0.3 - $s * 0.15 : 0.0); $arm = $ape ? 0.9 : 0.75; $set(self::LUA, $s * $amp * $arm - ($ape ? 0.35 : 0.0) + ($fast ? -0.2 : 0.0), 0.0, 0.1); $set(self::RUA, -$s * $amp * $arm - ($ape ? 0.35 : 0.0) + ($fast ? -0.2 : 0.0), 0.0, -0.1); $set(self::LFA, -0.18 - ($fast ? 1.0 : 0.15 * (1 + $s))); $set(self::RFA, -0.18 - ($fast ? 1.0 : 0.15 * (1 - $s))); $set(self::CLOTH, $moving ? 0.08 + abs($s) * 0.15 : 0.0); $set(self::BTAIL1, 0.6 + sin($anim * 1.1) * 0.1, sin($anim * 0.9) * 0.4); $set(self::BTAIL2, -0.6, sin($anim * 0.9 - 0.7) * 0.5); $lift = $moving ? abs($c) * ($fast ? 0.06 : 0.03) - 0.01 : 0.0; if (!$moving && !$attack && !$dead) { // idle: weight on one leg, arms resting $sh = sin($anim * 0.27); $set(self::PELVIS, 0.0, 0.0, $sh * 0.04); $set(self::LTH, 0.0, 0.0, -$sh * 0.04); $set(self::RTH, 0.0, 0.0, -$sh * 0.04); $set(self::LUA, 0.05 + $breath, 0.0, 0.12); $set(self::RUA, 0.05 - $breath, 0.0, -0.12); } if ($state === 'talk') { $g = sin($anim * 2.6); $set(self::RUA, -0.5 + $g * 0.25, 0.3, -0.25); $set(self::RFA, -1.0 + $g * 0.3, 0.0, 0.0); $set(self::LUA, -0.2 - $g * 0.1, 0.0, 0.15); $set(self::LFA, -0.7); $set(self::SKULL, sin($anim * 3.7) * 0.07, sin($anim * 0.8) * 0.15); } if ($state === 'work') { $k = sin($anim * 4.0); $set(self::SPINE, 0.45); $set(self::RUA, -1.4 + $k * 0.6, 0.0, -0.1); $set(self::RFA, -0.5 - max(0.0, $k) * 0.6); $set(self::LUA, -0.9, 0.0, 0.15); $set(self::LFA, -0.6); $set(self::SKULL, 0.25); } if ($state === 'sit' || $state === 'sleep') { $set(self::LTH, -1.5, -0.15, 0.1); $set(self::RTH, -1.5, 0.15, -0.1); $set(self::LSH, 1.6); $set(self::RSH, 1.6); $set(self::LFOOT, -0.2); $set(self::RFOOT, -0.2); $set(self::LUA, -0.6, 0.0, 0.2); $set(self::RUA, -0.6, 0.0, -0.2); $set(self::LFA, -0.8); $set(self::RFA, -0.8); $set(self::SPINE, 0.15 + $breath); $lift = -0.48; if ($state === 'sleep') { $set(self::SKULL, 0.5); $set(self::SPINE, 0.5); } } if ($attack) { $k = sin($anim * 7.0); $hit = max(0.0, $k); // the right arm strikes from above (club, machete, spear stab, fists), the body follows $set(self::RUA, -2.4 + 2.0 * $hit, 0.0, -0.2); $set(self::RFA, -0.6 + 0.5 * $hit); $set(self::LUA, -0.7, 0.0, 0.25); $set(self::LFA, -0.9); $set(self::SPINE, 0.1 + $lean + 0.3 * $hit, -0.3 + 0.5 * $hit); $set(self::LTH, -0.35); $set(self::RTH, 0.25); $set(self::LSH, 0.3); $set(self::RSH, 0.2); if ($ape) { $set(self::LUA, -2.4 + 2.0 * $hit, 0.0, 0.2); $set(self::LFA, -0.6 + 0.5 * $hit); } } if ($state === 'aim') { $set(self::RUA, -1.45, 0.25, -0.1); $set(self::RFA, -0.1); $set(self::LUA, -1.3, -0.35, 0.2); $set(self::LFA, -0.5); $set(self::SKULL, 0.05, 0.15); } if ($dead) { $pitch = -M_PI / 2; $set(self::LUA, -0.6, 0.0, 1.1); $set(self::RUA, -0.3, 0.0, -1.3); $set(self::LFA, -0.3); $set(self::RFA, -0.6); $set(self::SKULL, 0.0, 0.5); $set(self::LTH, -0.2, 0.0, 0.15); $set(self::RTH, 0.1, 0.0, -0.1); $set(self::LSH, 0.4); $set(self::SPINE, 0.0); $lift = 0.0; } break; } return [$a, $lift, $roll, $pitch]; } // ---- shared parts --------------------------------------------------------------------------------- /** * An eye looking along $dir (unit, mesh space): sclera, iris, pupil and a wet glint; $glow > 0 makes the iris * shine in the dark (night predators). * @param array{0: float, 1: float, 2: float} $dir @param array{0: float, 1: float, 2: float} $iris */ private static function eye(Mesh $m, float $x, float $y, float $z, float $r, array $dir, array $iris, float $glow = 0.0, bool $sclera = true): void { [$dx, $dy, $dz] = $dir; $cell = $m->cell; $gloss = $m->sway; $m->cell = Atlas::PLAIN; $m->sway = 1.0; if ($sclera) { $m->color = [0.92, 0.9, 0.85]; $m->ellipsoid($x, $y, $z, $r, $r, $r, 4, 6); } $m->color = $glow > 0 ? [$iris[0] * $glow, $iris[1] * $glow, $iris[2] * $glow] : $iris; $ir = $sclera ? $r * 0.62 : $r; $m->ellipsoid($x + $dx * $r * 0.62, $y + $dy * $r * 0.62, $z + $dz * $r * 0.62, $ir, $ir, $ir, 3, 6); $m->color = $glow > 0 ? [0.3, 0.1, 0.05] : [0.02, 0.02, 0.02]; $m->ellipsoid($x + $dx * $r * 0.95, $y + $dy * $r * 0.95, $z + $dz * $r * 0.95, $ir * 0.45, $ir * 0.45, $ir * 0.45, 3, 5); $m->color = [2.6, 2.6, 2.6]; $m->ellipsoid($x + $dx * $r * 0.98 + $r * 0.25, $y + $dy * $r * 0.98 + $r * 0.3, $z + $dz * $r * 0.98, $r * 0.16, $r * 0.16, $r * 0.16, 2, 4); $m->cell = $cell; $m->sway = $gloss; } /** Teeth: little cones along a line (jaw rim), pointing $down (-1 down, 1 up). */ private static function teeth(Mesh $m, float $x0, float $x1, float $y, float $z0, float $z1, int $n, float $len, float $down): void { $cell = $m->cell; $m->cell = Atlas::BONE; $col = $m->color; $m->color = [1.0, 0.96, 0.86]; for ($k = 0; $k < $n; $k++) { $t = $n > 1 ? $k / ($n - 1) : 0.5; foreach ([-1, 1] as $sd) { $x = $sd * ($x0 + ($x1 - $x0) * $t); $z = $z0 + ($z1 - $z0) * $t; $l = $len * (0.6 + 0.4 * sin($t * M_PI)); $m->tube([[$x, $y, $z, $l * 0.28], [$x, $y + $down * $l, $z, 0.002]], 3, 1.0); } } $m->cell = $cell; $m->color = $col; } // ---- quadrupeds --------------------------------------------------------------------------------- /** A leg: from the shoulder / hip down to the foot, a joint halfway (bones $u then $l). @param list $pts */ private static function leg(Build $b, int $u, int $l, array $pts, ?array $hoof = null, int $sides = 7): void { $m = $b->m; $n = count($pts); $secs = []; foreach ($pts as $k => [$x, $y, $z, $r]) { $t = $k / max(1, $n - 1); // the joint blends both bones if ($t < 0.35) { $secs[] = [$x, $y, $z, $r, $r, $u]; } elseif ($t < 0.6) { $secs[] = [$x, $y, $z, $r, $r * 1.05, $u, $l, 0.5]; } else { $secs[] = [$x, $y, $z, $r, $r, $l]; } } $m->sweep($secs, $sides); if ($hoof !== null) { [$x, $y, $z, $r] = $pts[$n - 1]; $col = $m->color; $m->color = $hoof; $m->skin($l); $m->ellipsoid($x, $y - $r * 0.4, $z + $r * 0.3, $r * 1.15, $r * 0.9, $r * 1.35, 3, 6, 0.0, 1, 0.3); $m->color = $col; } } /** @return array{0: string, 1: float, 2: float} rig, gait speed, height of the roll pivot when dead */ private static function grazer(Build $b): array { // a slender antelope-like grazer: tawny back, pale belly, a dark flank stripe, long neck, spiral horns $m = $b->m; $fur = [0.84, 0.62, 0.4]; $belly = [1.02, 0.96, 0.86]; $b->bone(self::BODY, -1, 0, 1.05, -0.3); $b->bone(self::CHEST, self::BODY, 0, 1.1, 0.25); $b->bone(self::NECK, self::CHEST, 0, 1.3, 0.55); $b->bone(self::HEAD, self::NECK, 0, 1.78, 0.92); $b->bone(self::JAW, self::HEAD, 0, 1.73, 1.0); $b->bone(self::TAIL1, self::BODY, 0, 1.18, -0.78); $b->bone(self::TAIL2, self::TAIL1, 0, 1.0, -0.86); $b->bone(self::EARL, self::HEAD, 0.08, 1.88, 0.92); $b->bone(self::EARR, self::HEAD, -0.08, 1.88, 0.92); $m->cell = Atlas::FUR; $m->color = $fur; $m->belly = $belly; $m->sweep([ [0, 1.0, -0.86, 0.05, 0.08, self::BODY], [0, 1.06, -0.78, 0.16, 0.22, self::BODY], [0, 1.08, -0.55, 0.22, 0.3, self::BODY], [0, 1.05, -0.2, 0.24, 0.3, self::BODY, self::CHEST, 0.3], [0, 1.06, 0.15, 0.25, 0.32, self::BODY, self::CHEST, 0.75], [0, 1.1, 0.45, 0.22, 0.33, self::CHEST], [0, 1.18, 0.62, 0.14, 0.24, self::CHEST, self::NECK, 0.4], ], 12); // the dark stripe along the flank $m->belly = null; $m->color = [0.36, 0.24, 0.16]; foreach ([-1, 1] as $sd) { $m->skin(self::BODY, self::CHEST, 0.5); $m->ellipsoid($sd * 0.205, 0.96, -0.1, 0.05, 0.05, 0.5, 3, 6); } $m->color = $fur; $m->belly = $belly; $m->sweep([ [0, 1.18, 0.5, 0.14, 0.2, self::CHEST], [0, 1.38, 0.66, 0.1, 0.13, self::CHEST, self::NECK, 0.6], [0, 1.58, 0.8, 0.075, 0.1, self::NECK], [0, 1.74, 0.88, 0.07, 0.085, self::NECK, self::HEAD, 0.5], ], 10); // head: skull to muzzle $m->sweep([ [0, 1.82, 0.82, 0.04, 0.05, self::HEAD], [0, 1.84, 0.9, 0.085, 0.09, self::HEAD], [0, 1.81, 1.02, 0.075, 0.075, self::HEAD], [0, 1.76, 1.16, 0.05, 0.05, self::HEAD], [0, 1.74, 1.24, 0.035, 0.036, self::HEAD], ], 10); $m->belly = null; $m->color = [0.16, 0.12, 0.1]; $m->skin(self::HEAD); $m->ellipsoid(0, 1.745, 1.255, 0.032, 0.026, 0.02, 3, 6); $m->skin(self::JAW); $m->color = [0.9, 0.8, 0.68]; $m->sweep([[0, 1.71, 0.98, 0.04, 0.02, self::JAW], [0, 1.71, 1.12, 0.035, 0.018, self::JAW], [0, 1.715, 1.2, 0.02, 0.012, self::JAW]], 6); $m->skin(self::HEAD); foreach ([-1, 1] as $sd) { self::eye($m, $sd * 0.065, 1.845, 1.0, 0.018, [$sd * 0.9, 0.1, 0.4], [0.18, 0.1, 0.05]); } // ears $m->cell = Atlas::FUR; foreach ([[self::EARL, 1], [self::EARR, -1]] as [$bn, $sd]) { $m->skin($bn); $m->color = $fur; $m->ellipsoid($sd * 0.13, 1.9, 0.9, 0.06, 0.022, 0.035, 3, 6); } // spiral horns $m->cell = Atlas::BONE; $m->color = [0.62, 0.55, 0.46]; $m->skin(self::HEAD); foreach ([-1, 1] as $sd) { $r = []; for ($k = 0; $k <= 9; $k++) { $t = $k / 9; $r[] = [$sd * (0.04 + 0.06 * $t + 0.035 * sin($t * 9)), 1.9 + 0.36 * $t, 0.88 - 0.24 * $t + 0.035 * cos($t * 9), 0.024 * (1 - $t * 0.85)]; } $m->tube($r, 5, 0.6); } // legs $m->cell = Atlas::FUR; $hoof = [0.12, 0.1, 0.09]; $m->color = $fur; foreach ([[self::FLU, self::FLL, 0.14, 0.46, 1], [self::FRU, self::FRL, -0.14, 0.46, 1], [self::BLU, self::BLL, 0.15, -0.55, -1], [self::BRU, self::BRL, -0.15, -0.55, -1]] as [$u, $l, $x, $z, $f]) { $b->bone($u, $f > 0 ? self::CHEST : self::BODY, $x, 1.0, $z); $b->bone($l, $u, $x, 0.55, $z + ($f > 0 ? 0.0 : -0.08)); $m->color = $fur; if ($f > 0) { self::leg($b, $u, $l, [[$x, 1.12, $z, 0.11], [$x, 0.85, $z + 0.02, 0.075], [$x, 0.56, $z, 0.045], [$x, 0.3, $z + 0.01, 0.03], [$x, 0.07, $z + 0.01, 0.028]], $hoof); } else { self::leg($b, $u, $l, [[$x, 1.1, $z + 0.05, 0.14], [$x, 0.82, $z - 0.05, 0.09], [$x, 0.56, $z - 0.1, 0.045], [$x, 0.3, $z - 0.04, 0.03], [$x, 0.07, $z, 0.028]], $hoof); } } // tail with a dark tuft $m->color = $fur; $m->sweep([[0, 1.18, -0.82, 0.035, 0.035, self::TAIL1], [0, 1.1, -0.9, 0.03, 0.03, self::TAIL1, self::TAIL2, 0.5], [0, 0.98, -0.93, 0.025, 0.025, self::TAIL2]], 6); $m->color = [0.2, 0.15, 0.12]; $m->skin(self::TAIL2); $m->ellipsoid(0, 0.9, -0.94, 0.04, 0.09, 0.04, 3, 6); return ['quad', 1.1, 0.3]; } /** @return array{0: string, 1: float, 2: float} */ private static function stalker(Build $b, float $k, bool $companion): array { // a lean night predator: dark slate hide with bands, a heavy head, glowing amber eyes, a long tail. // $k < 1: a cub (bigger head, shorter legs, fluffier and lighter). $m = $b->m; $cub = $k < 0.8; $hide = $cub ? [0.6, 0.54, 0.58] : [0.4, 0.36, 0.42]; $dark = $cub ? [0.36, 0.32, 0.36] : [0.17, 0.15, 0.19]; $belly = $cub ? [0.86, 0.8, 0.76] : [0.62, 0.56, 0.54]; $h = $k * ($cub ? 0.85 : 1.0); $legK = $cub ? 0.8 : 1.0; $y0 = 0.62 * $h * $legK; $b->bone(self::BODY, -1, 0, $y0, -0.35 * $k); $b->bone(self::CHEST, self::BODY, 0, $y0 + 0.02, 0.3 * $k); $b->bone(self::NECK, self::CHEST, 0, $y0 + 0.08 * $k, 0.62 * $k); $hs = $cub ? 1.35 : 1.0; $hz = 0.85 * $k; $hy = $y0 + 0.12 * $k; $b->bone(self::HEAD, self::NECK, 0, $hy, $hz); $b->bone(self::JAW, self::HEAD, 0, $hy - 0.06 * $k * $hs, $hz + 0.05 * $k); $b->bone(self::TAIL1, self::BODY, 0, $y0 + 0.08 * $k, -0.8 * $k); $b->bone(self::TAIL2, self::TAIL1, 0, $y0 - 0.02, -1.3 * $k); $b->bone(self::TAIL3, self::TAIL2, 0, $y0 + 0.05, -1.75 * $k); $b->bone(self::EARL, self::HEAD, 0.1 * $k * $hs, $hy + 0.14 * $k * $hs, $hz - 0.05 * $k); $b->bone(self::EARR, self::HEAD, -0.1 * $k * $hs, $hy + 0.14 * $k * $hs, $hz - 0.05 * $k); $m->cell = Atlas::FUR; $m->belly = $belly; // body: bands of dark and hide along the back $secs = []; $zs = [-0.88, -0.78, -0.55, -0.3, -0.05, 0.2, 0.45, 0.62, 0.72]; $rx = [0.06, 0.15, 0.2, 0.19, 0.2, 0.23, 0.25, 0.2, 0.14]; $ry = [0.08, 0.18, 0.22, 0.2, 0.21, 0.25, 0.27, 0.22, 0.16]; foreach ($zs as $i => $z) { $w = max(0.0, min(1.0, ($z + 0.3) / 0.8)); $col = $i % 2 ? $dark : $hide; $secs[] = [0, $y0 + 0.02 + ($z > 0.4 ? 0.03 : 0.0), $z * $k, $rx[$i] * $k, $ry[$i] * $k, self::BODY, self::CHEST, $w, $i > 0 && $i < 8 ? $col : $hide]; } $m->color = $hide; $m->sweep($secs, 12); $m->color = $hide; $m->sweep([ [0, $y0 + 0.05, 0.55 * $k, 0.16 * $k, 0.18 * $k, self::CHEST], [0, $y0 + 0.08 * $k, 0.7 * $k, 0.13 * $k, 0.15 * $k, self::CHEST, self::NECK, 0.6], [0, $hy, $hz - 0.05 * $k, 0.12 * $k * $hs, 0.13 * $k * $hs, self::NECK, self::HEAD, 0.7], ], 10); // head: a broad skull and a heavy muzzle $s = $k * $hs; $m->sweep([ [0, $hy + 0.01, $hz - 0.08 * $s, 0.08 * $s, 0.08 * $s, self::HEAD], [0, $hy + 0.03 * $s, $hz + 0.02 * $s, 0.15 * $s, 0.13 * $s, self::HEAD], [0, $hy + 0.01 * $s, $hz + 0.14 * $s, 0.12 * $s, 0.1 * $s, self::HEAD], [0, $hy - 0.02 * $s, $hz + 0.26 * $s, 0.08 * $s, 0.065 * $s, self::HEAD], [0, $hy - 0.03 * $s, $hz + 0.33 * $s, 0.05 * $s, 0.045 * $s, self::HEAD], ], 12); $m->belly = null; $m->color = [0.08, 0.07, 0.08]; $m->skin(self::HEAD); $m->ellipsoid(0, $hy - 0.02 * $s, $hz + 0.345 * $s, 0.035 * $s, 0.025 * $s, 0.02 * $s, 3, 6); // lower jaw, red mouth, teeth $m->color = [0.45, 0.16, 0.15]; $m->skin(self::JAW); $m->sweep([[0, $hy - 0.07 * $s, $hz + 0.04 * $s, 0.08 * $s, 0.035 * $s, self::JAW], [0, $hy - 0.075 * $s, $hz + 0.2 * $s, 0.065 * $s, 0.03 * $s, self::JAW], [0, $hy - 0.065 * $s, $hz + 0.3 * $s, 0.04 * $s, 0.02 * $s, self::JAW]], 8); $m->skin(self::HEAD); self::teeth($m, 0.04 * $s, 0.055 * $s, $hy - 0.05 * $s, $hz + 0.3 * $s, $hz + 0.2 * $s, 3, ($cub ? 0.02 : 0.05) * $s, -1); $m->skin(self::JAW); self::teeth($m, 0.035 * $s, 0.05 * $s, $hy - 0.06 * $s, $hz + 0.27 * $s, $hz + 0.18 * $s, 2, 0.03 * $s, 1); $m->skin(self::HEAD); foreach ([-1, 1] as $sd) { self::eye($m, $sd * 0.085 * $s, $hy + 0.06 * $s, $hz + 0.15 * $s, ($cub ? 0.03 : 0.025) * $s, [$sd * 0.5, 0.1, 0.85], [1.2, 0.75, 0.15], $cub ? 0.0 : 2.4, $cub); } // ears: tall, pointed $m->cell = Atlas::FUR; $m->color = $dark; foreach ([[self::EARL, 1], [self::EARR, -1]] as [$bn, $sd]) { $m->skin($bn); $m->tube([[$sd * 0.1 * $s, $hy + 0.1 * $s, $hz - 0.03 * $s, 0.045 * $s], [$sd * 0.13 * $s, $hy + 0.22 * $s, $hz - 0.06 * $s, 0.03 * $s], [$sd * 0.15 * $s, $hy + 0.3 * $s, $hz - 0.08 * $s, 0.003]], 5, 1.0); } // legs, big paws foreach ([[self::FLU, self::FLL, 0.17, 0.5, 1], [self::FRU, self::FRL, -0.17, 0.5, 1], [self::BLU, self::BLL, 0.17, -0.55, -1], [self::BRU, self::BRL, -0.17, -0.55, -1]] as [$u, $l, $x, $z, $f]) { $x *= $k; $z *= $k; $b->bone($u, $f > 0 ? self::CHEST : self::BODY, $x, $y0, $z); $b->bone($l, $u, $x * 1.05, $y0 * 0.5, $z); $m->color = $hide; $kk = $k * ($cub ? 1.25 : 1.0); self::leg($b, $u, $l, [[$x, $y0 + 0.05, $z, 0.13 * $kk], [$x * 1.05, $y0 * 0.75, $z - 0.03 * $f * $k, 0.09 * $kk], [$x * 1.05, $y0 * 0.48, $z - 0.05 * $f * $k, 0.06 * $kk], [$x * 1.05, $y0 * 0.2, $z, 0.05 * $kk], [$x * 1.05, 0.05 * $k, $z + 0.02 * $k, 0.05 * $kk]], null); $m->color = $dark; $m->skin($l); $m->ellipsoid($x * 1.05, 0.04 * $k, $z + 0.07 * $k, 0.075 * $kk, 0.045 * $kk, 0.1 * $kk, 3, 6, 0.0, 1, 0.4); $m->cell = Atlas::BONE; $m->color = [0.2, 0.18, 0.16]; if (!$cub) { foreach ([-1, 0, 1] as $c) { $m->tube([[$x * 1.05 + $c * 0.035 * $k, 0.04 * $k, $z + 0.15 * $k, 0.012], [$x * 1.05 + $c * 0.035 * $k, 0.0, $z + 0.2 * $k, 0.002]], 3, 1.0); } } $m->cell = Atlas::FUR; } // the long tail $m->color = $hide; $m->sweep([ [0, $y0 + 0.1 * $k, -0.82 * $k, 0.07 * $k, 0.075 * $k, self::TAIL1], [0, $y0 + 0.03, -1.1 * $k, 0.055 * $k, 0.055 * $k, self::TAIL1, self::TAIL2, 0.5, $dark], [0, $y0 - 0.02, -1.35 * $k, 0.045 * $k, 0.045 * $k, self::TAIL2, -1, 0.0, $hide], [0, $y0 + 0.02, -1.6 * $k, 0.035 * $k, 0.035 * $k, self::TAIL2, self::TAIL3, 0.5, $dark], [0, $y0 + 0.08, -1.85 * $k, 0.025 * $k, 0.025 * $k, self::TAIL3, -1, 0.0, $hide], [0, $y0 + 0.12, -2.0 * $k, 0.006, 0.006, self::TAIL3], ], 7); if ($companion) { // a woven collar: Rob's companion $m->cell = Atlas::PATTERN; $m->color = [1.0, 0.9, 0.8]; $m->sweep([[0, $y0 + 0.08 * $k, 0.74 * $k, 0.14 * $k, 0.16 * $k, self::NECK], [0, $y0 + 0.1 * $k, 0.8 * $k, 0.14 * $k, 0.16 * $k, self::NECK]], 10); } return ['quad', $cub ? 1.6 : 1.25, 0.25 * $k]; } /** @return array{0: string, 1: float, 2: float} */ private static function croc(Build $b): array { // a river ambusher: 4 m, low and sprawled, ridged armour, a long toothy snout, eyes and nostrils on top $m = $b->m; $back = [0.34, 0.38, 0.26]; $belly = [0.78, 0.74, 0.56]; $y = 0.3; $b->bone(self::BODY, -1, 0, $y, -0.3); $b->bone(self::CHEST, self::BODY, 0, $y, 0.4); $b->bone(self::NECK, self::CHEST, 0, $y, 0.95); $b->bone(self::HEAD, self::NECK, 0, $y + 0.02, 1.15); $b->bone(self::JAW, self::HEAD, 0, $y - 0.04, 1.2); $b->bone(self::TAIL1, self::BODY, 0, $y, -0.8); $b->bone(self::TAIL2, self::TAIL1, 0, $y - 0.02, -1.5); $b->bone(self::TAIL3, self::TAIL2, 0, $y - 0.04, -2.2); $m->cell = Atlas::SCALES; $m->color = $back; $m->belly = $belly; $m->sweep([ [0, $y, -0.85, 0.24, 0.14, self::BODY, self::TAIL1, 0.6], [0, $y + 0.02, -0.5, 0.34, 0.18, self::BODY], [0, $y + 0.03, -0.1, 0.38, 0.19, self::BODY, self::CHEST, 0.4], [0, $y + 0.03, 0.35, 0.36, 0.18, self::CHEST], [0, $y + 0.02, 0.75, 0.24, 0.13, self::CHEST, self::NECK, 0.5], [0, $y + 0.02, 1.05, 0.2, 0.11, self::NECK, self::HEAD, 0.5], ], 12); $m->sweep([ [0, $y + 0.02, -0.75, 0.25, 0.14, self::TAIL1], [0, $y, -1.2, 0.18, 0.12, self::TAIL1, self::TAIL2, 0.5], [0, $y - 0.02, -1.7, 0.12, 0.1, self::TAIL2, self::TAIL3, 0.4], [0, $y - 0.03, -2.2, 0.07, 0.08, self::TAIL3], [0, $y - 0.04, -2.7, 0.02, 0.05, self::TAIL3], ], 9); // dorsal scutes: two rows of ridges $m->belly = null; $m->color = [0.22, 0.25, 0.17]; for ($k = 0; $k < 16; $k++) { $z = 0.8 - $k * 0.2; $bn = $z > 0.35 ? self::CHEST : ($z > -0.75 ? self::BODY : ($z > -1.5 ? self::TAIL1 : self::TAIL2)); $w = $z > -0.75 ? 0.12 : 0.06; $hh = $z > -0.75 ? $y + 0.18 : $y + 0.14 - ($k - 8) * 0.008; $m->skin($bn); foreach ($z > -1.2 ? [-1, 1] : [0] as $sd) { $m->ellipsoid($sd * $w, $hh, $z, 0.035, 0.04, 0.07, 3, 5); } } // the snout $m->color = $back; $m->belly = $belly; $m->sweep([ [0, $y + 0.05, 1.05, 0.17, 0.09, self::HEAD], [0, $y + 0.04, 1.3, 0.12, 0.06, self::HEAD], [0, $y + 0.03, 1.6, 0.09, 0.045, self::HEAD], [0, $y + 0.03, 1.8, 0.075, 0.04, self::HEAD], [0, $y + 0.025, 1.88, 0.05, 0.03, self::HEAD], ], 10); $m->color = [0.6, 0.55, 0.42]; $m->belly = null; $m->sweep([ [0, $y - 0.05, 1.1, 0.15, 0.05, self::JAW], [0, $y - 0.04, 1.4, 0.11, 0.035, self::JAW], [0, $y - 0.02, 1.75, 0.07, 0.03, self::JAW], [0, $y - 0.015, 1.86, 0.045, 0.02, self::JAW], ], 8); $m->skin(self::HEAD); self::teeth($m, 0.06, 0.1, $y - 0.005, 1.82, 1.2, 7, 0.04, -1); $m->skin(self::JAW); self::teeth($m, 0.055, 0.09, $y - 0.02, 1.78, 1.25, 6, 0.035, 1); $m->skin(self::HEAD); $m->cell = Atlas::SCALES; $m->color = $back; foreach ([-1, 1] as $sd) { $m->ellipsoid($sd * 0.07, $y + 0.12, 1.2, 0.05, 0.045, 0.06, 3, 6); self::eye($m, $sd * 0.075, $y + 0.15, 1.22, 0.022, [$sd * 0.4, 0.5, 0.7], [0.75, 0.6, 0.1], 0.0, false); $m->color = [0.1, 0.1, 0.08]; $m->ellipsoid($sd * 0.025, $y + 0.065, 1.86, 0.012, 0.01, 0.012, 2, 4); $m->color = $back; } // sprawled legs: out to the sides, then down foreach ([[self::FLU, self::FLL, 1, 0.45], [self::FRU, self::FRL, -1, 0.45], [self::BLU, self::BLL, 1, -0.55], [self::BRU, self::BRL, -1, -0.55]] as [$u, $l, $sd, $z]) { $b->bone($u, $z > 0 ? self::CHEST : self::BODY, $sd * 0.28, $y, $z); $b->bone($l, $u, $sd * 0.5, $y - 0.02, $z); $m->color = $back; $m->belly = $belly; $m->sweep([ [$sd * 0.25, $y, $z, 0.09, 0.08, $u], [$sd * 0.42, $y - 0.02, $z, 0.07, 0.065, $u], [$sd * 0.5, $y - 0.05, $z, 0.06, 0.06, $u, $l, 0.5], [$sd * 0.55, $y - 0.18, $z + 0.03, 0.05, 0.05, $l], [$sd * 0.57, 0.04, $z + 0.05, 0.045, 0.04, $l], ], 7); $m->belly = null; $m->skin($l); $m->color = [0.26, 0.28, 0.2]; for ($t = -2; $t <= 2; $t++) { $m->tube([[$sd * 0.57, 0.03, $z + 0.05, 0.02], [$sd * (0.57 + $t * 0.03), 0.015, $z + 0.16 + (2 - abs($t)) * 0.02, 0.005]], 3, 1.0); } } $m->sway = 0.6; // a wet, glossy hide return ['croc', 0.9, 0.3]; } /** @return array{0: string, 1: float, 2: float} */ private static function generic(Build $b): array { $m = $b->m; $b->bone(self::BODY, -1, 0, 0.5, -0.2); $b->bone(self::CHEST, self::BODY, 0, 0.5, 0.2); $b->bone(self::NECK, self::CHEST, 0, 0.55, 0.4); $b->bone(self::HEAD, self::NECK, 0, 0.6, 0.5); $m->cell = Atlas::SKIN; $m->color = [0.6, 0.55, 0.5]; $m->belly = [0.8, 0.75, 0.68]; $m->sweep([[0, 0.5, -0.5, 0.06, 0.06, self::BODY], [0, 0.5, -0.35, 0.22, 0.2, self::BODY], [0, 0.52, 0.1, 0.25, 0.22, self::BODY, self::CHEST, 0.5], [0, 0.53, 0.35, 0.2, 0.2, self::CHEST], [0, 0.58, 0.5, 0.12, 0.13, self::NECK, self::HEAD, 0.5], [0, 0.6, 0.72, 0.08, 0.08, self::HEAD], [0, 0.58, 0.8, 0.03, 0.03, self::HEAD]], 10); $m->belly = null; foreach ([-1, 1] as $sd) { self::eye($m, $sd * 0.07, 0.65, 0.68, 0.02, [$sd * 0.6, 0.1, 0.8], [0.2, 0.15, 0.1]); } foreach ([[self::FLU, self::FLL, 0.14, 0.3, self::CHEST], [self::FRU, self::FRL, -0.14, 0.3, self::CHEST], [self::BLU, self::BLL, 0.14, -0.3, self::BODY], [self::BRU, self::BRL, -0.14, -0.3, self::BODY]] as [$u, $l, $x, $z, $p]) { $b->bone($u, $p, $x, 0.45, $z); $b->bone($l, $u, $x, 0.25, $z); self::leg($b, $u, $l, [[$x, 0.5, $z, 0.07], [$x, 0.25, $z, 0.05], [$x, 0.03, $z, 0.04]], [0.2, 0.18, 0.15], 6); } return ['quad', 1.4, 0.25]; } // ---- many legs ---------------------------------------------------------------------------------- /** @return array{0: string, 1: float, 2: float} */ private static function crawler(Build $b): array { // a cave insect the size of a dog: three armoured segments, six jointed legs, mandibles, a curled venom tail $m = $b->m; $shell = [0.3, 0.34, 0.24]; $b->bone(0, -1, 0, 0.35, 0.0); $b->bone(1, 0, 0, 0.35, 0.32); $b->bone(14, 0, 0, 0.38, -0.32); $b->bone(15, 14, 0, 0.9, -0.55); $m->cell = Atlas::CHITIN; $m->color = $shell; $m->belly = [0.5, 0.48, 0.36]; $m->sway = 0.8; $m->sweep([[0, 0.34, -0.3, 0.1, 0.08, 0], [0, 0.37, -0.15, 0.24, 0.15, 0], [0, 0.38, 0.1, 0.27, 0.16, 0], [0, 0.36, 0.28, 0.18, 0.12, 0, 1, 0.6]], 12); $m->sweep([[0, 0.34, 0.3, 0.12, 0.1, 1], [0, 0.35, 0.42, 0.19, 0.12, 1], [0, 0.33, 0.58, 0.14, 0.09, 1], [0, 0.31, 0.64, 0.06, 0.05, 1]], 10); $m->belly = null; // segment rims $m->color = [0.18, 0.2, 0.14]; $m->skin(0); $m->sweep([[0, 0.38, -0.02, 0.275, 0.165, 0], [0, 0.38, 0.02, 0.275, 0.165, 0]], 12); $m->skin(1); $m->color = [0.14, 0.11, 0.08]; foreach ([-1, 1] as $sd) { $m->tube([[$sd * 0.07, 0.31, 0.6, 0.025], [$sd * 0.15, 0.29, 0.74, 0.018], [$sd * 0.05, 0.27, 0.86, 0.004]], 4, 1.0); self::eye($m, $sd * 0.09, 0.42, 0.55, 0.03, [$sd * 0.4, 0.3, 0.8], [1.6, 0.35, 0.22], 1.8, false); } // antennae $m->color = $shell; foreach ([-1, 1] as $sd) { $m->tube([[$sd * 0.05, 0.42, 0.6, 0.008], [$sd * 0.2, 0.6, 0.85, 0.005], [$sd * 0.35, 0.62, 1.1, 0.002]], 3, 1.0); } // legs: 2..7 upper, 8..13 lower $k = 0; foreach ([0.22, 0.02, -0.18] as $z) { foreach ([1, -1] as $sd) { $u = 2 + $k; $l = 8 + $k; $b->bone($u, 0, $sd * 0.22, 0.35, $z); $b->bone($l, $u, $sd * 0.5, 0.5, $z + 0.05); $m->color = [0.24, 0.27, 0.19]; $m->sweep([[$sd * 0.2, 0.35, $z, 0.04, 0.04, $u], [$sd * 0.38, 0.48, $z + 0.03, 0.032, 0.032, $u], [$sd * 0.5, 0.5, $z + 0.05, 0.03, 0.03, $u, $l, 0.5], [$sd * 0.62, 0.3, $z + 0.08, 0.022, 0.022, $l], [$sd * 0.72, 0.0, $z + 0.11, 0.006, 0.006, $l]], 5); $k++; } } // tail: up and over the back, a glowing sting $rings = []; for ($i = 0; $i <= 8; $i++) { $t = $i / 8; $rings[] = [0.0, 0.38 + sin($t * M_PI * 0.85) * 0.62, -0.3 - sin($t * M_PI * 0.6) * 0.45 + $t * $t * 0.35, 0.14 * (1 - $t * 0.75), 0.12 * (1 - $t * 0.75), $t < 0.5 ? 14 : 15, $t > 0.3 && $t < 0.7 ? ($t < 0.5 ? 15 : 14) : -1, 0.5]; } $m->color = $shell; $m->sweep($rings, 8); $last = $rings[8]; $m->skin(15); $m->cell = Atlas::PLAIN; $m->color = [2.6, 2.0, 0.5]; $m->tube([[0, $last[1] + 0.02, $last[2] + 0.02, 0.03], [0, $last[1] - 0.03, $last[2] + 0.14, 0.003]], 4, 1.0); $m->sway = 0.0; return ['insect', 1.8, 0.25]; } /** @return array{0: string, 1: float, 2: float} */ private static function crab(Build $b): array { // a lava crab of the volcanic coast: a black, ridged carapace veined with glowing orange cracks, two big // claws, six legs, eyes on stalks $m = $b->m; $shell = [0.16, 0.12, 0.12]; $b->bone(0, -1, 0, 0.3, 0.0); $b->bone(1, 0, 0, 0.32, 0.2); $m->cell = Atlas::CHITIN; $m->color = $shell; $m->sway = 0.7; $m->belly = [0.4, 0.22, 0.16]; $m->sweep([[0, 0.28, -0.3, 0.12, 0.05, 0], [0, 0.32, -0.2, 0.36, 0.12, 0], [0, 0.34, 0.0, 0.45, 0.14, 0], [0, 0.33, 0.18, 0.38, 0.12, 0, 1, 0.5], [0, 0.3, 0.3, 0.2, 0.07, 1]], 14); $m->belly = null; // the glowing cracks over the back $m->cell = Atlas::PLAIN; $m->color = [3.0, 1.2, 0.3]; $m->skin(0); foreach ([[-0.25, 0.1, 0.0, -0.15], [0.05, -0.15, 0.3, 0.05], [-0.1, 0.18, 0.15, 0.12], [0.2, -0.05, 0.32, 0.1]] as [$x0, $z0, $x1, $z1]) { $m->tube([[$x0, 0.455, $z0, 0.012], [($x0 + $x1) / 2 + 0.03, 0.465, ($z0 + $z1) / 2, 0.012], [$x1, 0.455, $z1, 0.01]], 3, 1.0); } // eye stalks $m->skin(1); foreach ([-1, 1] as $sd) { $m->cell = Atlas::CHITIN; $m->color = $shell; $m->tube([[$sd * 0.07, 0.38, 0.27, 0.018], [$sd * 0.09, 0.5, 0.3, 0.014]], 4, 1.0); self::eye($m, $sd * 0.09, 0.52, 0.3, 0.025, [0.0, 0.3, 1.0], [1.8, 0.8, 0.2], 1.5, false); } // claws: 16 / 17 the arm, 18 / 19 the pincer foreach ([[16, 18, 1], [17, 19, -1]] as [$arm, $pin, $sd]) { $b->bone($arm, 1, $sd * 0.3, 0.32, 0.22); $b->bone($pin, $arm, $sd * 0.42, 0.35, 0.62); $m->cell = Atlas::CHITIN; $m->color = $shell; $m->sweep([[$sd * 0.28, 0.32, 0.22, 0.05, 0.05, $arm], [$sd * 0.42, 0.36, 0.35, 0.05, 0.05, $arm], [$sd * 0.42, 0.36, 0.48, 0.09, 0.07, $arm], [$sd * 0.42, 0.36, 0.62, 0.08, 0.06, $arm], [$sd * 0.4, 0.37, 0.78, 0.03, 0.03, $arm]], 8); $m->sweep([[$sd * 0.47, 0.33, 0.6, 0.035, 0.03, $pin], [$sd * 0.5, 0.32, 0.72, 0.025, 0.022, $pin], [$sd * 0.46, 0.33, 0.82, 0.005, 0.005, $pin]], 6); $m->cell = Atlas::PLAIN; $m->color = [2.6, 1.0, 0.25]; $m->skin($arm); $m->ellipsoid($sd * 0.42, 0.42, 0.5, 0.02, 0.008, 0.06, 2, 4); } // six legs $k = 0; foreach ([0.12, -0.05, -0.2] as $z) { foreach ([1, -1] as $sd) { $u = 2 + $k; $l = 8 + $k; $b->bone($u, 0, $sd * 0.38, 0.32, $z); $b->bone($l, $u, $sd * 0.62, 0.42, $z); $m->cell = Atlas::CHITIN; $m->color = [0.22, 0.14, 0.12]; $m->sweep([[$sd * 0.36, 0.3, $z, 0.035, 0.03, $u], [$sd * 0.62, 0.42, $z - 0.02, 0.03, 0.025, $u, $l, 0.5], [$sd * 0.75, 0.2, $z - 0.03, 0.022, 0.02, $l], [$sd * 0.8, 0.0, $z - 0.04, 0.005, 0.005, $l]], 5); $k++; } } $m->sway = 0.0; return ['crab', 1.6, 0.25]; } /** @return array{0: string, 1: float, 2: float} */ private static function burrower(Build $b): array { // a sand-coloured worm-like ambusher: eight banded, armoured segments and a crown of hooked teeth $m = $b->m; $m->cell = Atlas::SKIN; $m->belly = [0.86, 0.72, 0.56]; $secs = []; for ($k = 0; $k < 8; $k++) { $z = -1.6 + $k * 0.4; $b->bone($k, $k > 0 ? $k - 1 : -1, 0, 0.36, $z - 0.2); $r = 0.36 - abs($k - 4.5) * 0.035; $col = $k % 2 ? [0.74, 0.54, 0.36] : [0.6, 0.42, 0.28]; $secs[] = [0, 0.36, $z - 0.18, $r * 0.92, $r * 0.86, $k, $k > 0 ? $k - 1 : -1, 0.35, $col]; $secs[] = [0, 0.38, $z, $r, $r * 0.95, $k, -1, 0.0, $col]; } $secs[0][3] = 0.12; $secs[0][4] = 0.12; $secs[] = [0, 0.38, 1.6, 0.3, 0.28, 7]; $m->color = [0.7, 0.52, 0.34]; $m->sweep($secs, 12); $m->belly = null; $b->bone(8, 7, 0, 0.38, 1.6); $m->color = [0.45, 0.15, 0.14]; $m->skin(7); $m->ellipsoid(0, 0.38, 1.6, 0.26, 0.24, 0.05, 4, 10); $m->cell = Atlas::BONE; $m->color = [1.0, 0.95, 0.82]; for ($k = 0; $k < 10; $k++) { $a = $k / 10 * 2 * M_PI; $m->skin($k % 2 ? 8 : 7); $m->tube([[cos($a) * 0.24, 0.38 + sin($a) * 0.22, 1.6, 0.035], [cos($a) * 0.2, 0.38 + sin($a) * 0.19, 1.76, 0.02], [cos($a) * 0.1, 0.38 + sin($a) * 0.08, 1.84, 0.003]], 3, 1.0); } return ['worm', 0.8, 0.3]; } /** @return array{0: string, 1: float, 2: float} */ private static function fish(Build $b): array { // a river fish, 60 cm: dark green back, silver flanks, a forked tail, fins $m = $b->m; for ($k = 0; $k < 4; $k++) { $b->bone($k, $k > 0 ? $k - 1 : -1, 0, 0.0, 0.15 - $k * 0.14); } $m->cell = Atlas::SCALES; $m->color = [0.3, 0.38, 0.3]; $m->belly = [1.05, 1.05, 1.0]; $m->sway = 1.0; $m->sweep([[0, 0, 0.32, 0.01, 0.01, 0], [0, 0.0, 0.26, 0.04, 0.05, 0], [0, 0.005, 0.12, 0.06, 0.085, 0, 1, 0.3], [0, 0.0, -0.05, 0.055, 0.08, 1, 2, 0.4], [0, 0.0, -0.2, 0.035, 0.05, 2, 3, 0.5], [0, 0.0, -0.3, 0.015, 0.02, 3]], 10); $m->belly = null; $m->cell = Atlas::FEATHERS; $m->color = [0.4, 0.45, 0.38]; $m->skin(3); $m->quad4([0, 0.0, -0.28], [0, 0.09, -0.42], [0, 0.0, -0.36], [0, -0.09, -0.42], [1, 0, 0]); $m->skin(1); $m->quad4([0, 0.07, 0.05], [0, 0.07, -0.12], [0, 0.13, -0.08], [0, 0.11, 0.02], [1, 0, 0]); foreach ([-1, 1] as $sd) { $m->skin(0); self::eye($m, $sd * 0.035, 0.02, 0.24, 0.012, [$sd * 0.9, 0.1, 0.3], [0.8, 0.7, 0.2]); } $m->sway = 0.0; return ['fish', 1.0, 0.0]; } /** @return array{0: string, 1: float, 2: float} */ private static function bird(Build $b): array { $m = $b->m; $b->bone(0, -1, 0, 0, 0); $b->bone(1, 0, 0, 0.05, 0.2); $b->bone(6, 0, 0, 0.0, -0.18); $m->cell = Atlas::FEATHERS; $m->color = [0.25, 0.36, 0.6]; $m->belly = [0.9, 0.78, 0.6]; $m->sweep([[0, -0.01, -0.22, 0.02, 0.02, 0], [0, 0.0, -0.14, 0.08, 0.07, 0], [0, 0.0, 0.0, 0.11, 0.1, 0], [0, 0.03, 0.14, 0.08, 0.08, 0, 1, 0.5], [0, 0.07, 0.22, 0.06, 0.065, 1], [0, 0.08, 0.3, 0.055, 0.055, 1], [0, 0.07, 0.35, 0.02, 0.02, 1]], 10); $m->belly = null; $m->skin(1); $m->cell = Atlas::PLAIN; $m->color = [0.95, 0.68, 0.2]; $m->sweep([[0, 0.075, 0.33, 0.02, 0.018, 1], [0, 0.065, 0.42, 0.003, 0.003, 1]], 5); foreach ([-1, 1] as $sd) { self::eye($m, $sd * 0.04, 0.1, 0.3, 0.012, [$sd * 0.8, 0.2, 0.5], [0.1, 0.08, 0.05], 0.0, false); } $m->cell = Atlas::FEATHERS; foreach ([[2, 3, 1], [4, 5, -1]] as [$in, $out, $sd]) { $b->bone($in, 0, $sd * 0.08, 0.03, 0.02); $b->bone($out, $in, $sd * 0.36, 0.04, 0.0); $m->color = [0.22, 0.32, 0.55]; $m->skin($in); $m->quad4([$sd * 0.06, 0.03, 0.12], [$sd * 0.38, 0.045, 0.08], [$sd * 0.38, 0.04, -0.14], [$sd * 0.06, 0.03, -0.1], [0, 1, 0]); $m->skin($out); $m->color = [0.16, 0.22, 0.4]; $m->quad4([$sd * 0.37, 0.045, 0.08], [$sd * 0.72, 0.05, 0.0], [$sd * 0.66, 0.045, -0.16], [$sd * 0.37, 0.04, -0.14], [0, 1, 0]); } $m->skin(6); $m->color = [0.2, 0.26, 0.45]; $m->quad4([-0.04, 0.0, -0.18], [0.04, 0.0, -0.18], [0.13, -0.01, -0.44], [-0.13, -0.01, -0.44], [0, 1, 0]); $m->cell = Atlas::PLAIN; $m->color = [0.5, 0.4, 0.25]; foreach ([[7, 1], [8, -1]] as [$bn, $sd]) { $b->bone($bn, 0, $sd * 0.04, -0.06, 0.0); $m->skin($bn); $m->tube([[$sd * 0.04, -0.06, 0.0, 0.008], [$sd * 0.04, -0.16, 0.02, 0.005]], 3, 1.0); } return ['bird', 1.0, 0.1]; } /** @return array{0: string, 1: float, 2: float} */ private static function swarm(Build $b): array { // twelve groups of buzzing specks; each bone turns its group about the swarm's centre $m = $b->m; $m->cell = Atlas::PLAIN; for ($g = 0; $g < 12; $g++) { $b->bone($g, -1, 0, 1.0, 0); $m->skin($g); for ($k = 0; $k < 5; $k++) { $r = 0.3 + Mesh::hash($g, $k) * 0.9; $y = 0.6 + Mesh::hash($g + 50, $k) * 0.9; $a = Mesh::hash($g + 99, $k) * 6.28; $m->color = [0.08, 0.08, 0.06]; $m->ellipsoid(cos($a) * $r, $y, sin($a) * $r, 0.022, 0.016, 0.03, 2, 3); $m->color = [0.7, 0.75, 0.8]; $m->quad4([cos($a) * $r - 0.03, $y + 0.012, sin($a) * $r], [cos($a) * $r + 0.03, $y + 0.012, sin($a) * $r], [cos($a) * $r + 0.03, $y + 0.014, sin($a) * $r - 0.02], [cos($a) * $r - 0.03, $y + 0.014, sin($a) * $r - 0.02], [0, 1, 0]); } } return ['swarm', 1.0, 0.0]; } // ---- bipeds ------------------------------------------------------------------------------------- /** @return array{0: string, 1: float, 2: float} */ private static function brute(Build $b): array { // a huge hunched beast of the glaciers: shaggy white fur, a dark leathery face, hands and feet, long arms $fur = [1.0, 1.0, 1.04]; $skin = [0.26, 0.23, 0.25]; self::apeBody($b, 1.55, $fur, $skin, false); return ['ape', 0.75, 0.42]; } /** @return array{0: string, 1: float, 2: float} */ private static function climber(Build $b): array { // a lanky tree-dweller that steals: rusty fur, a pale face mask, big eyes, very long arms, a ringed tail self::apeBody($b, 0.62, [0.62, 0.36, 0.2], [0.85, 0.72, 0.6], true); return ['ape', 1.3, 0.16]; } /** Ape-like bodies (brute, climber): biped skeleton, hunched, long arms. */ private static function apeBody(Build $b, float $k, array $fur, array $face, bool $tail): void { $m = $b->m; $y = fn (float $v): float => $v * $k; $b->bone(self::PELVIS, -1, 0, $y(0.95), 0); $b->bone(self::SPINE, self::PELVIS, 0, $y(1.05), 0); $b->bone(self::SKULL, self::SPINE, 0, $y(1.72), $y(0.05)); $m->cell = Atlas::FUR; $m->color = $fur; $m->sweep([ [0, $y(0.82), 0, $y(0.2), $y(0.17), self::PELVIS], [0, $y(1.0), 0, $y(0.3), $y(0.24), self::PELVIS], [0, $y(1.2), 0, $y(0.33), $y(0.27), self::PELVIS, self::SPINE, 0.6], [0, $y(1.42), 0.0, $y(0.42), $y(0.3), self::SPINE], [0, $y(1.62), -0.02 * $k, $y(0.46), $y(0.3), self::SPINE], [0, $y(1.76), 0.0, $y(0.28), $y(0.22), self::SPINE, self::SKULL, 0.3], ], 12); // the head: low brow, heavy jaw, a leathery face $m->skin(self::SKULL); $m->ellipsoid(0, $y(1.84), $y(0.05), $y(0.2), $y(0.19), $y(0.19), 5, 9, 0.05, 13); $m->cell = Atlas::SKIN; $m->color = $face; $m->ellipsoid(0, $y(1.8), $y(0.17), $y(0.14), $y(0.13), $y(0.09), 5, 8); $m->ellipsoid(0, $y(1.72), $y(0.19), $y(0.11), $y(0.07), $y(0.08), 4, 8); $m->color = [$face[0] * 0.5, $face[1] * 0.5, $face[2] * 0.5]; $m->ellipsoid(0, $y(1.89), $y(0.2), $y(0.14), $y(0.03), $y(0.05), 3, 7); foreach ([-1, 1] as $sd) { self::eye($m, $sd * $y(0.055), $y(1.85), $y(0.235), $y($tail ? 0.03 : 0.022), [$sd * 0.15, 0.0, 1.0], $tail ? [0.55, 0.35, 0.1] : [0.3, 0.6, 0.85]); } $m->cell = Atlas::FUR; $m->color = $fur; foreach ([[self::LUA, self::LFA, self::LHAND, 1], [self::RUA, self::RFA, self::RHAND, -1]] as [$ua, $fa, $hd, $sd]) { $b->bone($ua, self::SPINE, $sd * $y(0.4), $y(1.6), 0); $b->bone($fa, $ua, $sd * $y(0.5), $y(1.08), $y(0.05)); $b->bone($hd, $fa, $sd * $y(0.55), $y(0.5), $y(0.1)); $m->color = $fur; $m->sweep([ [$sd * $y(0.36), $y(1.66), 0, $y(0.17), $y(0.17), $ua], [$sd * $y(0.46), $y(1.35), $y(0.02), $y(0.15), $y(0.14), $ua], [$sd * $y(0.5), $y(1.08), $y(0.05), $y(0.12), $y(0.12), $ua, $fa, 0.5], [$sd * $y(0.53), $y(0.8), $y(0.08), $y(0.12), $y(0.11), $fa], [$sd * $y(0.55), $y(0.55), $y(0.1), $y(0.09), $y(0.09), $fa, $hd, 0.4], ], 9); $m->cell = Atlas::SKIN; $m->color = $face; $m->skin($hd); $m->ellipsoid($sd * $y(0.56), $y(0.42), $y(0.12), $y(0.09), $y(0.13), $y(0.08), 4, 6); foreach ([-1, 0, 1] as $f) { $m->tube([[$sd * $y(0.56) + $f * $y(0.035), $y(0.33), $y(0.14), $y(0.022)], [$sd * $y(0.56) + $f * $y(0.035), $y(0.24), $y(0.16), $y(0.016)]], 4, 1.0); } $m->cell = Atlas::FUR; } foreach ([[self::LTH, self::LSH, self::LFOOT, 1], [self::RTH, self::RSH, self::RFOOT, -1]] as [$th, $sh, $ft, $sd]) { $b->bone($th, self::PELVIS, $sd * $y(0.2), $y(0.92), 0); $b->bone($sh, $th, $sd * $y(0.22), $y(0.5), $y(0.04)); $b->bone($ft, $sh, $sd * $y(0.22), $y(0.1), 0); $m->color = $fur; $m->sweep([ [$sd * $y(0.2), $y(0.95), 0, $y(0.19), $y(0.19), $th], [$sd * $y(0.22), $y(0.7), $y(0.02), $y(0.16), $y(0.16), $th], [$sd * $y(0.22), $y(0.5), $y(0.04), $y(0.13), $y(0.13), $th, $sh, 0.5], [$sd * $y(0.22), $y(0.28), $y(0.02), $y(0.12), $y(0.12), $sh], [$sd * $y(0.22), $y(0.12), 0, $y(0.1), $y(0.1), $sh, $ft, 0.4], ], 9); $m->cell = Atlas::SKIN; $m->color = $face; $m->skin($ft); $m->ellipsoid($sd * $y(0.22), $y(0.06), $y(0.1), $y(0.1), $y(0.06), $y(0.2), 3, 7, 0.0, 1, 0.3); $m->cell = Atlas::FUR; } if ($tail) { $b->bone(self::BTAIL1, self::PELVIS, 0, $y(0.95), -$y(0.15)); $b->bone(self::BTAIL2, self::BTAIL1, 0, $y(0.6), -$y(0.55)); $secs = []; for ($i = 0; $i <= 10; $i++) { $t = $i / 10; $secs[] = [0, $y(0.95 - 0.6 * $t + 0.5 * $t * $t * $t), -$y(0.15 + 0.9 * $t), $y(0.06 * (1 - 0.6 * $t)), $y(0.06 * (1 - 0.6 * $t)), $t < 0.5 ? self::BTAIL1 : self::BTAIL2, $t > 0.35 && $t < 0.65 ? ($t < 0.5 ? self::BTAIL2 : self::BTAIL1) : -1, 0.4, $i % 2 ? [0.25, 0.15, 0.1] : $fur]; } $m->sweep($secs, 7); } $m->color = [1.0, 1.0, 1.0]; } /** * A human: proportioned body, a face (eyes, brows, nose, lips, ears), hair, clothes of the faction, an item in * the right hand. $variant (0..7) changes sex, skin, hair, build and garment colours. * @return array{0: string, 1: float, 2: float} */ private static function human(Build $b, string $faction, bool $child, int $variant, ?string $held): array { $m = $b->m; $female = $variant % 2 === 1; $tones = [[0.84, 0.6, 0.45], [0.66, 0.44, 0.31], [0.47, 0.31, 0.21], [0.95, 0.74, 0.6]]; $hairs = [[0.08, 0.06, 0.05], [0.25, 0.15, 0.08], [0.45, 0.3, 0.16], [0.12, 0.09, 0.07], [0.6, 0.58, 0.55]]; $skin = match ($faction) { 'haldi' => $tones[($variant >> 1) % 3], 'ouvi' => $tones[1 + (($variant >> 1) % 2)], 'colonist' => $tones[3 - (($variant >> 1) % 2) * 3], default => $tones[$variant % 4], }; $hair = $faction === 'hermit' ? $hairs[4 - ($variant & 1)] : $hairs[($variant >> 1) % 4]; // garments: top, legs, accent, shoes; cells [$top, $legs, $accent, $shoes, $topCell, $legCell] = match ($faction) { 'haldi' => [[[1.15, 0.86, 0.6], [0.9, 1.0, 1.05], [1.1, 0.95, 0.8]][$variant % 3], [0.52, 0.4, 0.3], [0.2, 0.5, 0.52], [0.36, 0.24, 0.15], Atlas::PATTERN, Atlas::FABRIC], 'rodeur' => [[0.42, 0.3, 0.22], [0.24, 0.22, 0.2], [0.62, 0.14, 0.1], [0.16, 0.13, 0.11], Atlas::LEATHER, Atlas::FABRIC], 'ouvi' => [$skin, [0.82, 0.66, 0.42], [0.9, 0.86, 0.78], $skin, Atlas::PLAIN, Atlas::THATCH], 'hermit' => [[0.42, 0.38, 0.32], [0.36, 0.32, 0.26], [0.3, 0.26, 0.2], $skin, Atlas::FABRIC, Atlas::FABRIC], 'colonist' => [[0.5, 0.58, 0.66], [0.42, 0.48, 0.55], [1.2, 0.55, 0.2], [0.18, 0.17, 0.16], Atlas::FABRIC, Atlas::FABRIC], default => [[0.55, 0.55, 0.6], [0.32, 0.32, 0.35], [0.6, 0.6, 0.6], [0.2, 0.18, 0.16], Atlas::FABRIC, Atlas::FABRIC], }; $build = 1.0 + (Mesh::hash($variant, 7) - 0.5) * 0.12; $thin = $faction === 'hermit' ? 0.85 : 1.0; $sh = ($female ? 0.85 : 1.0) * $build * $thin; // shoulder width $hip = ($female ? 1.12 : 1.0) * $thin; $hk = $child ? 1.28 : 1.0; // head size (children: bigger heads) // heights: the body below the neck shrinks for a child (then scaled down by Graphics) $L = $child ? 0.9 : ($female ? 0.96 : 1.0); $y = fn (float $v): float => $v * $L; $b->bone(self::PELVIS, -1, 0, $y(0.98), 0); $b->bone(self::SPINE, self::PELVIS, 0, $y(1.08), 0); $b->bone(self::SKULL, self::SPINE, 0, $y(1.52), 0); $b->bone(self::CLOTH, self::PELVIS, 0, $y(1.0), 0); // ---- torso (the top garment) and hips: a tapered trunk (hips, waist, rib cage, chest), its top sloping from the // shoulders up to the neck (the trapezius) instead of a flat ledge; the round deltoids come with the arms $m->cell = $topCell; $m->color = $top; $fem = $female && !$child; $chest = $fem ? 0.122 : 0.122; $bust = $fem ? 0.02 : 0.0; // the chest's forward swell (women: the bust, smooth) $waist = ($fem ? 0.122 : 0.138) * ($child ? 1.06 : 1.0) * $thin; $m->sweep([ [0, $y(0.86), 0.0, 0.142 * $hip, 0.104, self::PELVIS, -1, 0.0, $legs], [0, $y(0.95), -0.004, 0.168 * $hip, 0.118, self::PELVIS, -1, 0.0, $legs], [0, $y(1.03), 0.0, 0.156 * $hip, 0.112, self::PELVIS, self::SPINE, 0.3, $top], [0, $y(1.1), 0.006, $waist * max(1.0, $sh), 0.103, self::PELVIS, self::SPINE, 0.6], [0, $y(1.18), 0.01, 0.147 * $sh, 0.108, self::PELVIS, self::SPINE, 0.85], [0, $y(1.25), 0.014 + $bust * 0.4, 0.158 * $sh, $chest * 0.97 + $bust * 0.5, self::SPINE], [0, $y(1.31), 0.016 + $bust, 0.168 * $sh, $chest + $bust, self::SPINE], [0, $y(1.36), 0.014 + $bust * 0.6, 0.176 * $sh, $chest * 0.98 + $bust * 0.5, self::SPINE], [0, $y(1.4), 0.008, 0.196 * $sh, $chest * 0.92, self::SPINE], // the shoulders: the trunk's top widens over the joints, then slopes to the neck [0, $y(1.432), 0.002, 0.212 * $sh, 0.104, self::SPINE], [0, $y(1.462), -0.004, 0.196 * $sh, 0.094, self::SPINE], [0, $y(1.49), -0.008, 0.148 * $sh, 0.08, self::SPINE], [0, $y(1.513), -0.009, 0.1, 0.068, self::SPINE], [0, $y(1.535), -0.007, 0.07, 0.058, self::SPINE], ], 16); // neck: wide where it leaves the shoulders, slimmer under the jaw, leaning a little forward $m->cell = Atlas::PLAIN; $m->color = $skin; $m->sweep([[0, $y(1.49), -0.012, 0.072, 0.064, self::SPINE], [0, $y(1.53), -0.002, 0.058, 0.056, self::SPINE, self::SKULL, 0.3], [0, $y(1.57), 0.008, 0.052, 0.052, self::SPINE, self::SKULL, 0.7], [0, $y(1.61), 0.014, 0.05, 0.05, self::SKULL]], 10); // ---- head $hy = $y(1.5) + 0.17 * $hk; $m->skin(self::SKULL); $hs = $hk * ($female ? 0.96 : 1.0); // one smooth head: sections from the chin to the crown, the face forward of the skull $hsec = []; foreach ([[-0.118, 0.012, 0.014, 0.05], [-0.108, 0.032, 0.036, 0.046], [-0.085, 0.056, 0.064, 0.026], [-0.055, 0.067, 0.083, 0.014], [-0.025, 0.074, 0.093, 0.008], [0.01, 0.079, 0.098, 0.0], [0.045, 0.081, 0.1, -0.006], [0.075, 0.075, 0.094, -0.012], [0.1, 0.056, 0.072, -0.016], [0.117, 0.024, 0.032, -0.018], [0.122, 0.004, 0.006, -0.018]] as [$dy, $rx, $rz, $dz]) { $hsec[] = [0, $hy + $dy * $hs, $dz * $hs, $rx * $hs, $rz * $hs, self::SKULL]; } $m->sweep($hsec, 14); // nose: a bridge widening to a rounded tip $m->sweep([[0, $hy + 0.012 * $hs, 0.086 * $hs, 0.008 * $hs, 0.006 * $hs, self::SKULL], [0, $hy - 0.012 * $hs, 0.098 * $hs, 0.01 * $hs, 0.01 * $hs, self::SKULL], [0, $hy - 0.026 * $hs, 0.104 * $hs, 0.014 * $hs, 0.012 * $hs, self::SKULL], [0, $hy - 0.034 * $hs, 0.098 * $hs, 0.012 * $hs, 0.008 * $hs, self::SKULL], [0, $hy - 0.037 * $hs, 0.09 * $hs, 0.006 * $hs, 0.004 * $hs, self::SKULL]], 8); // ears foreach ([-1, 1] as $sd) { $m->ellipsoid($sd * 0.084 * $hs, $hy - 0.005 * $hs, -0.005, 0.012 * $hs, 0.027 * $hs, 0.019 * $hs, 3, 6); } // lips $m->color = [$skin[0] * 0.95, $skin[1] * 0.62, $skin[2] * 0.6]; $m->tube([[-0.02 * $hs, $hy - 0.054 * $hs, 0.088 * $hs, 0.004 * $hs], [0, $hy - 0.052 * $hs, 0.097 * $hs, 0.006 * $hs], [0.02 * $hs, $hy - 0.054 * $hs, 0.088 * $hs, 0.004 * $hs]], 5, 1.0); // eyes, brows $iris = [[0.25, 0.15, 0.08], [0.2, 0.35, 0.45], [0.3, 0.32, 0.15], [0.15, 0.1, 0.06]][($variant >> 1) % 4]; foreach ([-1, 1] as $sd) { self::eye($m, $sd * 0.032 * $hs, $hy + 0.012 * $hs, 0.079 * $hs, 0.013 * $hs, [$sd * 0.05, 0.0, 1.0], $iris); $m->cell = Atlas::PLAIN; $m->color = [$hair[0] * 0.8, $hair[1] * 0.8, $hair[2] * 0.8]; $m->tube([[$sd * 0.012 * $hs, $hy + 0.034 * $hs, 0.097 * $hs, 0.004 * $hs], [$sd * 0.034 * $hs, $hy + 0.039 * $hs, 0.094 * $hs, 0.005 * $hs], [$sd * 0.054 * $hs, $hy + 0.034 * $hs, 0.083 * $hs, 0.003 * $hs]], 4, 1.0); $m->cell = Atlas::PLAIN; } // ---- hair self::hair($m, $faction, $variant, $female, $child, $hair, $hy, $hs); // ---- arms: a round deltoid capping the shoulder (blending the trunk into the arm), biceps, a slight bend at // the elbow, the forearm's swell, a slim wrist; the arms hang a little forward and clear of the hips foreach ([[self::LUA, self::LFA, self::LHAND, 1], [self::RUA, self::RFA, self::RHAND, -1]] as [$ua, $fa, $hd, $sd]) { $sx = 0.2 * $sh; $hx = max($sx + 0.05, 0.168 * $hip + 0.065); // the hand clears the hip $ex = $sx + 0.03 + ($hx - $sx - 0.05) * 0.4; // the elbow, between $b->bone($ua, self::SPINE, $sd * $sx, $y(1.43), 0); $b->bone($fa, $ua, $sd * $ex, $y(1.15), -0.005); $b->bone($hd, $fa, $sd * $hx, $y(0.88), 0.03); $sleeve = match ($faction) { 'ouvi' => $skin, 'rodeur' => $variant & 2 ? $skin : $top, 'haldi' => $female ? $top : $skin, default => $top }; $fore = in_array($faction, ['colonist', 'hermit'], true) ? $top : $skin; $m->cell = $sleeve === $skin ? Atlas::PLAIN : $topCell; $m->color = $sleeve; $k = $fem ? 0.88 : ($thin < 1 ? 0.9 : 1.0); // the deltoid: the arm grows out from under the shoulder's dome, round, then narrows to the biceps $m->sweep([ [$sd * ($sx - 0.024), $y(1.462), -0.004, 0.022, 0.024, self::SPINE, $ua, 0.5, $sleeve], [$sd * ($sx - 0.002), $y(1.44), -0.004, 0.046 * $k, 0.052 * $k, self::SPINE, $ua, 0.75], [$sd * ($sx + 0.012), $y(1.4), -0.002, 0.057 * $k, 0.062 * $k, $ua], [$sd * ($sx + 0.016), $y(1.35), 0.0, 0.053 * $k, 0.058 * $k, $ua], [$sd * ($sx + 0.02), $y(1.29), 0.004, 0.047 * $k, 0.053 * $k, $ua], [$sd * ($sx + 0.026), $y(1.21), 0.0, 0.041 * $k, 0.044 * $k, $ua], [$sd * $ex, $y(1.15), -0.008, 0.038 * $k, 0.04 * $k, $ua, $fa, 0.5, $fore], [$sd * ($ex + ($hx - $ex) * 0.3), $y(1.08), 0.004, 0.043 * $k, 0.041 * $k, $fa], [$sd * ($ex + ($hx - $ex) * 0.65), $y(0.99), 0.018, 0.034 * $k, 0.03 * $k, $fa], [$sd * ($hx - 0.002), $y(0.93), 0.026, 0.028 * $k, 0.022 * $k, $fa, -1, 0.0, $skin], [$sd * $hx, $y(0.885), 0.03, 0.027 * $k, 0.021 * $k, $fa, $hd, 0.6], ], 9); // the hand: palm toward the thigh, fingers curled a little, a thumb forward $m->cell = Atlas::PLAIN; $m->color = $skin; $m->skin($hd); $m->sweep([ [$sd * $hx, $y(0.875), 0.032, 0.02 * $k, 0.036 * $k, $hd], [$sd * ($hx + 0.002), $y(0.835), 0.034, 0.019 * $k, 0.042 * $k, $hd], [$sd * ($hx + 0.001), $y(0.79), 0.04, 0.016 * $k, 0.038 * $k, $hd], [$sd * ($hx - 0.004), $y(0.765), 0.05, 0.013 * $k, 0.026 * $k, $hd], [$sd * ($hx - 0.008), $y(0.757), 0.058, 0.008 * $k, 0.012 * $k, $hd], ], 8); $m->tube([[$sd * ($hx - 0.008), $y(0.86), 0.06, 0.011 * $k], [$sd * ($hx - 0.016), $y(0.83), 0.075, 0.0095 * $k], [$sd * ($hx - 0.02), $y(0.805), 0.079, 0.008 * $k]], 5, 1.0, true); } // ---- legs foreach ([[self::LTH, self::LSH, self::LFOOT, 1], [self::RTH, self::RSH, self::RFOOT, -1]] as [$th, $shn, $ft, $sd]) { $lx = 0.09 * $hip; $b->bone($th, self::PELVIS, $sd * $lx, $y(0.93), 0); $b->bone($shn, $th, $sd * $lx, $y(0.5), 0.01); $b->bone($ft, $shn, $sd * $lx, $y(0.08), 0.0); $bare = in_array($faction, ['ouvi', 'hermit'], true) || ($faction === 'haldi' && $female); $low = $bare ? $skin : $legs; $m->cell = $low === $skin && $faction === 'ouvi' ? Atlas::PLAIN : $legCell; $m->color = $legs; $knee = $faction === 'ouvi' ? $skin : $legs; $m->sweep([ [$sd * $lx, $y(0.95), 0.0, 0.088 * $hip, 0.092, $th, -1, 0.0, $faction === 'ouvi' ? $skin : $legs], [$sd * $lx, $y(0.84), 0.008, 0.08 * $hip, 0.084, $th], [$sd * $lx, $y(0.7), 0.008, 0.066, 0.07, $th], [$sd * $lx, $y(0.56), 0.012, 0.05, 0.053, $th, $shn, 0.5, $knee], [$sd * $lx, $y(0.47), 0.002, 0.048, 0.054, $shn, -1, 0.0, $low], [$sd * $lx, $y(0.38), -0.01, 0.051, 0.06, $shn], [$sd * $lx, $y(0.26), -0.006, 0.039, 0.045, $shn], [$sd * $lx, $y(0.15), -0.002, 0.031, 0.035, $shn], [$sd * $lx, $y(0.09), 0.0, 0.03, 0.032, $shn, $ft, 0.5], ], 9); // feet: boots, sandals or bare $m->skin($ft); $m->cell = $bare ? Atlas::PLAIN : Atlas::LEATHER; $m->color = $bare ? $skin : $shoes; $fl = $child ? 0.85 : 1.0; $m->sweep([ [$sd * $lx, $y(0.05), -0.05 * $fl, 0.036, 0.04, $ft], [$sd * $lx, $y(0.045), 0.02 * $fl, 0.045, 0.045, $ft], [$sd * $lx, $y(0.035), 0.1 * $fl, 0.045, 0.032, $ft], [$sd * $lx, $y(0.03), 0.15 * $fl, 0.025, 0.02, $ft], ], 8); } // ---- faction details self::garments($b, $faction, $variant, $female, $child, $top, $legs, $accent, $skin, $y, $sh, $hip, $hy, $hs); // ---- the item in the right hand if ($held !== null && !$child) { $item = Models::item($held); [$rx, $ry, $rz, $off] = Models::npcGrip($held); $m->push()->translate(-(max(0.2 * $sh + 0.05, 0.168 * $hip + 0.065) - 0.004), $y(0.8), 0.06)->rotate('x', $rx)->rotate('y', $ry)->rotate('z', $rz)->translate(0, $off, 0); $m->skin(self::RHAND); $m->color = [1.0, 1.0, 1.0]; $m->sway = 0.0; $m->append($item, true); $m->pop(); } $m->color = [1.0, 1.0, 1.0]; return ['biped', $child ? 1.25 : 1.0, 0.13]; } /** @param array{0: float, 1: float, 2: float} $hair */ private static function hair(Mesh $m, string $faction, int $variant, bool $female, bool $child, array $hair, float $hy, float $hs): void { $m->skin(self::SKULL); $m->cell = Atlas::FUR; $m->color = $hair; $style = $faction === 'hermit' ? 3 : ($female ? 1 + ($variant >> 2) % 2 : ($variant >> 2) % 2 * 2); if ($faction === 'colonist' || ($faction === 'rodeur' && !$female)) { $style = 0; } // a cap of hair over the skull (all styles but bald-ish) $m->push()->translate(0, $hy + 0.03 * $hs, -0.02 * $hs)->rotate('x', -0.3); $m->ellipsoid(0, 0, 0, 0.091 * $hs, 0.106 * $hs, 0.112 * $hs, 6, 10, 0.03, 7 + $variant, 0.2); $m->pop(); if ($style === 1 || $style === 3) { // long hair: strands down the back (hair cards, alpha) $m->cell = Atlas::HAIR; $len = $style === 3 ? 0.42 : ($child ? 0.22 : 0.34); $n = $style === 3 ? 14 : 9; for ($k = 0; $k < $n; $k++) { $a = M_PI * (0.12 + 0.76 * $k / ($n - 1)); $x = cos($a) * 0.085 * $hs; $z = -sin($a) * 0.09 * $hs + 0.01; $w = 0.07 * $hs; $top = $hy + 0.05 * $hs; $wild = $style === 3 ? (Mesh::hash($variant, $k) - 0.5) * 0.25 : 0.0; $out = $style === 3 ? 0.08 : 0.02; $m->quad4([$x - $w * sin($a) * 0.5, $top, $z - $w * cos($a) * 0.5], [$x + $w * sin($a) * 0.5, $top, $z + $w * cos($a) * 0.5], [$x * (1.4 + $out * 10) + $w * sin($a) * 0.6 + $wild, $top - $len, $z * 1.5 + $w * cos($a) * 0.6 - $out], [$x * (1.4 + $out * 10) - $w * sin($a) * 0.6 + $wild, $top - $len, $z * 1.5 - $w * cos($a) * 0.6 - $out], [cos($a), 0.0, -sin($a)], 0.0, 0.0, 1.0, 1.0); } } if ($style === 2) { // a short crest / bun on top $m->ellipsoid(0, $hy + 0.1 * $hs, -0.05 * $hs, 0.045 * $hs, 0.04 * $hs, 0.05 * $hs, 4, 7, 0.08, 3); } if (!$female && !$child && ($style === 3 || ($faction === 'rodeur' && ($variant & 2)) || ($faction === 'haldi' && $variant >= 6))) { // a beard $m->cell = Atlas::FUR; $m->color = $hair; $long = $style === 3 ? 1.0 : 0.4; $m->ellipsoid(0, $hy - 0.07 * $hs - 0.04 * $long, 0.055 * $hs, 0.06 * $hs, (0.04 + 0.06 * $long) * $hs, 0.04 * $hs, 4, 8, 0.12, 9 + $variant); $m->tube([[-0.03 * $hs, $hy - 0.03 * $hs, 0.087 * $hs, 0.008], [0, $hy - 0.035 * $hs, 0.094 * $hs, 0.009], [0.03 * $hs, $hy - 0.03 * $hs, 0.087 * $hs, 0.008]], 4, 1.0); } $m->color = [1.0, 1.0, 1.0]; } /** Clothing details per faction (belts, skirts, coats, masks, paint, ornaments). */ private static function garments(Build $b, string $faction, int $variant, bool $female, bool $child, array $top, array $legs, array $accent, array $skin, \Closure $y, float $sh, float $hip, float $hy, float $hs): void { $m = $b->m; // a belt $m->cell = Atlas::LEATHER; $m->color = $faction === 'colonist' ? [0.2, 0.2, 0.2] : [0.35, 0.22, 0.14]; $m->skin(self::PELVIS); $m->sweep([[0, $y(0.99), 0.0, 0.17 * $hip, 0.12, self::PELVIS], [0, $y(1.03), 0.0, 0.165 * $hip, 0.117, self::PELVIS]], 12); switch ($faction) { case 'haldi': // a woven tunic skirt / a long dress, a shawl, bead necklace $m->cell = Atlas::PATTERN; $m->color = $top; $low = $female ? $y(0.3) : $y(0.68); $m->sweep([[0, $y(1.0), 0.0, 0.175 * $hip, 0.125, self::PELVIS], [0, ($y(1.0) + $low) / 2, 0.0, 0.2 * $hip + 0.02, 0.15, self::PELVIS, self::CLOTH, 0.6], [0, $low, 0.0, 0.23 * $hip + ($female ? 0.06 : 0.0), 0.18, self::CLOTH]], 12); $m->cell = Atlas::PLAIN; $m->skin(self::SPINE); for ($k = 0; $k < 11; $k++) { $a = M_PI * (0.15 + 0.7 * $k / 10); $m->color = $k % 2 ? $accent : [1.2, 0.95, 0.4]; $m->ellipsoid(cos($a) * 0.088 * $sh, $y(1.475) - sin($a) * 0.05, sin($a) * 0.098 + 0.03, 0.011, 0.011, 0.011, 2, 4); } // a headband of beads $m->skin(self::SKULL); $m->color = $accent; $m->sweep([[0, $hy + 0.035 * $hs, -0.01, 0.091 * $hs, 0.1 * $hs, self::SKULL], [0, $hy + 0.05 * $hs, -0.012, 0.09 * $hs, 0.099 * $hs, self::SKULL]], 10); if ($variant === 5 || $variant === 7) { // an elder's shawl over the shoulders $m->cell = Atlas::PATTERN; $m->color = [0.8, 0.45, 0.3]; $m->skin(self::SPINE); $m->sweep([[0, $y(1.53), -0.008, 0.085, 0.07, self::SPINE], [0, $y(1.495), -0.006, 0.17 * $sh, 0.1, self::SPINE], [0, $y(1.445), 0.0, 0.25 * $sh, 0.13, self::SPINE], [0, $y(1.36), 0.006, 0.245 * $sh, 0.145, self::SPINE], [0, $y(1.27), 0.008, 0.215 * $sh, 0.14, self::SPINE]], 14); } break; case 'rodeur': // scrap armour: a rusty shoulder plate, a hood and a face cloth $m->cell = Atlas::RUST; $m->color = [1.0, 0.9, 0.85]; $m->skin(self::LUA); $m->push()->translate(0.205 * $sh, $y(1.455), -0.004)->rotate('z', -0.55); $m->ellipsoid(0, 0, 0, 0.085, 0.032, 0.088, 3, 9, 0.05, 3, 0.2); $m->pop(); $m->skin(self::SPINE); $m->cell = Atlas::METAL; $m->color = [0.6, 0.55, 0.5]; $m->box(0.05, $y(1.28), 0.13, 0.12, 0.1, 0.02); $m->cell = Atlas::FABRIC; $m->color = [0.32, 0.28, 0.24]; $m->skin(self::SKULL); $m->ellipsoid(0, $hy - 0.055 * $hs, 0.035 * $hs, 0.074 * $hs, 0.05 * $hs, 0.072 * $hs, 4, 9); if ($variant & 1) { $m->color = [0.3, 0.26, 0.22]; $m->push()->translate(0, $hy + 0.02 * $hs, -0.02 * $hs)->rotate('x', -0.2); $m->ellipsoid(0, 0, 0, 0.105 * $hs, 0.12 * $hs, 0.12 * $hs, 5, 9, 0.02, 1, 0.1); $m->pop(); } // a cape $m->cell = Atlas::FABRIC; $m->color = [0.28, 0.24, 0.2]; $m->skin(self::SPINE, self::CLOTH, 0.0); $m->quad4([-0.16 * $sh, $y(1.475), -0.1], [0.16 * $sh, $y(1.475), -0.1], [0.27, $y(0.72), -0.2], [-0.27, $y(0.72), -0.2], [0, 0, -1]); break; case 'ouvi': // a fibre wrap at the hips, white body paint, a feather headband, a necklace of teeth $m->cell = Atlas::THATCH; $m->color = [0.9, 0.75, 0.5]; $m->sweep([[0, $y(1.02), 0.0, 0.17 * $hip, 0.12, self::PELVIS], [0, $y(0.84), 0.0, 0.2 * $hip, 0.15, self::PELVIS, self::CLOTH, 0.5], [0, $y(0.68), 0.0, 0.21 * $hip, 0.16, self::CLOTH]], 12); if ($female && !$child) { $m->cell = Atlas::PATTERN; $m->color = [0.9, 0.55, 0.4]; $m->skin(self::SPINE); $m->sweep([[0, $y(1.22), 0.012, 0.165 * $sh, 0.14, self::SPINE], [0, $y(1.36), 0.01, 0.185 * $sh, 0.13, self::SPINE]], 12); } $m->cell = Atlas::PLAIN; $m->color = [0.95, 0.92, 0.85]; $m->skin(self::SPINE); foreach ([1.18, 1.24] as $yy) { $m->sweep([[0, $y($yy), 0.007, 0.152 * $sh, 0.112, self::SPINE], [0, $y($yy) + 0.015, 0.008, 0.155 * $sh, 0.115, self::SPINE]], 12); } foreach ([[self::LUA, 1], [self::RUA, -1]] as [$bn, $sd]) { $m->skin($bn); $m->sweep([[$sd * (0.2 * $sh + 0.022), $y(1.3), 0.0, 0.052, 0.054, $bn], [$sd * (0.2 * $sh + 0.024), $y(1.28), 0.0, 0.052, 0.054, $bn]], 8); } $m->skin(self::SKULL); $m->color = [0.95, 0.92, 0.85]; foreach ([-1, 1] as $sd) { $m->tube([[$sd * 0.07 * $hs, $hy, 0.055 * $hs, 0.006], [$sd * 0.045 * $hs, $hy - 0.035 * $hs, 0.075 * $hs, 0.006]], 3, 1.0); } $m->cell = Atlas::PATTERN; $m->color = [1.0, 0.6, 0.35]; $m->sweep([[0, $hy + 0.03 * $hs, -0.01, 0.092 * $hs, 0.1 * $hs, self::SKULL], [0, $hy + 0.05 * $hs, -0.012, 0.091 * $hs, 0.099 * $hs, self::SKULL]], 10); $m->cell = Atlas::FEATHERS; foreach ([[0.0, [0.9, 0.3, 0.15]], [0.35, [0.15, 0.5, 0.7]], [-0.35, [1.0, 0.85, 0.3]]] as [$a, $c]) { $m->color = $c; $m->push()->translate(sin($a) * 0.05, $hy + 0.05 * $hs, -0.1 * $hs)->rotate('z', $a)->rotate('x', -0.3); $m->quad4([-0.018, 0.0, 0.0], [0.018, 0.0, 0.0], [0.02, 0.2, 0.0], [-0.02, 0.2, 0.0], [0, 0, -1]); $m->pop(); } $m->cell = Atlas::BONE; $m->color = [1.0, 0.95, 0.85]; $m->skin(self::SPINE); for ($k = 0; $k < 7; $k++) { $a = M_PI * (0.25 + 0.5 * $k / 6); $px = cos($a) * 0.08 * $sh; $pz = sin($a) * 0.08 + 0.025; $m->tube([[$px, $y(1.43), $pz, 0.008], [$px * 1.1, $y(1.38), $pz + 0.01, 0.002]], 3, 1.0); } break; case 'hermit': // rags: a tattered long coat, frayed hems (hair cards coloured as cloth), a rope belt $m->cell = Atlas::FABRIC; $m->color = [0.4, 0.36, 0.3]; $m->sweep([[0, $y(1.53), -0.008, 0.085, 0.072, self::SPINE], [0, $y(1.49), -0.006, 0.16 * $sh, 0.1, self::SPINE], [0, $y(1.43), 0.0, 0.215 * $sh, 0.125, self::SPINE], [0, $y(1.3), 0.008, 0.19 * $sh, 0.138, self::SPINE], [0, $y(1.15), 0.004, 0.17 * $sh, 0.13, self::SPINE, self::PELVIS, 0.5], [0, $y(1.0), 0.0, 0.19 * $hip, 0.14, self::PELVIS], [0, $y(0.75), 0.0, 0.22 * $hip, 0.17, self::PELVIS, self::CLOTH, 0.7]], 12); $m->cell = Atlas::HAIR; $m->color = [0.42, 0.37, 0.3]; $m->skin(self::CLOTH); for ($k = 0; $k < 12; $k++) { $a = $k / 12 * 2 * M_PI; $x = cos($a) * 0.22 * $hip; $z = sin($a) * 0.17; $m->quad4([$x - sin($a) * 0.07, $y(0.77), $z + cos($a) * 0.07], [$x + sin($a) * 0.07, $y(0.77), $z - cos($a) * 0.07], [$x * 1.08 + sin($a) * 0.07, $y(0.55), $z * 1.08 - cos($a) * 0.07], [$x * 1.08 - sin($a) * 0.07, $y(0.55), $z * 1.08 + cos($a) * 0.07], [cos($a), 0, sin($a)], 0.0, 0.0, 1.0, 1.0); } $m->cell = Atlas::ROPE; $m->color = [0.9, 0.85, 0.7]; $m->skin(self::PELVIS); $m->sweep([[0, $y(1.0), 0.0, 0.195 * $hip, 0.145, self::PELVIS], [0, $y(1.025), 0.0, 0.195 * $hip, 0.145, self::PELVIS]], 10); break; case 'colonist': // the old expedition uniform: collar, orange shoulder patches, chest pockets, a name tape $m->cell = Atlas::FABRIC; $m->color = [$top[0] * 0.8, $top[1] * 0.8, $top[2] * 0.8]; $m->skin(self::SPINE); $m->sweep([[0, $y(1.49), -0.01, 0.09, 0.076, self::SPINE], [0, $y(1.545), 0.0, 0.07, 0.064, self::SPINE]], 10); $m->box(0.07, $y(1.32), 0.134, 0.068, 0.07, 0.014); $m->box(-0.07, $y(1.32), 0.134, 0.068, 0.07, 0.014); $m->cell = Atlas::PLAIN; $m->color = $accent; foreach ([[self::LUA, 1], [self::RUA, -1]] as [$bn, $sd]) { $m->skin($bn); $m->push()->translate($sd * (0.2 * $sh + 0.064), $y(1.36), 0.0)->rotate('z', $sd * 0.2); $m->box(0, 0, 0, 0.012, 0.05, 0.05); $m->pop(); } $m->skin(self::SPINE); $m->color = [0.9, 0.9, 0.85]; $m->box(-0.07, $y(1.385), 0.13, 0.07, 0.015, 0.014); // a worn cap $m->cell = Atlas::FABRIC; $m->color = [$top[0] * 0.9, $top[1] * 0.9, $top[2] * 0.9]; $m->skin(self::SKULL); $m->ellipsoid(0, $hy + 0.055 * $hs, -0.005, 0.092 * $hs, 0.06 * $hs, 0.1 * $hs, 4, 9, 0.0, 1, 0.1); $m->push()->translate(0, $hy + 0.045 * $hs, 0.1 * $hs)->rotate('x', 0.15); $m->ellipsoid(0, 0, 0, 0.075 * $hs, 0.008, 0.05 * $hs, 2, 8); $m->pop(); break; } $m->color = [1.0, 1.0, 1.0]; } }