本文整理汇总了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();
}
示例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();
}