Example #1
0
    public void InitColors2()
    {
        var tempIngredientGroupColor = new Color[SceneManager.Get.NumAllIngredients];

        var tempIngredientsInfo        = new Vector4[SceneManager.Get.NumAllIngredients];
        var tempIngredientsColors      = new Vector4[SceneManager.Get.NumAllIngredients];
        var tempIngredientsChainColors = new Vector4[SceneManager.Get.NumAllIngredients];

        foreach (var group in SceneManager.Get.IngredientGroups)
        {
            var currentHue = _hueShifts[group.unique_id] * 360.0f;
            tempIngredientGroupColor[group.unique_id] = MyUtility.ColorFromHSV(currentHue, 1, 1);

            //*******//

            var offsetInc       = 1.0f / group.Ingredients.Count;
            var ingredientCount = 0;

            foreach (var ingredient in group.Ingredients)
            {
                if (!SceneManager.Get.ProteinIngredientNames.Contains(ingredient.path))
                {
                    throw new Exception("Unknown ingredient: " + ingredient.path);
                }

                var currentChroma = Random.Range(0.5f, 1);

                tempIngredientsInfo[ingredient.ingredient_id]   = new Vector4(group.unique_id, ingredient.nbChains, CPUBuffers.Get.ProteinIngredientsChainColors.Count, 0);
                tempIngredientsColors[ingredient.ingredient_id] = (MyUtility.ColorFromHSV(currentHue, currentChroma, 1));

                //for (var j = 0; j < ingredient.nbChains; j++)
                //{
                //    var currentLuminance = Random.Range(0.5f, 1);
                //    CPUBuffers.Get.IngredientsChainColors.Add(MyUtility.ColorFromHSV(currentHue, currentChroma, currentLuminance));
                //}

                ingredientCount++;
            }
        }

        CPUBuffers.Get.IngredientsInfo               = tempIngredientsInfo.ToList();
        CPUBuffers.Get.IngredientGroupsColor         = tempIngredientGroupColor.ToList();
        CPUBuffers.Get.IngredientsColors             = tempIngredientsColors.ToList();
        CPUBuffers.Get.ProteinIngredientsChainColors = tempIngredientsChainColors.ToList();
    }
Example #2
0
    //*******//

    public void InitColors()
    {
        CPUBuffers.Get.IngredientsInfo.Clear();
        CPUBuffers.Get.IngredientsDisplayInfo.Clear();
        CPUBuffers.Get.IngredientGroupsDisplayInfo.Clear();

        // Predefined colors

        CPUBuffers.Get.IngredientsColors.Clear();
        CPUBuffers.Get.IngredientGroupsColor.Clear();
        CPUBuffers.Get.ProteinIngredientsChainColors.Clear();

        var tempIngredientsColors      = new Vector4[SceneManager.Get.NumAllIngredients];
        var tempIngredientsChainColors = new Vector4[SceneManager.Get.NumAllIngredients];

        // Properties to generate colors on the fly

        CPUBuffers.Get.IngredientGroupsLerpFactors.Clear();
        CPUBuffers.Get.IngredientGroupsColorRanges.Clear();
        CPUBuffers.Get.IngredientGroupsColorValues.Clear();
        CPUBuffers.Get.ProteinIngredientsRandomValues.Clear();

        foreach (var group in SceneManager.Get.IngredientGroups)
        {
            CPUBuffers.Get.IngredientGroupsDisplayInfo.Add(new DisplayInfo(group.NumIngredients, 0, 0, 0));

            var currentHue = _hueShifts[group.unique_id] * 360.0f;

            // Predified group color
            CPUBuffers.Get.IngredientGroupsColor.Add(MyUtility.ColorFromHSV(currentHue, 1, 1));

            //...
            CPUBuffers.Get.IngredientGroupsLerpFactors.Add(0);
            CPUBuffers.Get.IngredientGroupsColorValues.Add(new Vector4(currentHue, 75, 75));
            CPUBuffers.Get.IngredientGroupsColorRanges.Add(new Vector4(80, 0, 0));

            //*******//

            var offsetInc = 1.0f / group.Ingredients.Count;

            for (var i = 0; i < group.Ingredients.Count; i++)
            {
                if (!SceneManager.Get.AllIngredientNames.Contains(group.Ingredients[i].path))
                {
                    throw new Exception("Unknown ingredient: " + group.Ingredients[i].path);
                }

                CPUBuffers.Get.IngredientsDisplayInfo.Add(new DisplayInfo(group.Ingredients[i].nbMol, 0, 0, 0));

                var currentChroma = Random.Range(0.5f, 1);

                CPUBuffers.Get.IngredientsInfo.Add(new Vector4(group.unique_id, group.Ingredients[i].nbChains, CPUBuffers.Get.ProteinIngredientsChainColors.Count, 0));

                // Predefined ingredient color
                CPUBuffers.Get.IngredientsColors.Add(MyUtility.ColorFromHSV(currentHue, currentChroma, 1));

                for (var j = 0; j < group.Ingredients[i].nbChains; j++)
                {
                    var currentLuminance = Random.Range(0.5f, 1);
                    CPUBuffers.Get.ProteinIngredientsChainColors.Add(MyUtility.ColorFromHSV(currentHue, currentChroma, currentLuminance));
                }

                // ...
                CPUBuffers.Get.ProteinIngredientsRandomValues.Add(new Vector4(i * offsetInc, Random.Range(0.0f, 1.0f), 0));
            }
        }

        int a = 0;
    }