X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2Fcreature.cpp;h=1196a3c8ca0341200cf2fe9ec26f3c36afbc5b79;hp=6c9fb8596680e496804b6f3174a855ed6992164c;hb=5b2ab168a9b3c05082bd9cd924f548bc90fc8efa;hpb=f59ca070e1146a3afc5ae11df327dc4cdea1fc8c diff --git a/src/creature/creature.cpp b/src/creature/creature.cpp index 6c9fb85..1196a3c 100644 --- a/src/creature/creature.cpp +++ b/src/creature/creature.cpp @@ -322,6 +322,9 @@ void Spawn(Creature &c, world::Planet &p) { genome.properties.Death().mass = { 0.9, 0.05 }; genome.properties.Death().fertility = { 0.0, 0.0 }; + glm::dvec3 color_avg(0.0); + double color_divisor = 0.0; + if (p.HasAtmosphere()) { genome.composition.push_back({ p.Atmosphere(), // resource @@ -330,6 +333,8 @@ void Spawn(Creature &c, world::Planet &p) { { 0.1, 0.0005 }, // penalty { 0.0, 0.0 }, // growth }); + color_avg += c.GetSimulation().Resources()[p.Atmosphere()].base_color; + color_divisor += 0.1; } if (liquid > -1) { genome.composition.push_back({ @@ -339,17 +344,28 @@ void Spawn(Creature &c, world::Planet &p) { { 0.01, 0.002 }, // penalty { 0.1, 0.0 }, // growth }); + color_avg += c.GetSimulation().Resources()[liquid].base_color; + color_divisor += 0.5; } if (solid > -1) { genome.composition.push_back({ solid, // resource { 0.4, 0.01 }, // mass - //{ 0.1, 0.001 }, // intake { 0.4, 0.001 }, // intake { 0.001, 0.0001 }, // penalty { 10.0, 0.002 }, // growth }); + color_avg += c.GetSimulation().Resources()[solid].base_color; + color_divisor += 1.0; + } + + if (color_divisor > 0.001) { + color_avg /= color_divisor; } + glm::dvec3 hsl = rgb2hsl(color_avg); + genome.base_hue = { hsl.x, 0.01 }; + genome.base_saturation = { hsl.y, 0.01 }; + genome.base_lightness = { hsl.z, 0.01 }; genome.Configure(c); }