Search in sources :

Example 16 with MutableQuad

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();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 17 with MutableQuad

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);
    }
}
Also used : Matrix4f(javax.vecmath.Matrix4f) Vector3f(javax.vecmath.Vector3f) EnumRobotStationState(buildcraft.robotics.RobotStationPluggable.EnumRobotStationState) MutableQuad(buildcraft.lib.client.model.MutableQuad) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 18 with MutableQuad

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;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IModel(net.minecraftforge.client.model.IModel) Matrix4f(javax.vecmath.Matrix4f) Vector3f(javax.vecmath.Vector3f) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 19 with MutableQuad

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);
        }
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ItemLayerModel(net.minecraftforge.client.model.ItemLayerModel) ResourceLocation(net.minecraft.util.ResourceLocation) VariableFaceData(buildcraft.lib.client.model.json.VariablePartCuboidBase.VariableFaceData) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 20 with MutableQuad

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;
}
Also used : MutableQuad(buildcraft.lib.client.model.MutableQuad)

Aggregations

MutableQuad (buildcraft.lib.client.model.MutableQuad)31 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)19 Matrix4f (javax.vecmath.Matrix4f)11 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)10 Vector3f (javax.vecmath.Vector3f)8 IModel (net.minecraftforge.client.model.IModel)8 EnumFacing (net.minecraft.util.EnumFacing)7 IFlexibleBakedModel (net.minecraftforge.client.model.IFlexibleBakedModel)6 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 Vec3d (net.minecraft.util.math.Vec3d)3 UvFaceData (buildcraft.lib.client.model.ModelUtil.UvFaceData)2 Tuple3f (javax.vecmath.Tuple3f)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 Profiler (net.minecraft.profiler.Profiler)2 Axis (net.minecraft.util.EnumFacing.Axis)2 ItemLayerModel (net.minecraftforge.client.model.ItemLayerModel)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EnumPipePart (buildcraft.api.core.EnumPipePart)1 EntityResizableCuboid (buildcraft.core.lib.EntityResizableCuboid)1