private void Form_Animal(animal_object animal, float bodySize, float greediness, int seed) { // // give appropriate name // int d0 = UnityEngine.Random.Range(0, adjectives.Length); // int d1 = (int)(bodySize*.999f * nounsConsumer.Length); // int d2 = UnityEngine.Random.Range(0, nounsConsumer[d1].Length); // animal.name = adjectives[d0] + " " + nounsConsumer[d1][d2]; animal.name = name_generator.GetName6(seed); // assign mesh animal.Renderer.sharedMesh = Consumer_Meshs[(int)(bodySize * .999f * Consumer_Meshs.Length)]; // generate texture and material // var yuv = new Vector3(.8f-.5f*bodySize, .4f, .8f*greediness-.4f); // // convert yuv to rgb // Color rgb = (Vector4)(AnimalTexture.yuv_to_rgb.MultiplyVector(yuv)) + new Vector4(0,0,0,1); // // scale mesh animal.transform.localScale = Vector3.one;// * (1+bodySize*.1f); // var lab = new LABColor(70-50*bodySize, 10+40*greediness, -50); float L = 70 - 50 * bodySize; var lab1 = new LABColor(L, 50, -80); var lab2 = new LABColor(L, 30, 20); var lab = LABColor.Lerp(lab1, lab2, greediness); Color rgb = lab.ToColor(); Generate_and_Apply(animal, seed, rgb); }
private void Form_Plant(animal_object plant, float bodySize, float greediness, int seed) { // give appropriate name // int d0 = UnityEngine.Random.Range(0, adjectives.Length); // int d1 = (int)(bodySize*.999f * nounsProducer.Length); // int d2 = UnityEngine.Random.Range(0, nounsProducer[d1].Length); // plant.name = adjectives[d0] + " " + nounsProducer[d1][d2]; plant.name = name_generator.GetName1(seed); // assign mesh plant.Renderer.sharedMesh = Producer_Meshs[(int)(bodySize * .999f * Producer_Meshs.Length)]; // generate texture and material // var yuv = new Vector3(.7f-.7f*bodySize, -.4f, .8f*greediness-.4f); // Color rgb = (Vector4)(AnimalTexture.yuv_to_rgb.MultiplyVector(yuv)) + new Vector4(0,0,0,1); // // scale mesh plant.transform.localScale = Vector3.one;// * (1+bodySize*.1f); // var lab = new LABColor(80-50*bodySize, -50+40*greediness, 50); float L = 80 - 50 * bodySize; var lab1 = new LABColor(L, -50, 10); var lab2 = new LABColor(L, -5, 65); var lab = LABColor.Lerp(lab1, lab2, greediness); Color rgb = lab.ToColor(); Generate_and_Apply(plant, seed, rgb); }
// public static LABColor LerpLCH(LABColor a, LABColor b, float t){ // float C0 = Mathf.Sqrt(a.A*a.A + a.B*a.B); // float C1 = Mathf.Sqrt(b.A*b.A + b.B*b.B); // float h0 = Mathf.Atan2(a.B, a.A); // float h1 = Mathf.Atan2(b.B, b.A); // float C = Mathf.Lerp(C0, C1, t); // float h = Mathf.Lerp(h0, h1, t); // float L = Mathf.Lerp(a.L, b.L, t); // float A = C*Mathf.Cos(h); // float B = C*Mathf.Sin(h); // return new LABColor(L, A, B); // } // static function for interpolation between two Unity Colors through normalized colorspace public static Color Lerp(Color a, Color b, float t) { return((LABColor.Lerp(LABColor.FromColor(a), LABColor.FromColor(b), t)).ToColor()); }