Interface QuadEmitter

All Superinterfaces:
MutableQuadView, QuadView

public interface QuadEmitter extends MutableQuadView
Specialized 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 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.

      The default value for all vertices is 0.0f.

      Specified by:
      pos in interface MutableQuadView
    • pos

      default QuadEmitter pos(int vertexIndex, org.joml.Vector3f pos)
      Description copied from interface: MutableQuadView
      Sets the geometric position for the given vertex. Only use this method if you already have a Vector3f. Otherwise, use MutableQuadView.pos(int, float, float, float).
      Specified by:
      pos in interface MutableQuadView
    • pos

      default QuadEmitter pos(int vertexIndex, org.joml.Vector3fc pos)
      Description copied from interface: MutableQuadView
      Sets the geometric position for the given vertex. Only use this method if you already have a Vector3fc. Otherwise, use MutableQuadView.pos(int, float, float, float).
      Specified by:
      pos in interface MutableQuadView
    • color

      QuadEmitter color(int vertexIndex, int color)
      Description copied from interface: MutableQuadView
      Sets the color in ARGB format (0xAARRGGBB) for the given vertex.

      The default value for all vertices is 0xFFFFFFFF.

      Specified by:
      color in interface MutableQuadView
    • color

      default QuadEmitter color(int c0, int c1, int c2, int c3)
      Description copied from interface: MutableQuadView
      Sets the color in ARGB format (0xAARRGGBB) for all vertices at once.
      Specified by:
      color in interface MutableQuadView
      See Also:
    • uv

      QuadEmitter uv(int vertexIndex, float u, float v)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for the given vertex.

      The default value for all vertices is 0.0f.

      Specified by:
      uv in interface MutableQuadView
    • uv

      default QuadEmitter uv(int vertexIndex, org.joml.Vector2f uv)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for the given vertex. Only use this method if you already have a Vector2f. Otherwise, use MutableQuadView.uv(int, float, float).
      Specified by:
      uv in interface MutableQuadView
    • uv

      default QuadEmitter uv(int vertexIndex, org.joml.Vector2fc uv)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for the given vertex. Only use this method if you already have a Vector2fc. Otherwise, use MutableQuadView.uv(int, float, float).
      Specified by:
      uv in interface MutableQuadView
    • spriteBake

      default QuadEmitter spriteBake(Sprite sprite, int bakeFlags)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for all vertices using 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
      Sets the minimum lightmap value for the given vertex. 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, prefer using MutableQuadView.emissive(boolean).

      The default value for all vertices is 0.

      Specified by:
      lightmap in interface MutableQuadView
    • lightmap

      default QuadEmitter lightmap(int l0, int l1, int l2, int l3)
      Description copied from interface: MutableQuadView
      Sets the lightmap value for all vertices at once.

      For emissive rendering, prefer using MutableQuadView.emissive(boolean).

      Specified by:
      lightmap in interface MutableQuadView
      See Also:
    • normal

      QuadEmitter normal(int vertexIndex, float x, float y, float z)
      Description copied from interface: MutableQuadView
      Sets the normal vector for the given vertex. The face normal is used when no vertex normal is provided. Models that have per-vertex normals should include them to get correct lighting when it matters.
      Specified by:
      normal in interface MutableQuadView
    • normal

      default QuadEmitter normal(int vertexIndex, org.joml.Vector3f normal)
      Description copied from interface: MutableQuadView
      Sets the normal vector for the given vertex. Only use this method if you already have a Vector3f. Otherwise, use MutableQuadView.normal(int, float, float, float).
      Specified by:
      normal in interface MutableQuadView
    • normal

      default QuadEmitter normal(int vertexIndex, org.joml.Vector3fc normal)
      Description copied from interface: MutableQuadView
      Sets the normal vector for the given vertex. Only use this method if you already have a Vector3fc. Otherwise, use MutableQuadView.normal(int, float, float, float).
      Specified by:
      normal in interface MutableQuadView
    • nominalFace

      QuadEmitter nominalFace(@Nullable @Nullable Direction face)
      Description copied from interface: MutableQuadView
      Sets the nominal face, which provides a hint to the renderer about the facing of this quad. It is not required, but if set, should be the expected value of QuadView.lightFace(). It may be used to shortcut geometric analysis, if the provided value was correct; otherwise, it is ignored.

      The nominal face is also used for MutableQuadView.spriteBake(Sprite, int) with MutableQuadView.BAKE_LOCK_UV.

      When MutableQuadView.cullFace(Direction) is called, it also sets the nominal face.

      The default value is null.

      This property is transient. It is set to the same value as QuadView.lightFace() when a quad is decoded.

      Specified by:
      nominalFace in interface MutableQuadView
    • cullFace

      QuadEmitter cullFace(@Nullable @Nullable Direction face)
      Description copied from interface: MutableQuadView
      Sets the cull face. This quad will not be rendered if its cull face is non-null and the block is occluded by another block in the direction of the cull face.

      The cull face is different from BakedQuad.face(), which is equivalent to QuadView.lightFace(). The light face is computed based on geometry and must be non-null.

      When called, sets MutableQuadView.nominalFace(Direction) to the same value.

      The default value is null.

      This property is respected only in block contexts. It will not have an effect in other contexts.

      Specified by:
      cullFace in interface MutableQuadView
    • renderLayer

      QuadEmitter renderLayer(@Nullable @Nullable BlockRenderLayer renderLayer)
      Description copied from interface: MutableQuadView
      Controls how this quad's pixels should be blended with the scene.

      If set to null, RenderLayers.getBlockLayer(BlockState) will be used to retrieve the render layer in block contexts and the render layer of the state layer will be used in item contexts. Set to another value to override this behavior.

      In block contexts, a non-null value will be used directly. In item contexts, a non-null value will be converted to a RenderLayer using RenderLayerHelper.getEntityBlockLayer(BlockRenderLayer).

      The default value is null.

      Specified by:
      renderLayer in interface MutableQuadView
    • emissive

      QuadEmitter emissive(boolean emissive)
      Description copied from interface: MutableQuadView
      When true, this quad will be rendered at full brightness. Lightmap values provided via QuadView.lightmap(int) will be ignored.

      This is the preferred method for emissive lighting effects as some renderers with advanced lighting pipelines may not use lightmaps.

      Note that vertex colors will still be modified by diffuse shading and ambient occlusion, unless disabled via MutableQuadView.diffuseShade(boolean) and MutableQuadView.ambientOcclusion(TriState).

      The default value is false.

      Specified by:
      emissive in interface MutableQuadView
    • diffuseShade

      QuadEmitter diffuseShade(boolean shade)
      Description copied from interface: MutableQuadView
      Controls whether vertex colors should be modified for diffuse shading.

      The default value is true.

      This property is guaranteed to be respected in block contexts. Some renderers may also respect it in item contexts, but this is not guaranteed.

      Specified by:
      diffuseShade in interface MutableQuadView
    • ambientOcclusion

      QuadEmitter ambientOcclusion(TriState ao)
      Description copied from interface: MutableQuadView
      Controls whether vertex colors should be modified for ambient occlusion.

      If set to TriState.DEFAULT, ambient occlusion will be used if the block state has a luminance of 0. Set to TriState.TRUE or TriState.FALSE to override this behavior. TriState.TRUE will not have an effect if ambient occlusion is disabled globally.

      The default value is TriState.DEFAULT.

      This property is respected only in block contexts. It will not have an effect in other contexts.

      Specified by:
      ambientOcclusion in interface MutableQuadView
    • glint

      QuadEmitter glint(@Nullable ItemRenderState.Glint glint)
      Description copied from interface: MutableQuadView
      Controls how glint should be applied.

      If set to null, glint will be applied in item contexts based on the glint type of the layer. Set to another value to override this behavior.

      The default value is null.

      This property is guaranteed to be respected in item contexts. Some renderers may also respect it in block contexts, but this is not guaranteed.

      Specified by:
      glint in interface MutableQuadView
    • shadeMode

      QuadEmitter shadeMode(ShadeMode mode)
      Description copied from interface: MutableQuadView
      A hint to the renderer about how this quad is intended to be shaded, for example through ambient occlusion and diffuse shading. The renderer is free to ignore this hint.

      The default value is ShadeMode.ENHANCED.

      This property is respected only in block contexts. It will not have an effect in other contexts.

      Specified by:
      shadeMode in interface MutableQuadView
      See Also:
    • tintIndex

      QuadEmitter tintIndex(int tintIndex)
      Description copied from interface: MutableQuadView
      Sets the tint index, which is used to retrieve the tint color.

      The default value is -1.

      Specified by:
      tintIndex in interface MutableQuadView
    • tag

      QuadEmitter tag(int tag)
      Description copied from interface: MutableQuadView
      Sets the tag, which is an arbitrary integer that is meant to be encoded into Meshes to later allow performing conditional transformation or filtering on their quads.

      The default value is 0.

      Specified by:
      tag in interface MutableQuadView
    • copyFrom

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

      Calling this method does not emit this quad.

      Specified by:
      copyFrom in interface MutableQuadView
    • fromVanilla

      QuadEmitter fromVanilla(int[] vertexData, int startIndex)
      Description copied from interface: MutableQuadView
      Sets this quad's vertex data for all vertices using data in given array, starting at the given index. The array must have at least QuadView.VANILLA_QUAD_STRIDE elements starting at the given index. The format of the data must be the same as BakedQuad.vertexData(). This quad's lightmap values and normals will be set even though vanilla does not decode them from packed vertex data.

      Prefer using MutableQuadView.fromBakedQuad(BakedQuad) instead if you have a BakedQuad.

      Calling this method does not emit this quad.

      Specified by:
      fromVanilla in interface MutableQuadView
    • fromBakedQuad

      QuadEmitter fromBakedQuad(BakedQuad quad)
      Description copied from interface: MutableQuadView
      Sets all applicable data and properties of this quad as specified by the given BakedQuad. This quad's lightmap values and normals will be set even though vanilla does not decode them from packed vertex data. The baked quad's light emission will be applied to the lightmap values from the vertex data after copying.

      Calling this method does not emit this quad.

      Specified by:
      fromBakedQuad 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).

    • pushTransform

      void pushTransform(QuadTransform transform)
      Pushed transforms will be applied immediately after every call to emit() and before the quad data is delivered to its destination. If any transform returns false, 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 this emitter from inside the pushed quad transform is not supported.

    • popTransform

      void popTransform()
      Removes the transformer added by the last call to pushTransform(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.