Class BakedPipeline
- All Implemented Interfaces:
IVertexConsumer
The BakedPipeline is final once created, you cannot add or remove elements, you should not need to add or remove them runtime, enable and disable exist.
You must use the Builder class to construct a BakedPipeline, see builder()
Transformers run on a mutable state inside each transformer, allowing for easy reuse. It is recommended to store your pipeline inside a ThreadLocal because 'minecraft'.
Each Transformer should be smart enough to expand itself for each newly sized VertexFormat it comes across, meaning that the internal states for the transformers can be safely shared across VertexFormats, this reduces array creations, and generally makes the system as efficient as it is.
To use the system:
Grab any elements you need to set state data on first, using getElement(String, Class)
transformers should NOT clear their state on pipeline Reset's so set any global data on elements now.
Assuming you are looping over a set of quads to transform, next you need to reset(com.mojang.blaze3d.vertex.VertexFormat) the pipeline,
Now you should disable / enable any optional elements that are needed, NOTE: Element states are reset when resetting
the pipeline.
Now you will need to call prepare(IVertexConsumer) on the pipeline, here you will pass your collector,
usually Quad.
Now final step, simply pipe the quad you want to transform INTO the pipeline 'quad.pipe(pipeline)'
And that's it! hell, Pipe a pipeline into each other for all i care, the system is efficient enough that there
would be no performance penalty for doing so.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe builder associated with the BakedPipeline.static classInternal class, used to hold a PipelineElement's state. -
Method Summary
Modifier and TypeMethodDescriptionstatic BakedPipeline.Builderbuilder()Used to create a BakedPipeline.voiddisableElement(String name) Used to disable an element on the pipeline with the specified name.voidenableElement(String name) Used to enable an element on the pipeline with the specified name.<T extends IPipelineConsumer>
TgetElement(String name, Class<T> clazz) Get an element from the pipeline.com.mojang.blaze3d.vertex.VertexFormatvoidprepare(IVertexConsumer collector) Call when you are ready to use the pipeline.voidput(int element, float... data) voidAssumes the data is already completely unpacked.voidreset(CachedFormat format) Used to reset the pipeline for the next quad.voidreset(com.mojang.blaze3d.vertex.VertexFormat format) Used to reset the pipeline for the next quad.voidsetApplyDiffuseLighting(boolean diffuse) voidsetElementState(String name, boolean enabled) Used to set the state of an element on the pipeline.voidsetQuadOrientation(net.minecraft.core.Direction orientation) voidsetQuadTint(int tint) voidsetTexture(net.minecraft.client.renderer.texture.TextureAtlasSprite texture) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface codechicken.lib.model.IVertexConsumer
put
-
Method Details
-
builder
Used to create a BakedPipeline.- Returns:
- The builder.
-
reset
public void reset(com.mojang.blaze3d.vertex.VertexFormat format) Used to reset the pipeline for the next quad. MUST be called between quads.- Parameters:
format- The format.
-
reset
Used to reset the pipeline for the next quad. MUST be called between quads.- Parameters:
format- The format.
-
getElement
Get an element from the pipeline.- Parameters:
name- The name of the element.clazz- The Class of the element, used to safe cast.- Returns:
- The element.
-
enableElement
Used to enable an element on the pipeline with the specified name.- Parameters:
name- The elements name.
-
disableElement
Used to disable an element on the pipeline with the specified name.- Parameters:
name- The elements name.
-
setElementState
Used to set the state of an element on the pipeline.- Parameters:
name- The name of the element.enabled- The state to set it to.
-
prepare
Call when you are ready to use the pipeline. This builds the internal state of the Elements getting things ready to transform.- Parameters:
collector- The IVertexConsumer that should collect the transformed quad.
-
getVertexFormat
public com.mojang.blaze3d.vertex.VertexFormat getVertexFormat()- Specified by:
getVertexFormatin interfaceIVertexConsumer
-
setQuadTint
public void setQuadTint(int tint) - Specified by:
setQuadTintin interfaceIVertexConsumer
-
setQuadOrientation
public void setQuadOrientation(net.minecraft.core.Direction orientation) - Specified by:
setQuadOrientationin interfaceIVertexConsumer
-
setApplyDiffuseLighting
public void setApplyDiffuseLighting(boolean diffuse) - Specified by:
setApplyDiffuseLightingin interfaceIVertexConsumer
-
setTexture
public void setTexture(net.minecraft.client.renderer.texture.TextureAtlasSprite texture) - Specified by:
setTexturein interfaceIVertexConsumer
-
put
public void put(int element, float... data) - Specified by:
putin interfaceIVertexConsumer
-
put
Description copied from interface:IVertexConsumerAssumes the data is already completely unpacked. You must always copy the data from the quad provided to an internal cache. basically: this.quad.put(quad);- Specified by:
putin interfaceIVertexConsumer- Parameters:
quad- The quad to copy data from.
-