本文整理汇总了C#中System.Numerics.Vector3类的典型用法代码示例。如果您正苦于以下问题:C# Vector3类的具体用法?C# Vector3怎么用?C# Vector3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector3类属于System.Numerics命名空间,在下文中一共展示了Vector3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlaceBlock
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
Metadata = (byte) face;
world.SetBlock(this);
return true;
}
示例2: PlaceBlock
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
if (face == BlockFace.Down) return true;
switch (face)
{
case BlockFace.Up:
Metadata = 5;
break;
case BlockFace.East:
Metadata = 4;
break;
case BlockFace.West:
Metadata = 3;
break;
case BlockFace.North:
Metadata = 2;
break;
case BlockFace.South:
Metadata = 1;
break;
}
world.SetBlock(this);
return true;
}
示例3: ResetLocalSpace
public static void ResetLocalSpace(out Vector3 forward, out Vector3 side, out Vector3 up, out Vector3 position)
{
forward = -Vector3.UnitZ;
side = Vector3.UnitX;
up = Vector3.UnitY;
position = Vector3.Zero;
}
示例4: HowFarOutsidePath
/// <summary>
/// how far outside path tube is the given point? (negative is inside)
/// </summary>
/// <param name="pathway"></param>
/// <param name="point"></param>
/// <returns></returns>
public static float HowFarOutsidePath(this IPathway pathway, Vector3 point)
{
float outside;
Vector3 tangent;
pathway.MapPointToPath(point, out tangent, out outside);
return outside;
}
示例5: Mesh
public Mesh(string fileName = null)
{
Filename = fileName;
MinVertex = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
MaxVertex = new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity);
SubMeshes = new List<SubMesh>();
}
示例6: LocalSpace
public LocalSpace(Vector3 up, Vector3 forward, Vector3 position)
{
Up = up;
Forward = forward;
Position = position;
SetUnitSideFromForwardAndUp();
}
示例7: PlaceBlock
// 000 001 010 011 100
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
byte direction = player.GetDirection();
byte upper = (byte) ((faceCoords.Y > 0.5 && face != BlockFace.Up) || face == BlockFace.Down ? 0x04 : 0x00);
switch (direction)
{
case 0:
Metadata = (byte) (0 | upper);
break;
case 1:
Metadata = (byte) (2 | upper);
break;
case 2:
Metadata = (byte) (1 | upper);
break;
case 3:
Metadata = (byte) (3 | upper);
break;
}
world.SetBlock(this);
return true;
}
示例8: PlaceBlock
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
byte direction = player.GetDirection();
switch (face)
{
case BlockFace.South: // ok
Metadata = 0;
break;
case BlockFace.North:
Metadata = 1;
break;
case BlockFace.West:
Metadata = 2;
break;
case BlockFace.East: // ok
Metadata = 3;
break;
}
Log.Warn($"Direction={direction}, face={face}, metadata={Metadata}");
world.SetBlock(this);
return true;
}
示例9: MapPointToPath
// Given an arbitrary point ("A"), returns the nearest point ("P") on
// this path. Also returns, via output arguments, the path tangent at
// P and a measure of how far A is outside the Pathway's "tube". Note
// that a negative distance indicates A is inside the Pathway.
public virtual Vector3 MapPointToPath(Vector3 point, out Vector3 tangent, out float outside)
{
float minDistance = float.MaxValue;
Vector3 onPath = Vector3.Zero;
tangent = Vector3.Zero;
// loop over all segments, find the one nearest to the given point
for (int i = 1; i < PointCount; i++)
{
Vector3 chosen;
float d = PointToSegmentDistance(point, Points[i - 1], Points[i], Tangents[i], Lengths[i], out chosen);
if (d < minDistance)
{
minDistance = d;
onPath = chosen;
tangent = Tangents[i];
}
}
// measure how far original point is outside the Pathway's "tube"
outside = Vector3.Distance(onPath, point) - Radius;
// return point on path
return onPath;
}
示例10: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords)
{
//if (player.GameMode != GameMode.Creative)
//{
// Item itemStackInHand = player.Inventory.GetItemInHand();
// itemStackInHand.Count--;
// if (itemStackInHand.Count <= 0)
// {
// // set empty
// player.Inventory.Slots[player.Inventory.Slots.IndexOf(itemStackInHand)] = new ItemAir();
// }
//}
_block.Coordinates = GetNewCoordinatesFromFace(targetCoordinates, face);
_block.Metadata = (byte) Metadata;
if ((player.GetBoundingBox() - 0.01f).Intersects(_block.GetBoundingBox()))
{
Log.Debug("Can't build where you are standing: " + _block.GetBoundingBox());
return;
}
if (!_block.CanPlace(world, face)) return;
if (_block.PlaceBlock(world, player, targetCoordinates, face, faceCoords)) return; // Handled
world.SetBlock(_block);
}
示例11: IsInsidePath
/// <summary>
/// is the given point inside the path tube?
/// </summary>
/// <param name="pathway"></param>
/// <param name="point"></param>
/// <returns></returns>
public static bool IsInsidePath(this IPathway pathway, Vector3 point)
{
float outside;
Vector3 tangent;
pathway.MapPointToPath(point, out tangent, out outside);
return outside < 0;
}
示例12: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
if (player.GameMode != GameMode.Creative)
{
Item itemStackInHand = player.Inventory.GetItemInHand();
itemStackInHand.Count--;
if (itemStackInHand.Count <= 0)
{
// set empty
player.Inventory.Slots[player.Inventory.Slots.IndexOf(itemStackInHand)] = new ItemAir();
}
}
var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
Chest chest = new Chest
{
Coordinates = coor,
};
if (!chest.CanPlace(world, face)) return;
chest.PlaceBlock(world, player, coor, face, faceCoords);
// Then we create and set the sign block entity that has all the intersting data
ChestBlockEntity chestBlockEntity = new ChestBlockEntity
{
Coordinates = coor
};
world.SetBlockEntity(chestBlockEntity);
}
示例13: Vector4
/// <summary>
/// Constructs a Vector4 from the given Vector3 and a W component.
/// </summary>
/// <param name="value">The vector to use as the X, Y, and Z components.</param>
/// <param name="w">The W component.</param>
public Vector4(Vector3 value, Single w)
{
X = value.X;
Y = value.Y;
Z = value.Z;
W = w;
}
示例14: WithinArea
private bool WithinArea(Vector3 location)
{
var differenceFromCenter = this.Position - location;
var uLength = Util.Projection(differenceFromCenter, uDirection);
var vLength = Util.Projection(differenceFromCenter, vDirection);
return uLength.Magnitude() <= width / 2f && vLength.Magnitude() <= height / 2f;
}
示例15: LocalizePosition
/// <summary>
/// Transforms a point in global space to its equivalent in local space.
/// </summary>
/// <param name="basis">The basis which this should operate on</param>
/// <param name="globalPosition">The global space position to transform.</param>
/// <returns>The global space position transformed to local space.</returns>
public static Vector3 LocalizePosition(this ILocalSpaceBasis basis, Vector3 globalPosition)
{
// global offset from local origin
Vector3 globalOffset = globalPosition - basis.Position;
// dot offset with local basis vectors to obtain local coordiantes
return LocalizeDirection(basis, globalOffset);
}