本文整理汇总了C#中System.Random.Direction方法的典型用法代码示例。如果您正苦于以下问题:C# Random.Direction方法的具体用法?C# Random.Direction怎么用?C# Random.Direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.Direction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddVein
public static void AddVein(MyMwcObjectBuilder_VoxelMap builder, float thickness, Vector3 position, Random rnd, MyMwcVoxelMaterialsEnum material, float veinAngleDev, int maxLevel, int level = 0)
{
int numSplits = 2;// rnd.Next(2, 4);
List<Vector3> targets = new List<Vector3>(numSplits);
float handDist = thickness * 1.5f;
for (int iSplit = 0; iSplit < numSplits; iSplit++)
{
// Hands per line
int numHands = rnd.Next(8, 12);
Vector3 direction = rnd.Direction();
Vector3 target = position;
for (int i = 0; i < numHands; i++)
{
direction = rnd.Direction(direction, veinAngleDev);
target += direction * handDist;
// TODO: uncomment this to see material better (shown as tunnels, not only as voxel material)
//var voxelHand = new MyMwcObjectBuilder_VoxelHand_Sphere(target, thickness - 1, MyMwcVoxelHandModeTypeEnum.SUBTRACT);
//voxelHand.VoxelHandMaterial = material;
//builder.VoxelHandShapes.Add(voxelHand);
var voxelHand2 = new MyMwcObjectBuilder_VoxelHand_Sphere(new MyMwcPositionAndOrientation(target, Vector3.Forward, Vector3.Up), thickness, MyMwcVoxelHandModeTypeEnum.SET_MATERIAL);
voxelHand2.VoxelHandMaterial = material;
builder.VoxelHandShapes.Add(voxelHand2);
}
targets.Add(target);
}
if (level < maxLevel)
{
foreach (var t in targets)
{
AddVein(builder, thickness * 0.7f, t, rnd, material, veinAngleDev, maxLevel, level + 1);
}
}
}
示例2: AddAsteroidField
void AddAsteroidField(MySolarSystemMapEntity entity)
{
Vector3 areaPos = EntityPosition(entity, m_currentCamera);
float areaRadius = KmToGameUnits(entity.Radius);
float blendSizeLower = SectorToGameUnits(10000);
float blendSizeUpper = SectorToGameUnits(150000);
float minAsteroidFieldDist = SectorToGameUnits(20000);
float maxAsteroidFieldDist = SectorToGameUnits(200000);
// Size of billboards in fraction of whole size
const float billboardSizeRatio = 0.2f;
const int billboardsPerAsteroidField = 25;
float radius = billboardSizeRatio * areaRadius;
Random rnd = new Random(entity.Sector.X ^ entity.Sector.Y ^ entity.Sector.Z ^ (int)entity.PositionInSector.X ^ (int)entity.PositionInSector.Y ^ (int)entity.PositionInSector.Z);
for (int i = 0; i < billboardsPerAsteroidField; i++)
{
Vector3 dir = rnd.Direction();
float maxDist = areaRadius - radius;
Vector3 pos = areaPos + dir * maxDist;
float dist = pos.Length();
float alphaLower = CalculateBlend(minAsteroidFieldDist, minAsteroidFieldDist + blendSizeLower, dist);
float alphaUpper = 1 - CalculateBlend(maxAsteroidFieldDist, maxAsteroidFieldDist + blendSizeUpper, dist);
float alpha = alphaLower * alphaUpper;
if (alpha < float.Epsilon)
{
return;
}
Vector4 color = entity.Color.ToVector4();
color *= alpha;
//color.W = alpha;
/*if (dist < minAsteroidFieldDist || dist > maxAsteroidFieldDist)
{
return;
}*/
MyTransparentGeometry.AddBillboardOriented(MyTransparentMaterialEnum.SolarMapAsteroidField, color, pos, m_currentCamera.Up, m_currentCamera.Left, radius, -2);
}
}