当前位置: 首页>>代码示例>>C#>>正文


C# Vector4.ToList方法代码示例

本文整理汇总了C#中Vector4.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4.ToList方法的具体用法?C# Vector4.ToList怎么用?C# Vector4.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector4的用法示例。


在下文中一共展示了Vector4.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetClusters

    public static List<Vector4> GetClusters(List<Vector4> atoms, int numCentroids)
    {
        if (ComputeShaderManager.Instance.KMeansCS == null) throw new Exception("KMeans compute shader not assigned");

        if (numCentroids <= 0) throw new Exception("Num centroids too low");

        var centroids = new List<Vector4>();
        var centroidStep = Mathf.CeilToInt(atoms.Count / (float)numCentroids);
        for (int i = 0; i < numCentroids; i++)
        {
            if (i*centroidStep < atoms.Count)
            {
                centroids.Add(atoms[i * centroidStep]);
            }
            else
            {
                centroids.Add(atoms[UnityEngine.Random.Range(0, atoms.Count)]);
            }
        }

        var centroidBuffer = new ComputeBuffer(numCentroids, 4 * sizeof(float));
        centroidBuffer.SetData(centroids.ToArray());

        var pointBuffer = new ComputeBuffer(atoms.Count, 4 * sizeof(float));
        pointBuffer.SetData(atoms.ToArray());

        var membershipBuffer = new ComputeBuffer(atoms.Count, sizeof(int));

        ComputeShaderManager.Instance.KMeansCS.SetInt("_NumPoints", atoms.Count);
        ComputeShaderManager.Instance.KMeansCS.SetInt("_NumCentroids", numCentroids);

        for (int i = 0; i < 5; i++)
        {
            ComputeShaderManager.Instance.KMeansCS.SetBuffer(0, "_PointBuffer", pointBuffer);
            ComputeShaderManager.Instance.KMeansCS.SetBuffer(0, "_CentroidBuffer", centroidBuffer);
            ComputeShaderManager.Instance.KMeansCS.SetBuffer(0, "_MembershipBuffer", membershipBuffer);
            ComputeShaderManager.Instance.KMeansCS.Dispatch(0, Mathf.CeilToInt(atoms.Count / 1), 1, 1);

            ComputeShaderManager.Instance.KMeansCS.SetBuffer(1, "_PointBuffer", pointBuffer);
            ComputeShaderManager.Instance.KMeansCS.SetBuffer(1, "_NewCentroidBuffer", centroidBuffer);
            ComputeShaderManager.Instance.KMeansCS.SetBuffer(1, "_NewMembershipBuffer", membershipBuffer);
            ComputeShaderManager.Instance.KMeansCS.Dispatch(1, Mathf.CeilToInt(numCentroids / 64.0f), 1, 1);
        }

        var newCentroids = new Vector4[numCentroids];
        centroidBuffer.GetData(newCentroids);

        pointBuffer.Release();
        centroidBuffer.Release();
        membershipBuffer.Release();

        return newCentroids.ToList();
    }
开发者ID:matmuze,项目名称:VIZZIES,代码行数:53,代码来源:KMeansClustering.cs

示例2: InitColors2

    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();
    }
开发者ID:matmuze,项目名称:cellVIEW_color,代码行数:45,代码来源:ColorManager.cs


注:本文中的Vector4.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。