Interface BakedNormals
- All Known Implementing Classes:
BakedNormals.PerQuad,BakedNormals.PerVertex
Holds pre-computed normals, either for the entire quad or for each vertex.
The normal values are quantized to an integer between -127 and 127, truncated to a byte and packed into an int, leaving the MSB unused.
Normals can also be unspecified. In that case, rendering will use the normal implied by BakedQuad.direction(),
while a face normal will be computed for the purposes of AO calculations.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic final record -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intcomputeQuadNormal(Vector3fc position0, Vector3fc position1, Vector3fc position2, Vector3fc position3) Computes the packed normal of a quad based on the given vertex positions.static booleanisUnspecified(int packedNormal) Returns true if the packed normal represents an unspecified normal.intnormal(int vertex) Returns The packed normal of the given vertex.static BakedNormalsof(int normal) static BakedNormalsof(int normal0, int normal1, int normal2, int normal3) static intpack(float x, float y, float z) Returns a packed representation of the given normal.static intReturns a packed representation of the given normal.static Vector3fcstatic floatunpackComponent(int packedNormal, int axis) Returns the component of the given packed normal.static floatunpackX(int packedNormal) Returns the x component of the given packed normal.static floatunpackY(int packedNormal) Returns the y component of the given packed normal.static floatunpackZ(int packedNormal) Returns the z component of the given packed normal.
-
Field Details
-
UNSPECIFIED
-
-
Method Details
-
normal
int normal(int vertex) Returns The packed normal of the given vertex. It can also be unspecified.- Returns:
- The packed normal of the given vertex
- See Also:
-
of
- Parameters:
normal0- The normal of the first vertex, packed usingpack(float, float, float).normal1- The normal of the second vertex, packed usingpack(float, float, float).normal2- The normal of the third vertex, packed usingpack(float, float, float).normal3- The normal of the fourth vertex, packed usingpack(float, float, float).
-
of
- Parameters:
normal- The face normal, packed usingpack(float, float, float).
-
pack
static int pack(float x, float y, float z) Returns a packed representation of the given normal.- Returns:
- a packed representation of the given normal
-
pack
Returns a packed representation of the given normal.- Returns:
- a packed representation of the given normal
-
unpackComponent
static float unpackComponent(int packedNormal, int axis) Returns the component of the given packed normal.- Parameters:
axis- Pass 0 to extract the x component, 1 for y and 2 for z.- Returns:
- the component of the given packed normal
- See Also:
-
unpackX
static float unpackX(int packedNormal) Returns the x component of the given packed normal.- Returns:
- the x component of the given packed normal
- See Also:
-
unpackY
static float unpackY(int packedNormal) Returns the y component of the given packed normal.- Returns:
- the y component of the given packed normal
- See Also:
-
unpackZ
static float unpackZ(int packedNormal) Returns the z component of the given packed normal.- Returns:
- the z component of the given packed normal
- See Also:
-
unpack
- Parameters:
destination- The vector to unpack the packed normal into, ifnull, a new vector will be allocated.- Returns:
- The vector that the normal was unpacked into.
-
isUnspecified
static boolean isUnspecified(int packedNormal) Returns true if the packed normal represents an unspecified normal.- Returns:
- true if the packed normal represents an unspecified normal
-
computeQuadNormal
static int computeQuadNormal(Vector3fc position0, Vector3fc position1, Vector3fc position2, Vector3fc position3) Computes the packed normal of a quad based on the given vertex positions.- Returns:
- The packed representation of the computed normal.
-