private List<BakedQuad> fixQuadTint( EnumFacing facing, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright ) { List<BakedQuad> quads = this.baseModel.getQuads( null, facing, 0 ); List<BakedQuad> result = new ArrayList<>( quads.size() ); for( BakedQuad quad : quads ) { int tint; if( quad.getSprite() == texDark ) { tint = 1; } else if( quad.getSprite() == texMedium ) { tint = 2; } else if( quad.getSprite() == texBright ) { tint = 3; } else { result.add( quad ); continue; } BakedQuad newQuad = new BakedQuad( quad.getVertexData(), tint, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad .getFormat() ); result.add( newQuad ); } return result; }
public BakedQuad recolorQuad(BakedQuad quad, int color) { int[] vertexData = quad.getVertexData(); for (int i = 0; i < 4; i++) { vertexData[v * i + c] = color; } return quad; }
int[] newData = quad.getVertexData().clone();
BakedQuad packedQuad = new BakedQuad( unpackedQuad.getVertexData(), quad.getTintIndex(), unpackedQuad.getFace(), quad.getSprite(), quad .shouldApplyDiffuseLighting(), quad.getFormat() ); rotated.add( packedQuad );
public BakedTintedQuad(BakedQuad quad) { super(Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length), 1, FaceBakery.getFacingFromVertexData(quad.getVertexData()), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()); } }
/** * Offsets the z coordinate and color the quads * @param quads The original quads * @param offset The offset to apply * @param color The color * @return The offsetted quads */ private Collection<? extends BakedQuad> offsetAndColor(List<BakedQuad> quads, float offset, int color) { List<BakedQuad> offsetQuads = Lists.newArrayListWithExpectedSize(quads.size()); for (BakedQuad quad : quads) { int[] vertexData = Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length); for(int i = 0; i < vertexData.length / 7; i++) { float originalZ = Float.intBitsToFloat(vertexData[i * 7 + 2]); originalZ += offset; vertexData[i * 7 + 2] = Float.floatToIntBits(originalZ); vertexData[i * 7 + 3] = color; } offsetQuads.add(new BakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), false, DefaultVertexFormats.ITEM)); } return offsetQuads; }
/** * Color the quads * @param quads The original quads * @param color The color * @return The colored quads */ private Collection<? extends BakedQuad> color(List<BakedQuad> quads, int color) { List<BakedQuad> offsetQuads = Lists.newArrayListWithExpectedSize(quads.size()); for (BakedQuad quad : quads) { int[] vertexData = Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length); for(int i = 0; i < vertexData.length / 7; i++) { vertexData[i * 7 + 3] = color; } offsetQuads.add(new BakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), false, DefaultVertexFormats.ITEM)); } return offsetQuads; }
@Override public List<BakedQuad> getGeneralQuads() { List<BakedQuad> quads = Lists.newLinkedList(); // Base chalice model quads.addAll(chaliceModel.getQuads(blockState, facing, rand)); // Colored gems int color = getColorSeed(this.id); for(BakedQuad quad : gemsModel.getQuads(blockState, facing, rand)) { int[] data = quad.getVertexData(); for(int i = 0; i < data.length / 7; i++) { data[i * 7 + 3] = color; } quads.add(new BakedQuad(data, quad.getTintIndex(), quad.getFace(), quad.getSprite(), true, DefaultVertexFormats.ITEM)); } // Fluid if(fluidStack != null) { quads.addAll(getFluidQuads(fluidStack, TileEntangledChalice.BASE_CAPACITY)); } return quads; }
/** * Renders a baked model from the resource location pointing to the model JSON. * <b>Always draw after calling this method, otherwise the vertex will never finish building!</b> * @param buffer The VertexBuffer * @param modelLocation The model, do not include .json */ public static void renderModel(BufferBuilder buffer, ResourceLocation modelLocation) { buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM); IBakedModel model = bakeModel(modelLocation); for (BakedQuad quad : model.getQuads(null, null, 0)) { buffer.addVertexData(quad.getVertexData()); } } }
public void renderSphere(int color) { List<BakedQuad> quadList = star_model.getQuads(null, null, 0); for (BakedQuad quad : quadList) { Tessellator.getInstance().getBuffer().addVertexData(quad.getVertexData()); Tessellator.getInstance().getBuffer().putColor4(color); //LightUtil.renderQuadColorSlow(Tessellator.getInstance().getBuffer(),quad,color); //LightUtil.renderQuadColor(Tessellator.getInstance().getBuffer(),quad,new Color(color).getColor()+0x00ff); } } }
private static BakedQuad tint(PartInfo.ClientInfo info, BakedQuad quad) { return quad.hasTintIndex() ? new BakedQuad(quad.getVertexData(), info.getTint(quad.getTintIndex()), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()) : quad; }
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if (bakedQuads.isEmpty()) { IModel crateModel = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(Constants.MOD_ID + ":item/crate-filled")); IBakedModel bakedModel = crateModel.bake(ModelManager.getInstance().getDefaultItemState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE); //Set the crate color index to 100 for (BakedQuad quad : bakedModel.getQuads(null, null, 0L)) { bakedQuads.add(new BakedQuad(quad.getVertexData(), 100, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat())); } } IBakedModel model; List<BakedQuad> quads = new LinkedList<>(bakedQuads); IBakedModel contentModel = getCustomContentModel(); if (contentModel == null) { model = new ModelCrateBaked(quads, contained); } else { quads.addAll(contentModel.getQuads(null, null, 0)); model = new ModelCrateBaked(quads); } return new PerspectiveMapWrapper(model, ModelManager.getInstance().getDefaultItemState()); } }
private void tesseleteHelix(int fromSegment, int toSegment, List<BakedQuad> quadList, int color) { for (int i = fromSegment; i < toSegment; i++) { for (BakedQuad quad : quadList) { Tessellator.getInstance().getBuffer().addVertexData(quad.getVertexData()); Tessellator.getInstance().getBuffer().putColor4(color); Tessellator.getInstance().getBuffer().putPosition(0, 129.7 * i, 0); } } }
protected void renderObelisk() { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableRescaleNormal(); RenderUtil.bindBlockTexture(); BufferBuilder tes = Tessellator.getInstance().getBuffer(); tes.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM); for (BakedQuad quad : bakedQuads) { tes.addVertexData(quad.getVertexData()); } Tessellator.getInstance().draw(); GlStateManager.disableRescaleNormal(); }
final VertexFormat format ) final int[] vertData = g.getVertexData(); final int wrapAt = vertData.length / 4;