use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class PipeWireRenderer method renderQuads.
private static void renderQuads(MutableQuad[] quads, ISprite sprite, int level) {
VertexFormat vf = DefaultVertexFormats.POSITION_TEX_COLOR;
Tessellator tessellator = new Tessellator(quads.length * vf.getNextOffset());
BufferBuilder bb = tessellator.getBuffer();
bb.begin(GL11.GL_QUADS, vf);
float vOffset = (level & 0xF) / 16f;
for (MutableQuad q : quads) {
if (q.getFace() != EnumFacing.UP && level != 15) {
q = new MutableQuad(q);
float shade = 1 - q.getCalculatedDiffuse();
shade = shade * (15 - level) / 15;
shade = 1 - shade;
q.multColourd(shade);
}
renderVertex(bb, q.vertex_0, sprite, vOffset);
renderVertex(bb, q.vertex_1, sprite, vOffset);
renderVertex(bb, q.vertex_2, sprite, vOffset);
renderVertex(bb, q.vertex_3, sprite, vOffset);
}
tessellator.draw();
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class RobotStationModel method textureStitchPost.
@SubscribeEvent
public void textureStitchPost(TextureStitchEvent.Post post) {
for (final EnumRobotStationState state : EnumRobotStationState.values()) {
Matrix4f translation = new Matrix4f();
translation.setIdentity();
translation.setTranslation(new Vector3f(2.8f / 16f, 0, 0));
List<MutableQuad> quads = Lists.newArrayList();
for (MutableQuad mutable : BuildCraftBakedModel.createQuadsItemLayer(stateSprites.get(state))) {
mutable.transform(translation);
mutable.colouri(0xFF_FF_FF_FF);
quads.add(mutable);
}
stateQuads.put(state, quads);
}
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class RobotStationModel method bakeCutout.
private List<BakedQuad> bakeCutout(EnumRobotStationState state, EnumFacing face, VertexFormat format) {
IModel base = modelBase();
List<MutableQuad> stateQuads = this.stateQuads.get(state);
List<BakedQuad> quads = Lists.newArrayList();
if (base != null) {
Matrix4f matrix = MatrixUtil.rotateTowardsFace(face);
for (MutableQuad mutable : baseQuads()) {
mutable = new MutableQuad(mutable);
mutable.transform(matrix);
Vector3f normal = mutable.getCalculatedNormal();
mutable.normalv(normal);
float diffuse = MutableQuad.diffuseLight(normal);
mutable.colourf(diffuse, diffuse, diffuse, 1);
ModelUtil.appendBakeQuads(quads, format, mutable);
}
if (stateQuads != null) {
for (MutableQuad mutable : stateQuads) {
mutable = new MutableQuad(mutable);
mutable.transform(matrix);
Vector3f normal = mutable.getCalculatedNormal();
mutable.normalv(normal);
float diffuse = MutableQuad.diffuseLight(normal);
mutable.colourf(diffuse, diffuse, diffuse, 1);
ModelUtil.appendBakeQuads(quads, format, mutable);
}
}
}
return quads;
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class VariablePartTextureExpand method addQuads.
@Override
public void addQuads(List<MutableQuad> addTo, ITextureGetter spriteLookup) {
if (visible.evaluate()) {
float[] f = bakePosition(from);
float[] t = bakePosition(to);
float[] size = { t[0] - f[0], t[1] - f[1], t[2], f[2] };
boolean s = shade.evaluate();
int l = (int) (light.evaluate() & 15);
int rgba = RenderUtil.swapARGBforABGR((int) colour.evaluate());
VariableFaceData data = faceUv.evaluate(spriteLookup);
// TODO: Use the UV data! (only take part of the texture)
ItemLayerModel model = new ItemLayerModel(ImmutableList.of(new ResourceLocation(".")));
IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.ITEM, (loc) -> data.sprite);
List<BakedQuad> quads = baked.getQuads(null, null, 0);
for (BakedQuad q : quads) {
MutableQuad mut = new MutableQuad();
mut.fromBakedItem(q);
mut.translated(0, 0, -(7.5 / 16.0));
mut.scaled(1, 1, 16);
mut.rotate(EnumFacing.SOUTH, evaluateFace(this.face), 0.5f, 0.5f, 0.5f);
mut.scalef(size[0], size[1], size[2]);
mut.translated(f[0], f[1], f[2]);
mut.setCalculatedNormal();
mut.setShade(s);
mut.lighti(l, 0);
mut.colouri(rgba);
mut.setSprite(data.sprite);
addTo.add(mut);
}
}
}
use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.
the class JsonQuad method toQuad.
public MutableQuad toQuad(TextureAtlasSprite sprite) {
MutableQuad quad = new MutableQuad(tint, face, shade);
vertices[0].loadInto(quad.vertex_0);
vertices[1].loadInto(quad.vertex_1);
vertices[2].loadInto(quad.vertex_2);
vertices[3].loadInto(quad.vertex_3);
if (sprite != null) {
quad.texFromSprite(sprite);
quad.setSprite(sprite);
}
return quad;
}
Aggregations