本文整理汇总了C#中Vector3.XZToVector2方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.XZToVector2方法的具体用法?C# Vector3.XZToVector2怎么用?C# Vector3.XZToVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.XZToVector2方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PointScatterRegion
public PointScatterRegion(Vector3 outerOrigin, float outerRadius, Vector3 innerOrigin, float innerRadius)
{
outerRect = new Rect(0, 0, 2f * outerRadius, 2f * outerRadius);
outerRect.center = outerOrigin.XZToVector2();
innerRect = new Rect(0, 0, 2f * innerRadius, 2f * innerRadius);
innerRect.center = innerOrigin.XZToVector2();
}
示例2: Plate
/// <summary>
/// Creates a new plate.
/// </summary>
/// <param name="homeQuarter">Town quarter where is it located</param>
/// <param name="upperLeft">Upper left corner</param>
/// <param name="upperRight">Upper right corner</param>
/// <param name="lowerLeft">Lower left corner</param>
/// <param name="lowerRight">Lower right corner</param>
/// <param name="front">Front side texture</param>
/// <param name="back">Back side texture</param>
/// <param name="enableDefaultLightning">Determines if the default lightning is used</param>
public Plate(TownQuarter homeQuarter, Vector3 upperLeft, Vector3 upperRight, Vector3 lowerLeft, Vector3 lowerRight, Texture2D front, Texture2D back, bool enableDefaultLightning)
: base(upperLeft.XZToVector2(), upperRight.XZToVector2(), lowerLeft.XZToVector2(), lowerRight.XZToVector2())
{
quarter = homeQuarter;
ul = upperLeft;
ur = upperRight;
ll = lowerLeft;
lr = lowerRight;
this.back = back;
this.front = front;
graphicsDevice = front.GraphicsDevice;
frontVertices = new VertexPositionNormalTexture[4];
backVertices = new VertexPositionNormalTexture[4];
indexes = new short[6];
BuildEffects(enableDefaultLightning);
}
示例3: SpatialObject
/// <summary>
/// Creates a new spatial object.
/// </summary>
/// <param name="model">Model</param>
/// <param name="quarter">Town quarter</param>
/// <param name="positionInQuarter">Position inside the town quarter</param>
/// <param name="azimuth">Azimuth</param>
/// <param name="worldTransform">World transform matrix</param>
public SpatialObject(Model model, TownQuarter quarter, Vector3 positionInQuarter, double azimuth, Matrix worldTransform)
: base(new PositionInTown(quarter, positionInQuarter.XZToVector2()), azimuth, (model == null? Vector2.Zero : model.GetSize(worldTransform).XZToVector2()))
{
Load(model, new PositionInTown(quarter, positionInQuarter.XZToVector2()), positionInQuarter.Y, azimuth, worldTransform);
}
示例4: ScatterPoints
public static List<Vector3> ScatterPoints(this Rect rect, int count, float height, Rect notRect = new Rect())
{
var current = new List<Vector3>();
int maxTimes = 50;
while (maxTimes >= 0 && current.Count < count) {
var y = height;
var x = UnityEngine.Random.Range(rect.xMin, rect.xMax);
var z = UnityEngine.Random.Range(rect.yMin, rect.yMax);
var newP = new Vector3(x, y, z);
if (!notRect.Contains(newP.XZToVector2()) && CanAdd(current, 4f, newP, out newP)) {
current.Add(newP);
}
maxTimes--;
}
return current;
}
示例5: CanAdd
static bool CanAdd(IEnumerable<Vector3> currentPoints, float minDistance, Vector3 point, out Vector3 hitPoint)
{
hitPoint = Vector3.zero;
var sqrDist = minDistance * minDistance;
foreach (var p in currentPoints) {
if (Vector2.SqrMagnitude(point.XZToVector2() - p.XZToVector2()) < sqrDist) {
return false;
}
}
var ray = new Ray(point, Vector3.down);
var hit = new RaycastHit();
if (Physics.Raycast(ray, out hit, 100f)) {
if (hit.transform.gameObject.layer == LayerMask.NameToLayer(blockedLayer)) {
return false;
} else {
hitPoint = hit.point;
return true;
}
} else {
return false;
}
}