Class BlockFacing
- Namespace
- Vintagestory.API.MathTools
- Assembly
- VintagestoryAPI.dll
Represents one of the 6 faces of a cube and all it's properties. Uses a right Handed Coordinate System. See also http://www.matrix44.net/cms/notes/opengl-3d-graphics/coordinate-systems-in-opengl In short: North: Negative Z East: Positive X South: Positive Z West: Negative X Up: Positive Y Down: Negative Y
public class BlockFacing
- Inheritance
-
BlockFacing
- Inherited Members
- Extension Methods
Fields
ALLFACES
All block faces in the order of N, E, S, W, U, D
public static readonly BlockFacing[] ALLFACES
Field Value
ALLNORMALI
All block faces in the order of N, E, S, W, U, D
public static readonly Vec3i[] ALLNORMALI
Field Value
- Vec3i[]
AllVertexFlagsNormals
Packed ints representing the normal flags, left-shifted by 15 for easy inclusion in VertexFlags
public static readonly int[] AllVertexFlagsNormals
Field Value
- int[]
DOWN
Faces towards negative Y
public static readonly BlockFacing DOWN
Field Value
EAST
Faces towards positive X
public static readonly BlockFacing EAST
Field Value
HORIZONTALS
Array of horizontal faces (N, E, S, W)
public static readonly BlockFacing[] HORIZONTALS
Field Value
HORIZONTALS_ANGLEORDER
Array of horizontal faces in angle order (0°, 90°, 180°, 270°) => (E, N, W, S)
public static readonly BlockFacing[] HORIZONTALS_ANGLEORDER
Field Value
HORIZONTAL_NORMALI
Array of the normals to the horizontal faces (N, E, S, W)
public static readonly Vec3i[] HORIZONTAL_NORMALI
Field Value
- Vec3i[]
HorizontalFlags
All horizontal blockfacing flags combined
public static readonly byte HorizontalFlags
Field Value
NORTH
Faces towards negative Z
public static readonly BlockFacing NORTH
Field Value
NumberOfFaces
public const int NumberOfFaces = 6
Field Value
SOUTH
Faces towards positive Z
public static readonly BlockFacing SOUTH
Field Value
UP
Faces towards positive Y
public static readonly BlockFacing UP
Field Value
VERTICALS
Array of vertical faces (U, D)
public static readonly BlockFacing[] VERTICALS
Field Value
VerticalFlags
All vertical blockfacing flags combined
public static readonly byte VerticalFlags
Field Value
WEST
Faces towards negative X
public static readonly BlockFacing WEST
Field Value
indexDOWN
public const int indexDOWN = 5
Field Value
indexEAST
public const int indexEAST = 1
Field Value
indexNORTH
public const int indexNORTH = 0
Field Value
indexSOUTH
public const int indexSOUTH = 2
Field Value
indexUP
public const int indexUP = 4
Field Value
indexWEST
public const int indexWEST = 3
Field Value
Properties
Axis
The normal axis of this vector.
public EnumAxis Axis { get; }
Property Value
Code
Returns the string north, east, south, west, up or down
public string Code { get; }
Property Value
Flag
The faces byte flag
public byte Flag { get; }
Property Value
HorizontalAngleIndex
The angle index of the face (E = 0, N = 1, W = 2, S = 3)
public int HorizontalAngleIndex { get; }
Property Value
Index
The index of the face (N=0, E=1, S=2, W=3, U=4, D=5)
public int Index { get; }
Property Value
IsAxisNS
True if this face is N or S
public bool IsAxisNS { get; }
Property Value
IsAxisWE
True if this face is N or S
public bool IsAxisWE { get; }
Property Value
IsHorizontal
True if this face is N,E,S or W
public bool IsHorizontal { get; }
Property Value
IsVertical
True if this face is U or D
public bool IsVertical { get; }
Property Value
MeshDataIndex
Index + 1
public byte MeshDataIndex { get; }
Property Value
Negative
public bool Negative { get; }
Property Value
NormalByte
Returns a normal vector of this face encoded in 6 bits/ bit 0: 1 if south or west bit 1: sign bit bit 2: 1 if up or down bit 3: sign bit bit 4: 1 if north or south bit 5: sign bit
public byte NormalByte { get; }
Property Value
NormalPacked
Normalized normal vector in format GL_INT_2_10_10_10_REV
public int NormalPacked { get; }
Property Value
NormalPackedFlags
Normalized normal vector packed into 3x4=12 bytes total and bit shifted by 15 bits, for use in meshdata flags data
public int NormalPackedFlags { get; }
Property Value
Normald
public Vec3d Normald { get; }
Property Value
Normalf
Returns a normal vector of this face
public Vec3f Normalf { get; }
Property Value
Normali
Returns a normal vector of this face. Classic iterating through these at a position x,y,z is unlikely to be dimension-aware, use BlockFacing.IterateThruFacingOffsets(pos) instead.
public Vec3i Normali { get; }
Property Value
Opposite
Returns the opposing face
public BlockFacing Opposite { get; }
Property Value
Plane
Returns a cuboid where either the width, height or length is zero which represents the min/max of the block 2D plane in 3D space
public Cuboidf Plane { get; }
Property Value
PlaneCenter
Returns the center position of this face
public Vec3f PlaneCenter { get; }
Property Value
Methods
FaceWhenRotatedBy(float, float, float)
Applies a 3d rotation on the face and returns the face thats closest to the rotated face
public BlockFacing FaceWhenRotatedBy(float radX, float radY, float radZ)
Parameters
Returns
FinishIteratingAllFaces(BlockPos)
Restores the original value of pos, if we are certain we looped through ALLFACES using IterateThruFacingOffsets Note: if for any reason control might have exited the loop early, this cannot sensibly be used
public static void FinishIteratingAllFaces(BlockPos pos)
Parameters
pos
BlockPos
FlagContains(byte, BlockFacing)
Returns true if given byte flags contain given face
public static bool FlagContains(byte flag, BlockFacing facing)
Parameters
flag
bytefacing
BlockFacing
Returns
FlagContainsHorizontals(byte)
Returns true if given byte flags contains a horizontal face
public static bool FlagContainsHorizontals(byte flag)
Parameters
flag
byte
Returns
FromCode(string)
Returns the face if code is 'north', 'east', 'south', 'west', 'north', 'up' or 'down'. Otherwise null.
public static BlockFacing FromCode(string code)
Parameters
code
string
Returns
FromFirstLetter(char)
public static BlockFacing FromFirstLetter(char code)
Parameters
code
char
Returns
FromFirstLetter(string)
Returns the face if code is 'n', 'e', 's', 'w', 'n', 'u' or 'd'. Otherwise null.
public static BlockFacing FromFirstLetter(string code)
Parameters
code
string
Returns
FromFlag(int)
public static BlockFacing FromFlag(int flag)
Parameters
flag
int
Returns
FromNormal(Vec3f)
public static BlockFacing FromNormal(Vec3f vec)
Parameters
vec
Vec3f
Returns
FromNormal(Vec3i)
public static BlockFacing FromNormal(Vec3i vec)
Parameters
vec
Vec3i
Returns
FromVector(double, double, double)
public static BlockFacing FromVector(double x, double y, double z)
Parameters
Returns
GetCCW()
Returns the face if current face would be horizontally counter-clockwise rotated, only works for horizontal faces
public BlockFacing GetCCW()
Returns
GetCW()
Returns the face if current face would be horizontally clockwise rotated, only works for horizontal faces
public BlockFacing GetCW()
Returns
GetFaceBrightness(double[], float[])
Rotates the face by given angle and returns the interpolated brightness of this face.
public float GetFaceBrightness(double[] matrix, float[] BlockSideBrightnessByFacing)
Parameters
matrix
double[]BlockSideBrightnessByFacing
float[]Array of brightness values between 0 and 1 per face. In index order (N, E, S, W, U, D)
Returns
GetFaceBrightness(float, float, float, float[])
Rotates the face by given angle and returns the interpolated brightness of this face.
public float GetFaceBrightness(float radX, float radY, float radZ, float[] BlockSideBrightnessByFacing)
Parameters
radX
floatradY
floatradZ
floatBlockSideBrightnessByFacing
float[]Array of brightness values between 0 and 1 per face. In index order (N, E, S, W, U, D)
Returns
GetHorizontalRotated(int)
Gets the Horizontal BlockFacing by applying the given angel If used on a UP or DOWN BlockFacing it will return it's current BlockFacing
public BlockFacing GetHorizontalRotated(int angle)
Parameters
angle
int
Returns
GetOpposite()
[Obsolete("Use Opposite property instead")]
public BlockFacing GetOpposite()
Returns
HorizontalFromAngle(float)
Returns the closest horizontal face from given angle (0 degree = east). Uses HORIZONTALS_ANGLEORDER
public static BlockFacing HorizontalFromAngle(float radians)
Parameters
radians
float
Returns
HorizontalFromYaw(float)
Returns the closest horizontal face from given angle (0 degree = north for yaw!). Uses HORIZONTALS_ANGLEORDER
public static BlockFacing HorizontalFromYaw(float radians)
Parameters
radians
float
Returns
IsAdjacent(BlockFacing)
public bool IsAdjacent(BlockFacing facing)
Parameters
facing
BlockFacing
Returns
IterateThruFacingOffsets(BlockPos)
In 1.20+ this is the recommended technique for examining blocks on all sides of a BlockPos position, as it is dimension-aware
Successive calls to this when looping through the standard six BlockFacings will set pos to the relevant facing offset from the original position
NOTE: this modifies the fields of the pos parameter, which is better for heap usage than creating a new BlockPos object for each iteration
If necessary to restore the original blockPos value, call FinishIteratingAllFaces(pos)
public void IterateThruFacingOffsets(BlockPos pos)
Parameters
pos
BlockPos
ToAB(Vec3f)
Project pos onto the block face
public Vec2f ToAB(Vec3f pos)
Parameters
pos
Vec3f
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.