Table of Contents

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

Fields

ALLFACES

All block faces in the order of N, E, S, W, U, D

public static readonly BlockFacing[] ALLFACES

Field Value

BlockFacing[]

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

BlockFacing

EAST

Faces towards positive X

public static readonly BlockFacing EAST

Field Value

BlockFacing

HORIZONTALS

Array of horizontal faces (N, E, S, W)

public static readonly BlockFacing[] HORIZONTALS

Field Value

BlockFacing[]

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

BlockFacing[]

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

byte

NORTH

Faces towards negative Z

public static readonly BlockFacing NORTH

Field Value

BlockFacing

NumberOfFaces

public const int NumberOfFaces = 6

Field Value

int

SOUTH

Faces towards positive Z

public static readonly BlockFacing SOUTH

Field Value

BlockFacing

UP

Faces towards positive Y

public static readonly BlockFacing UP

Field Value

BlockFacing

VERTICALS

Array of vertical faces (U, D)

public static readonly BlockFacing[] VERTICALS

Field Value

BlockFacing[]

VerticalFlags

All vertical blockfacing flags combined

public static readonly byte VerticalFlags

Field Value

byte

WEST

Faces towards negative X

public static readonly BlockFacing WEST

Field Value

BlockFacing

indexDOWN

public const int indexDOWN = 5

Field Value

int

indexEAST

public const int indexEAST = 1

Field Value

int

indexNORTH

public const int indexNORTH = 0

Field Value

int

indexSOUTH

public const int indexSOUTH = 2

Field Value

int

indexUP

public const int indexUP = 4

Field Value

int

indexWEST

public const int indexWEST = 3

Field Value

int

Properties

Axis

The normal axis of this vector.

public EnumAxis Axis { get; }

Property Value

EnumAxis

Code

Returns the string north, east, south, west, up or down

public string Code { get; }

Property Value

string

Flag

The faces byte flag

public byte Flag { get; }

Property Value

byte

HorizontalAngleIndex

The angle index of the face (E = 0, N = 1, W = 2, S = 3)

public int HorizontalAngleIndex { get; }

Property Value

int

Index

The index of the face (N=0, E=1, S=2, W=3, U=4, D=5)

public int Index { get; }

Property Value

int

IsAxisNS

True if this face is N or S

public bool IsAxisNS { get; }

Property Value

bool

IsAxisWE

True if this face is N or S

public bool IsAxisWE { get; }

Property Value

bool

IsHorizontal

True if this face is N,E,S or W

public bool IsHorizontal { get; }

Property Value

bool

IsVertical

True if this face is U or D

public bool IsVertical { get; }

Property Value

bool

MeshDataIndex

Index + 1

public byte MeshDataIndex { get; }

Property Value

byte

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

byte

NormalPacked

Normalized normal vector in format GL_INT_2_10_10_10_REV

public int NormalPacked { get; }

Property Value

int

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

int

Normald

public Vec3d Normald { get; }

Property Value

Vec3d

Normalf

Returns a normal vector of this face

public Vec3f Normalf { get; }

Property Value

Vec3f

Normali

Returns a normal vector of this face

public Vec3i Normali { get; }

Property Value

Vec3i

Opposite

Returns the opposing face

public BlockFacing Opposite { get; }

Property Value

BlockFacing

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

Cuboidf

PlaneCenter

Returns the center position of this face

public Vec3f PlaneCenter { get; }

Property Value

Vec3f

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

radX float
radY float
radZ float

Returns

BlockFacing

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 byte
facing BlockFacing

Returns

bool

FlagContainsHorizontals(byte)

Returns true if given byte flags contains a horizontal face

public static bool FlagContainsHorizontals(byte flag)

Parameters

flag byte

Returns

bool

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

BlockFacing

FromFirstLetter(char)

public static BlockFacing FromFirstLetter(char code)

Parameters

code char

Returns

BlockFacing

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

BlockFacing

FromFlag(int)

public static BlockFacing FromFlag(int flag)

Parameters

flag int

Returns

BlockFacing

FromNormal(Vec3f)

public static BlockFacing FromNormal(Vec3f vec)

Parameters

vec Vec3f

Returns

BlockFacing

FromNormal(Vec3i)

public static BlockFacing FromNormal(Vec3i vec)

Parameters

vec Vec3i

Returns

BlockFacing

FromVector(double, double, double)

public static BlockFacing FromVector(double x, double y, double z)

Parameters

x double
y double
z double

Returns

BlockFacing

GetCCW()

Returns the face if current face would be horizontally counter-clockwise rotated, only works for horizontal faces

public BlockFacing GetCCW()

Returns

BlockFacing

GetCW()

Returns the face if current face would be horizontally clockwise rotated, only works for horizontal faces

public BlockFacing GetCW()

Returns

BlockFacing

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

float

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 float
radY float
radZ float
BlockSideBrightnessByFacing float[]

Array of brightness values between 0 and 1 per face. In index order (N, E, S, W, U, D)

Returns

float

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

BlockFacing

GetOpposite()

[Obsolete("Use Opposite property instead")]
public BlockFacing GetOpposite()

Returns

BlockFacing

HorizontalFromAngle(float)

Returns the closest horizontal face from given angle (0 degree = east). Uses HORIZONTALS_ANGLEORDER

public static BlockFacing HorizontalFromAngle(float radiant)

Parameters

radiant float

Returns

BlockFacing

IsAdjacent(BlockFacing)

public bool IsAdjacent(BlockFacing facing)

Parameters

facing BlockFacing

Returns

bool

IterateThruFacingOffsets(BlockPos)

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

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.