use of com.infinityraider.infinitylib.render.tessellation.ITessellator in project AgriCraft by AgriCraft.
the class AgriPlantQuadGenerator method bakeQuadsForHashPattern.
@Nonnull
@Override
public List<BakedQuad> bakeQuadsForHashPattern(IAgriGrowable plant, IAgriGrowthStage stage, @Nullable Direction face, IntFunction<TextureAtlasSprite> spriteFunc) {
if (face != null) {
return ImmutableList.of();
}
ITessellator tessellator = this.getTessellator();
tessellator.startDrawingQuads();
tessellator.setFace((Direction) null);
tessellator.pushMatrix();
double height = plant.getPlantHeight(stage);
int layer = 0;
int layers = (int) Math.ceil(height / 16.0);
while ((16 * layer) < height) {
TextureAtlasSprite sprite = spriteFunc.apply(layers - layer - 1);
tessellator.drawScaledFaceDouble(0, 0, 16, 16, Direction.NORTH, sprite, 4);
tessellator.drawScaledFaceDouble(0, 0, 16, 16, Direction.EAST, sprite, 4);
tessellator.drawScaledFaceDouble(0, 0, 16, 16, Direction.NORTH, sprite, 12);
tessellator.drawScaledFaceDouble(0, 0, 16, 16, Direction.EAST, sprite, 12);
tessellator.translate(0, 1, 0);
layer++;
}
tessellator.popMatrix();
List<BakedQuad> quads = tessellator.getQuads();
tessellator.draw();
return quads;
}
use of com.infinityraider.infinitylib.render.tessellation.ITessellator in project AgriCraft by AgriCraft.
the class TileEntityIrrigationTankRenderer method renderWater.
@Override
protected void renderWater(TileEntityIrrigationTank tile, float partialTicks, MatrixStack transforms, IRenderTypeBuffer.Impl buffer, int light, int overlay) {
float level = tile.getRenderLevel(partialTicks) - tile.getPos().getY();
if (tile.getContent() <= 0) {
return;
}
if (level > 1) {
return;
}
ITessellator tessellator = this.getTessellator(buffer);
this.applyWaterColor(tile, tessellator.startDrawingQuads()).setBrightness(light).setOverlay(overlay).pushMatrix();
tessellator.applyTransformation(transforms.getLast().getMatrix());
tessellator.drawScaledFace(0, 0, 16, 16, Direction.UP, this.getWaterTexture(), Constants.WHOLE * level);
tessellator.popMatrix().draw();
}
use of com.infinityraider.infinitylib.render.tessellation.ITessellator in project AgriCraft by AgriCraft.
the class JournalItemRenderer method renderJournalOpen.
protected void renderJournalOpen(ItemCameraTransforms.TransformType perspective, MatrixStack transforms, ItemStack stack, IAgriJournalItem journal, IRenderTypeBuffer.Impl buffer, int light, int overlay) {
// Fetch animation progress
float openProgress = JournalViewPointHandler.getInstance().getOpeningProgress(this.getPartialTick());
float flipProgress = JournalViewPointHandler.getInstance().getFlippingProgress(this.getPartialTick());
// Apply transformations to the stack
transforms.push();
this.applyTransformations(perspective, transforms);
if (!perspective.isFirstPerson()) {
transforms.rotate(Vector3f.ZP.rotationDegrees(90 * openProgress));
}
// Fetch tessellator
ITessellator tessellator = this.getTessellator(buffer);
// Draw book back
this.drawOpenBack(tessellator, transforms, openProgress, light, overlay);
// Draw book right side
this.drawOpenRight(tessellator, transforms, stack, journal, openProgress, flipProgress, light, overlay);
// Draw left side
this.drawOpenLeft(tessellator, transforms, stack, journal, openProgress, light, overlay);
// Draw page flip
this.drawOpenFlipped(tessellator, transforms, stack, journal, flipProgress, light, overlay);
// Pop transformations from the stack
transforms.pop();
}
use of com.infinityraider.infinitylib.render.tessellation.ITessellator in project AgriCraft by AgriCraft.
the class JournalItemRenderer method renderJournalClosed.
protected void renderJournalClosed(ItemCameraTransforms.TransformType perspective, MatrixStack transforms, IRenderTypeBuffer.Impl buffer, int light, int overlay) {
// Apply transformations to the stack
transforms.push();
this.applyTransformations(perspective, transforms);
// Fetch tessellator and start drawing
ITessellator tessellator = this.getTessellator(buffer);
tessellator.startDrawingQuads();
// Configure tessellator
tessellator.pushMatrix();
tessellator.applyTransformation(transforms.getLast().getMatrix());
tessellator.setBrightness(light).setOverlay(overlay);
// Draw Book
tessellator.setColorRGB(COLOR_COVER).drawScaledPrism(0, -T_TOTAL / 2, -HEIGHT, WIDTH, T_COVER - T_TOTAL / 2, 0);
tessellator.setColorRGB(COLOR_PAGE).drawScaledPrism(0.5F, T_COVER - T_TOTAL / 2, -HEIGHT + 0.5F, WIDTH - 0.5F, T_COVER + T_PAPER - T_TOTAL / 2, -0.5F);
tessellator.setColorRGB(COLOR_COVER).drawScaledPrism(0, T_COVER - T_TOTAL / 2, -HEIGHT, 0.5F, T_COVER + T_PAPER - T_TOTAL / 2, 0);
tessellator.setColorRGB(COLOR_COVER).drawScaledPrism(0, T_COVER + T_PAPER - T_TOTAL / 2, -HEIGHT, WIDTH, T_TOTAL / 2, 0);
// Finalize drawing
tessellator.popMatrix();
tessellator.draw();
transforms.pop();
}
use of com.infinityraider.infinitylib.render.tessellation.ITessellator in project AgriCraft by AgriCraft.
the class MysticalAgricultureCompatClient method bakeQuadsForMystical.
@Nonnull
private static List<BakedQuad> bakeQuadsForMystical(IAgriGrowable growable, IAgriGrowthStage stage, @Nullable Direction face, IntFunction<TextureAtlasSprite> spriteFunc) {
if (face != null) {
return ImmutableList.of();
}
ITessellator tessellator = AgriPlantQuadGenerator.getInstance().getTessellator();
TextureAtlasSprite sprite = spriteFunc.apply(0);
tessellator.startDrawingQuads();
tessellator.setFace((Direction) null);
tessellator.pushMatrix();
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 11.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 11.999F, 0, 0, 16, 16);
if (stage.isFinal()) {
IAgriPlant plant = ((IAgriPlant) growable);
int flowerColor = MysticalAgricultureCompatClient.colorForFlower(plant.getId());
TextureAtlasSprite flowerSprite = spriteFunc.apply(1);
if (flowerColor != -1) {
tessellator.setColorRGB(((flowerColor >> 16) & 0xFF) / 255.0F, ((flowerColor >> 8) & 0xFF) / 255.0F, ((flowerColor) & 0xFF) / 255.0F);
}
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, flowerSprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, flowerSprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, flowerSprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, flowerSprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, flowerSprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, flowerSprite, 11.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, flowerSprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, flowerSprite, 11.999F, 0, 0, 16, 16);
}
tessellator.translate(0, 12.0F / 16.0F, 0);
tessellator.popMatrix();
List<BakedQuad> quads = tessellator.getQuads();
tessellator.draw();
return quads;
}
Aggregations