Interface QuadEmitter
- All Superinterfaces:
MutableQuadView,QuadView
MutableQuadView that supports transformers and
sends quads to some destination, such as a mesh builder or rendering.
Instances of QuadEmitter will practically always be
thread local and/or reused - do not retain references.
Only the renderer should implement or extend this interface.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatTolerance for determining if the depth parameter tosquare(Direction, float, float, float, float, float)is effectively zero - meaning the face is a cull face.Fields inherited from interface net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView
BAKE_FLIP_U, BAKE_FLIP_V, BAKE_LOCK_UV, BAKE_NORMALIZED, BAKE_ROTATE_180, BAKE_ROTATE_270, BAKE_ROTATE_90, BAKE_ROTATE_NONEFields inherited from interface net.fabricmc.fabric.api.renderer.v1.mesh.QuadView
VANILLA_QUAD_STRIDE, VANILLA_VERTEX_STRIDE -
Method Summary
Modifier and TypeMethodDescriptioncolor(int vertexIndex, int color) Set vertex color in ARGB format (0xAARRGGBB).default QuadEmittercolor(int c0, int c1, int c2, int c3) Convenience: set vertex color for all vertices at once.Copies all quad properties from the givenQuadViewto this quad.If non-null, quad is coplanar with a block face which, if known, simplifies or shortcuts geometric analysis that might otherwise be needed.emit()In static mesh building, causes quad to be appended to the mesh being built.fromVanilla(int[] quadData, int startIndex) Enables bulk vertex data transfer using the standard Minecraft vertex formats.fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace) Enables bulk vertex data transfer using the standard Minecraft quad format.lightmap(int vertexIndex, int lightmap) Accept vanilla lightmap values.default QuadEmitterlightmap(int b0, int b1, int b2, int b3) Convenience: set lightmap for all vertices at once.material(RenderMaterial material) Assigns a different material to this quad.nominalFace(@Nullable Direction face) Provides a hint to renderer about the facing of this quad.normal(int vertexIndex, float x, float y, float z) Adds a vertex normal.default QuadEmitternormal(int vertexIndex, org.joml.Vector3f normal) Same asMutableQuadView.normal(int, float, float, float)but accepts vector type.default QuadEmitternormal(int vertexIndex, org.joml.Vector3fc normal) Same asMutableQuadView.normal(int, float, float, float)but accepts vector type.voidRemoves the transformer added by the last call topushTransform(QuadTransform).pos(int vertexIndex, float x, float y, float z) Sets the geometric vertex position for the given vertex, relative to block origin, (0,0,0).default QuadEmitterpos(int vertexIndex, org.joml.Vector3f pos) Same asMutableQuadView.pos(int, float, float, float)but accepts vector type.default QuadEmitterpos(int vertexIndex, org.joml.Vector3fc pos) Same asMutableQuadView.pos(int, float, float, float)but accepts vector type.voidpushTransform(QuadTransform transform) Pushed transforms will be applied immediately after every call toemit()and before the quad data is delivered to its destination.spriteBake(Sprite sprite, int bakeFlags) Assigns sprite atlas u,v coordinates to this quad for the given sprite.default QuadEmitterHelper method to assign vertex coordinates for a square aligned with the given face.tag(int tag) Encodes an integer tag with this quad that can later be retrieved viaQuadView.tag().tintIndex(int tintIndex) Value functions identically toBakedQuad.getTintIndex()and is used by renderer in same way.uv(int vertexIndex, float u, float v) Set texture coordinates.default QuadEmitteruv(int vertexIndex, org.joml.Vector2f uv) Set texture coordinates.default QuadEmitteruv(int vertexIndex, org.joml.Vector2fc uv) Set texture coordinates.default QuadEmitterMethods inherited from interface net.fabricmc.fabric.api.renderer.v1.mesh.QuadView
color, copyNormal, copyPos, copyUv, cullFace, faceNormal, hasNormal, lightFace, lightmap, material, nominalFace, normalX, normalY, normalZ, posByIndex, tag, tintIndex, toBakedQuad, toVanilla, u, v, x, y, z
-
Field Details
-
CULL_FACE_EPSILON
static final float CULL_FACE_EPSILONTolerance for determining if the depth parameter tosquare(Direction, float, float, float, float, float)is effectively zero - meaning the face is a cull face.- See Also:
-
-
Method Details
-
pos
Description copied from interface:MutableQuadViewSets the geometric vertex position for the given vertex, relative to block origin, (0,0,0). Minecraft rendering is designed for models that fit within a single block space and is recommended that coordinates remain in the 0-1 range, with multi-block meshes split into multiple per-block models.- Specified by:
posin interfaceMutableQuadView
-
pos
Description copied from interface:MutableQuadViewSame asMutableQuadView.pos(int, float, float, float)but accepts vector type.- Specified by:
posin interfaceMutableQuadView
-
pos
Description copied from interface:MutableQuadViewSame asMutableQuadView.pos(int, float, float, float)but accepts vector type.- Specified by:
posin interfaceMutableQuadView
-
color
Description copied from interface:MutableQuadViewSet vertex color in ARGB format (0xAARRGGBB).- Specified by:
colorin interfaceMutableQuadView
-
color
Description copied from interface:MutableQuadViewConvenience: set vertex color for all vertices at once.- Specified by:
colorin interfaceMutableQuadView
-
uv
Description copied from interface:MutableQuadViewSet texture coordinates.- Specified by:
uvin interfaceMutableQuadView
-
uv
Description copied from interface:MutableQuadViewSet texture coordinates.Only use this function if you already have a
Vector2f. Otherwise, seeMutableQuadView.uv(int, float, float).- Specified by:
uvin interfaceMutableQuadView
-
uv
Description copied from interface:MutableQuadViewSet texture coordinates.Only use this function if you already have a
Vector2fc. Otherwise, seeMutableQuadView.uv(int, float, float).- Specified by:
uvin interfaceMutableQuadView
-
spriteBake
Description copied from interface:MutableQuadViewAssigns sprite atlas u,v coordinates to this quad for the given sprite. Can handle UV locking, rotation, interpolation, etc. Control this behavior by passing additive combinations of the BAKE_ flags defined in this interface.- Specified by:
spriteBakein interfaceMutableQuadView
-
uvUnitSquare
-
lightmap
Description copied from interface:MutableQuadViewAccept vanilla lightmap values. Input values will override lightmap values computed from world state if input values are higher. Exposed for completeness but some rendering implementations with non-standard lighting model may not honor it.For emissive rendering, it is better to use
MaterialFinder.emissive(boolean).- Specified by:
lightmapin interfaceMutableQuadView
-
lightmap
Description copied from interface:MutableQuadViewConvenience: set lightmap for all vertices at once.For emissive rendering, it is better to use
MaterialFinder.emissive(boolean). SeeMutableQuadView.lightmap(int, int).- Specified by:
lightmapin interfaceMutableQuadView
-
normal
Description copied from interface:MutableQuadViewAdds a vertex normal. Models that have per-vertex normals should include them to get correct lighting when it matters. Computed face normal is used when no vertex normal is provided.Rendererimplementations should honor vertex normals for diffuse lighting - modifying vertex color(s) or packing normals in the vertex buffer as appropriate for the rendering method/vertex format in effect.- Specified by:
normalin interfaceMutableQuadView
-
normal
Description copied from interface:MutableQuadViewSame asMutableQuadView.normal(int, float, float, float)but accepts vector type.- Specified by:
normalin interfaceMutableQuadView
-
normal
Description copied from interface:MutableQuadViewSame asMutableQuadView.normal(int, float, float, float)but accepts vector type.- Specified by:
normalin interfaceMutableQuadView
-
cullFace
Description copied from interface:MutableQuadViewIf non-null, quad is coplanar with a block face which, if known, simplifies or shortcuts geometric analysis that might otherwise be needed. Set to null if quad is not coplanar or if this is not known. Also controls face culling during block rendering.Null by default.
When called with a non-null value, also sets
MutableQuadView.nominalFace(Direction)to the same value.This is different from the value reported by
BakedQuad.getFace(). That value is computed based on face geometry and must be non-null in vanilla quads. That computed value is returned byQuadView.lightFace().- Specified by:
cullFacein interfaceMutableQuadView
-
nominalFace
Description copied from interface:MutableQuadViewProvides a hint to renderer about the facing of this quad. Not required, but if provided can shortcut some geometric analysis if the quad is parallel to a block face. Should be the expected value ofQuadView.lightFace(). Value will be confirmed and if invalid the correct light face will be calculated.Null by default, and set automatically by
QuadView.cullFace().Models may also find this useful as the face for texture UV locking and rotation semantics.
Note: This value is not persisted independently when the quad is encoded. When reading encoded quads, this value will always be the same as
QuadView.lightFace().- Specified by:
nominalFacein interfaceMutableQuadView
-
material
Description copied from interface:MutableQuadViewAssigns a different material to this quad. Useful for transformation of existing meshes because lighting and texture blending are controlled by material.- Specified by:
materialin interfaceMutableQuadView
-
tintIndex
Description copied from interface:MutableQuadViewValue functions identically toBakedQuad.getTintIndex()and is used by renderer in same way. Default value is -1.- Specified by:
tintIndexin interfaceMutableQuadView
-
tag
Description copied from interface:MutableQuadViewEncodes an integer tag with this quad that can later be retrieved viaQuadView.tag(). Useful for models that want to perform conditional transformation or filtering on static meshes.- Specified by:
tagin interfaceMutableQuadView
-
copyFrom
Description copied from interface:MutableQuadViewCopies all quad properties from the givenQuadViewto this quad.Calling this method does not emit the quad.
- Specified by:
copyFromin interfaceMutableQuadView
-
fromVanilla
Description copied from interface:MutableQuadViewEnables bulk vertex data transfer using the standard Minecraft vertex formats. Only thequad vertex datais copied. This method should be performant whenever caller's vertex representation makes it feasible.Use
the other overloadwhich has better encapsulation unless you have a specific reason to use this one.Calling this method does not emit the quad.
- Specified by:
fromVanillain interfaceMutableQuadView
-
fromVanilla
QuadEmitter fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable @Nullable Direction cullFace) Description copied from interface:MutableQuadViewEnables bulk vertex data transfer using the standard Minecraft quad format.The material applied to this quad view might be slightly different from the
materialparameter regarding diffuse shading. If either the baked quaddoes not have shadeor the materialdoes not have shade, diffuse shading will be disabled for this quad view. This is reflected in the quad view'sQuadView.material(), but thematerialparameter is unchanged (it is immutable anyway).The baked quad's light emission will be applied to the lightmap values from the vertex data after copying.
Calling this method resets the
QuadView.tag().Calling this method does not emit the quad.
- Specified by:
fromVanillain interfaceMutableQuadView
-
square
default QuadEmitter square(Direction nominalFace, float left, float bottom, float right, float top, float depth) Helper method to assign vertex coordinates for a square aligned with the given face. Ensures that vertex order is consistent with vanilla convention. (Incorrect order can lead to bad AO lighting unless enhanced lighting logic is available/enabled.)Square will be parallel to the given face and coplanar with the face (and culled if the face is occluded) if the depth parameter is approximately zero. See
CULL_FACE_EPSILON.All coordinates should be normalized (0-1).
-
pushTransform
Pushed transforms will be applied immediately after every call toemit()and before the quad data is delivered to its destination. If any transform returnsfalse, the emitted quad will be discarded and will not be delivered to its destination.You MUST call
popTransform()once you are done using this emitter in the current scope.More than one transformer can be pushed. Transformers are applied in reverse order. (Last pushed is applied first.)
Using
thisemitter from inside the pushed quad transform is not supported. -
popTransform
void popTransform()Removes the transformer added by the last call topushTransform(QuadTransform). MUST be called once you are done using this emitter in the current scope. -
emit
QuadEmitter emit()In static mesh building, causes quad to be appended to the mesh being built. In a dynamic render context, create a new quad to be output to rendering. In both cases, current instance is reset to default values.
-