本文整理汇总了C#中VRageMath.Vector3.Snap方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Snap方法的具体用法?C# Vector3.Snap怎么用?C# Vector3.Snap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRageMath.Vector3
的用法示例。
在下文中一共展示了Vector3.Snap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawSceneDebug
//.........这里部分代码省略.........
// batch.AddSphereRing(new BoundingSphere(position, light.Pointlight.Range), new Color(light.Pointlight.Color), Matrix.CreateRotationX((float)Math.PI * 0.5f));
// batch.AddSphereRing(new BoundingSphere(position, light.Pointlight.Range), new Color(light.Pointlight.Color), Matrix.CreateRotationZ((float)Math.PI * 0.5f));
// batch.AddSphereRing(new BoundingSphere(position, light.Pointlight.Radius), new Color(light.Pointlight.Color), Matrix.Identity);
// batch.AddSphereRing(new BoundingSphere(position, light.Pointlight.Radius), new Color(light.Pointlight.Color), Matrix.CreateRotationX((float)Math.PI * 0.5f));
// }
// }
// batch.Commit();
//}
//
if (false)
{
MyLinesBatch batch = MyLinesRenderer.CreateBatch();
foreach(var r in MyComponentFactory<MyRenderableComponent>.GetAll())
{
if(r.m_owner.GetComponent(MyActorComponentEnum.Instancing) != null)
{
batch.AddBoundingBox((BoundingBox)r.m_owner.Aabb, Color.Blue);
}
}
batch.Commit();
}
if (false)
{
MyLinesBatch batch = MyLinesRenderer.CreateBatch();
//var radius = new [] { 0, 40, 72, 128, 256 , 512 };
var radius = new[] { 0, 50, 80, 128, 256, 512 };
float cellSize = 8;
var colors = new[] { Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Pink, Color.MediumVioletRed };
var prevPositionG = Vector3.PositiveInfinity;
for(int i=0; i<4; i++)
{
float levelCellSize = cellSize * (float)Math.Pow(2, i);
var position = MyEnvironment.CameraPosition;
//var position = Vector3.Zero;
position.Y = 0;
var positionG = position.Snap(levelCellSize * 2);
float radiusMin = radius[i];
float radiusMax = radius[i+1];
// naive
var pmin = (positionG - radiusMax - levelCellSize * 2).Snap(levelCellSize * 2);
var pmax = (positionG + radiusMax + levelCellSize * 2).Snap(levelCellSize * 2);
//if(i==0)
//{
// for (var x = pmin.X; x < pmax.X; x += levelCellSize)
// {
// for (var y = pmin.Y; y < pmax.Y; y += levelCellSize)
// {
// for (var z = pmin.Z; z < pmax.Z; z += levelCellSize)
// {
// var cell = new Vector3(x, y, z);
// var rep = cell.Snap(levelCellSize * 2);
// var inLevelGrid = (rep - positionG).Length() < radiusMax;
// if(inLevelGrid)
// {
// batch.AddBoundingBox(new BoundingBox(cell, cell + levelCellSize), colors[i]);
// }
// }
// }
// }
//}
//else
{
for (var x = pmin.X; x < pmax.X; x += levelCellSize)
{
for (var z = pmin.Z; z < pmax.Z; z += levelCellSize)
{
var cell = new Vector3(x, positionG.Y, z);
var rep = cell.Snap(levelCellSize * 2);
var inPrevLevelGrid = (cell - prevPositionG).Length() < radiusMin;
var inLevelGrid = (rep - positionG).Length() < radiusMax;
if (inLevelGrid && !inPrevLevelGrid)
{
batch.AddBoundingBox(new BoundingBox(cell, cell + levelCellSize), colors[i]);
}
}
}
}
prevPositionG = positionG;
}
batch.Commit();
}
}