#include "render/figure.h" static const FigureLook WARDROBE[] = { { .skin = { 0.93f, 0.74f, 0.60f }, .hair = { 0.30f, 0.19f, 0.12f }, .shirt = { 0.86f, 0.42f, 0.32f }, .pants = { 0.24f, 0.30f, 0.48f }, .shoes = { 0.22f, 0.16f, 0.13f }, .height = 1.78f, .hair_style = HAIR_SHORT, .long_sleeves = false }, { .skin = { 0.72f, 0.52f, 0.38f }, .hair = { 0.12f, 0.10f, 0.10f }, .shirt = { 0.30f, 0.62f, 0.60f }, .pants = { 0.55f, 0.48f, 0.36f }, .shoes = { 0.32f, 0.22f, 0.16f }, .height = 1.70f, .hair_style = HAIR_LONG, .long_sleeves = true }, { .skin = { 0.96f, 0.80f, 0.68f }, .hair = { 0.86f, 0.66f, 0.36f }, .shirt = { 0.92f, 0.78f, 0.36f }, .pants = { 0.42f, 0.30f, 0.46f }, .shoes = { 0.85f, 0.82f, 0.74f }, .height = 1.66f, .hair_style = HAIR_LONG, .long_sleeves = false }, { .skin = { 0.50f, 0.34f, 0.24f }, .hair = { 0.08f, 0.07f, 0.08f }, .shirt = { 0.92f, 0.88f, 0.78f }, .pants = { 0.30f, 0.42f, 0.30f }, .shoes = { 0.18f, 0.14f, 0.14f }, .height = 1.82f, .hair_style = HAIR_SHORT, .long_sleeves = true }, { .skin = { 0.88f, 0.66f, 0.50f }, .hair = { 0.55f, 0.22f, 0.10f }, .shirt = { 0.56f, 0.40f, 0.72f }, .pants = { 0.20f, 0.22f, 0.26f }, .shoes = { 0.60f, 0.24f, 0.20f }, .height = 1.74f, .hair_style = HAIR_LONG, .long_sleeves = false }, }; /* Jackets for the night: denim, an olive parka, brown leather, a grey hoodie, a red rain jacket. */ static const Vec3 JACKETS[] = { { 0.24f, 0.33f, 0.52f }, { 0.36f, 0.40f, 0.22f }, { 0.42f, 0.26f, 0.16f }, { 0.55f, 0.55f, 0.57f }, { 0.62f, 0.16f, 0.15f } }; FigureLook Figure_wardrobe(int index) { const int n = (int)(sizeof(WARDROBE) / sizeof(WARDROBE[0])); FigureLook look = WARDROBE[((index % n) + n) % n]; look.jacket = JACKETS[((index % 5) + 5) % 5]; look.hoodie = index % 5 == 1 || index % 5 == 3 || index % 5 == 4; /* (the parka, the hoodie, the red rain jacket) */ switch (index) { /* hats (by who: world/cast.c): Toni a red cap, Kurti an old green one, Jonas a beanie, Kerry a grey one, Pascal a black cap */ case 3: look.hat = HAT_CAP; look.hat_color = vec3(0.72f, 0.13f, 0.12f); break; case 4: look.hat = HAT_CAP; look.hat_color = vec3(0.26f, 0.32f, 0.22f); break; case 6: look.hat = HAT_BEANIE; look.hat_color = vec3(0.20f, 0.28f, 0.46f); break; case 11: look.hat = HAT_BEANIE; look.hat_color = vec3(0.42f, 0.40f, 0.36f); break; case 13: look.hat = HAT_CAP; look.hat_color = vec3(0.12f, 0.12f, 0.13f); break; default: break; } return look; } static Vec3 rightOf(Vec3 facing) { return vec3_normalize(vec3_cross(facing, vec3(0, 1, 0))); } Vec3 Figure_toWorld(Vec3 position, Vec3 facing, Vec3 local) { Vec3 r = rightOf(facing); return vec3_add(position, vec3_add(vec3_add(vec3_scale(r, local.x), vec3(0, local.y, 0)), vec3_scale(facing, local.z))); } Vec3 Figure_toLocal(Vec3 position, Vec3 facing, Vec3 world) { Vec3 d = vec3_sub(world, position); return vec3(vec3_dot(d, rightOf(facing)), d.y, vec3_dot(d, facing)); }