Interface QuadEmitter

All Superinterfaces:
MutableQuadView, QuadView

public interface QuadEmitter extends MutableQuadView
Specialized MutableQuadView obtained via MeshBuilder.getEmitter() to append quads during mesh building.

Also obtained from RenderContext.getEmitter() to submit dynamic quads one-by-one at render time.

Instances of QuadEmitter will practically always be threadlocal and/or reused - do not retain references.

Only the renderer should implement or extend this interface.

  • Field Details

  • Method Details

    • pos

      QuadEmitter pos(int vertexIndex, float x, float y, float z)
      Description copied from interface: MutableQuadView
      Sets 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:
      pos in interface MutableQuadView
    • pos

      default QuadEmitter pos(int vertexIndex, org.joml.Vector3f pos)
      Description copied from interface: MutableQuadView
      Same as MutableQuadView.pos(int, float, float, float) but accepts vector type.
      Specified by:
      pos in interface MutableQuadView
    • color

      QuadEmitter color(int vertexIndex, int color)
      Description copied from interface: MutableQuadView
      Set vertex color.
      Specified by:
      color in interface MutableQuadView
    • color

      default QuadEmitter color(int c0, int c1, int c2, int c3)
      Description copied from interface: MutableQuadView
      Convenience: set vertex color for all vertices at once.
      Specified by:
      color in interface MutableQuadView
    • uv

      QuadEmitter uv(int vertexIndex, float u, float v)
      Description copied from interface: MutableQuadView
      Set texture coordinates.
      Specified by:
      uv in interface MutableQuadView
    • uv

      default QuadEmitter uv(int vertexIndex, org.joml.Vector2f uv)
      Description copied from interface: MutableQuadView
      Set texture coordinates.

      Only use this function if you already have a Vector2f. Otherwise, see MutableQuadView.uv(int, float, float).

      Specified by:
      uv in interface MutableQuadView
    • spriteBake

      QuadEmitter spriteBake(Sprite sprite, int bakeFlags)
      Description copied from interface: MutableQuadView
      Assigns 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:
      spriteBake in interface MutableQuadView
    • uvUnitSquare

      default QuadEmitter uvUnitSquare()
    • lightmap

      QuadEmitter lightmap(int vertexIndex, int lightmap)
      Description copied from interface: MutableQuadView
      Accept 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:
      lightmap in interface MutableQuadView
    • lightmap

      default QuadEmitter lightmap(int b0, int b1, int b2, int b3)
      Description copied from interface: MutableQuadView
      Convenience: set lightmap for all vertices at once.

      For emissive rendering, it is better to use MaterialFinder.emissive(boolean). See MutableQuadView.lightmap(int, int).

      Specified by:
      lightmap in interface MutableQuadView
    • normal

      QuadEmitter normal(int vertexIndex, float x, float y, float z)
      Description copied from interface: MutableQuadView
      Adds 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.

      Renderer implementations 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:
      normal in interface MutableQuadView
    • normal

      default QuadEmitter normal(int vertexIndex, org.joml.Vector3f normal)
      Description copied from interface: MutableQuadView
      Same as MutableQuadView.normal(int, float, float, float) but accepts vector type.
      Specified by:
      normal in interface MutableQuadView
    • cullFace

      QuadEmitter cullFace(@Nullable @Nullable Direction face)
      Description copied from interface: MutableQuadView
      If 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 by QuadView.lightFace().

      Specified by:
      cullFace in interface MutableQuadView
    • nominalFace

      QuadEmitter nominalFace(@Nullable @Nullable Direction face)
      Description copied from interface: MutableQuadView
      Provides 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 of QuadView.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:
      nominalFace in interface MutableQuadView
    • material

      QuadEmitter material(RenderMaterial material)
      Description copied from interface: MutableQuadView
      Assigns a different material to this quad. Useful for transformation of existing meshes because lighting and texture blending are controlled by material.
      Specified by:
      material in interface MutableQuadView
    • colorIndex

      QuadEmitter colorIndex(int colorIndex)
      Description copied from interface: MutableQuadView
      Value functions identically to BakedQuad.getColorIndex() and is used by renderer / model builder in same way. Default value is -1.
      Specified by:
      colorIndex in interface MutableQuadView
    • tag

      QuadEmitter tag(int tag)
      Description copied from interface: MutableQuadView
      Encodes an integer tag with this quad that can later be retrieved via QuadView.tag(). Useful for models that want to perform conditional transformation or filtering on static meshes.
      Specified by:
      tag in interface MutableQuadView
    • copyFrom

      QuadEmitter copyFrom(QuadView quad)
      Description copied from interface: MutableQuadView
      Copies all quad properties from the given QuadView to this quad.

      Calling this method does not emit the quad.

      Specified by:
      copyFrom in interface MutableQuadView
    • fromVanilla

      QuadEmitter fromVanilla(int[] quadData, int startIndex)
      Description copied from interface: MutableQuadView
      Enables bulk vertex data transfer using the standard Minecraft vertex formats. Only the quad vertex data is copied. This method should be performant whenever caller's vertex representation makes it feasible.

      Use the other overload which has better encapsulation unless you have a specific reason to use this one.

      Calling this method does not emit the quad.

      Specified by:
      fromVanilla in interface MutableQuadView
    • fromVanilla

      QuadEmitter fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable @Nullable Direction cullFace)
      Description copied from interface: MutableQuadView
      Enables bulk vertex data transfer using the standard Minecraft quad format.

      Calling this method does not emit the quad.

      The material applied to this quad view might be slightly different from the material parameter regarding diffuse shading. If either the baked quad does not have shade or the material does not have shade, diffuse shading will be disabled for this quad view. This is reflected in the quad view's QuadView.material(), but the material parameter is unchanged (it is immutable anyway).

      Specified by:
      fromVanilla in interface MutableQuadView
    • 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).

    • 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.
    • spriteColor

      @Deprecated default QuadEmitter spriteColor(int vertexIndex, int spriteIndex, int color)
      Deprecated.
      Specified by:
      spriteColor in interface MutableQuadView
    • spriteColor

      @Deprecated default QuadEmitter spriteColor(int spriteIndex, int c0, int c1, int c2, int c3)
      Deprecated.
      Specified by:
      spriteColor in interface MutableQuadView
    • sprite

      @Deprecated default QuadEmitter sprite(int vertexIndex, int spriteIndex, float u, float v)
      Deprecated.
      Specified by:
      sprite in interface MutableQuadView
    • sprite

      @Deprecated default QuadEmitter sprite(int vertexIndex, int spriteIndex, Vec2f uv)
      Deprecated.
      Specified by:
      sprite in interface MutableQuadView
    • spriteBake

      @Deprecated default QuadEmitter spriteBake(int spriteIndex, Sprite sprite, int bakeFlags)
      Deprecated.
      Specified by:
      spriteBake in interface MutableQuadView
    • spriteUnitSquare

      @Deprecated default QuadEmitter spriteUnitSquare(int spriteIndex)
      Deprecated.
      Use uvUnitSquare() instead.
    • fromVanilla

      @Deprecated default QuadEmitter fromVanilla(int[] quadData, int startIndex, boolean isItem)
      Deprecated.
      Specified by:
      fromVanilla in interface MutableQuadView