Search in sources :

Example 26 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.

the class ModelPowerAdapter method renderAdapter.

public static List<BakedQuad> renderAdapter(IModel model, TextureAtlasSprite sprite, VertexFormat format) {
    List<BakedQuad> quads = Lists.newArrayList();
    IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
    for (BakedQuad quad : baked.getGeneralQuads()) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.colouri(0xFF_FF_FF_FF);
        ModelUtil.appendBakeQuads(quads, format, mutable);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 27 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.

the class PipeItemModel method create.

public static PipeItemModel create(ItemPipe item, int colorIndex) {
    TextureAtlasSprite sprite = item.getSprite();
    if (sprite == null) {
        sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
    }
    Vec3d center = Utils.VEC_HALF;
    Vec3d radius = new Vec3d(0.25, 0.5, 0.25);
    EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
    cuboid.texture = sprite;
    cuboid.setTextureOffset(new Vec3d(4, 0, 4));
    cuboid.setPosition(center.subtract(radius));
    cuboid.setSize(Utils.multiply(radius, 2));
    List<MutableQuad> unprocessed = Lists.newArrayList();
    List<BakedQuad> quads = Lists.newArrayList();
    RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
    for (MutableQuad quad : unprocessed) {
        quad.normalf(0, 1, 0);
        ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
    }
    unprocessed.clear();
    // Set up the colour
    if (colorIndex != 0) {
        // Very sligthly smaller
        radius = new Vec3d(0.249, 0.499, 0.249);
        cuboid = new EntityResizableCuboid(null);
        cuboid.setTextureOffset(new Vec3d(4, 0, 4));
        cuboid.texture = PipeIconProvider.TYPE.PipeStainedOverlay.getIcon();
        cuboid.setPosition(center.subtract(radius));
        cuboid.setSize(Utils.multiply(radius, 2));
        // Render it into a different list
        RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
        EnumDyeColor dye = EnumDyeColor.byDyeDamage(colorIndex - 1);
        int quadColor = ColorUtils.getLightHex(dye);
        // Add all of the quads we just rendered to the main list
        for (MutableQuad quad : unprocessed) {
            quad.normalf(0, 1, 0);
            quad.setTint(quadColor);
            ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
        }
        unprocessed.clear();
    }
    return new PipeItemModel(ImmutableList.copyOf(quads), sprite);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) EnumDyeColor(net.minecraft.item.EnumDyeColor) Vec3d(net.minecraft.util.math.Vec3d) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 28 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.

the class PlugPluggableModel method renderPlug.

public static List<BakedQuad> renderPlug(IModel model, TextureAtlasSprite sprite, VertexFormat format) {
    List<BakedQuad> quads = Lists.newArrayList();
    IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
    for (BakedQuad quad : baked.getGeneralQuads()) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.colouri(0xFF_FF_FF_FF);
        ModelUtil.appendBakeQuads(quads, format, mutable);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 29 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.

the class GateItemModel method handleItemState.

@Override
public GateItemModel handleItemState(ItemStack stack) {
    KeyPlugGate key = getState(stack);
    if (!map.containsKey(key)) {
        List<BakedQuad> quads = Lists.newArrayList();
        List<MutableQuad> mutableQuads = GatePluggableModel.INSTANCE.renderGate(key, DefaultVertexFormats.ITEM);
        Matrix4f rotation = MatrixUtil.rotateTowardsFace(EnumFacing.SOUTH);
        Matrix4f matScale = new Matrix4f();
        matScale.setIdentity();
        matScale.setScale(2);
        matScale.setTranslation(new Vector3f(-0.5f, -0.5f, -0.5f));
        Matrix4f translateToItem = new Matrix4f();
        translateToItem.setIdentity();
        translateToItem.setTranslation(new Vector3f(0, 0, -0.4f));
        Matrix4f totalMatrix = new Matrix4f();
        totalMatrix.setIdentity();
        totalMatrix.mul(translateToItem);
        totalMatrix.mul(matScale);
        totalMatrix.mul(rotation);
        for (MutableQuad quad : mutableQuads) {
            quad.transform(totalMatrix);
            quad.colouri(0xFF_FF_FF_FF);
            quads.add(quad.toUnpacked(DefaultVertexFormats.ITEM));
        }
        map.put(key, new GateItemModel(ImmutableList.copyOf(quads), null, DefaultVertexFormats.ITEM));
    }
    return map.get(key);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Matrix4f(javax.vecmath.Matrix4f) Vector3f(javax.vecmath.Vector3f) KeyPlugGate(buildcraft.transport.client.model.key.KeyPlugGate) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 30 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.

the class FacadeItemModel method createFacadeItemModel.

private FacadeItemModel createFacadeItemModel(FacadeState state) {
    List<BakedQuad> quads = Lists.newArrayList();
    IModel model;
    if (state.hollow)
        model = FacadePluggableModel.INSTANCE.modelHollow();
    else
        model = FacadePluggableModel.INSTANCE.modelFilled();
    TextureAtlasSprite sprite = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state.state);
    if (sprite == null) {
        sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
    }
    List<BakedQuad> bakedQuads = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.ITEM, singleTextureFunction(sprite)).getGeneralQuads();
    Matrix4f rotation = MatrixUtil.rotateTowardsFace(EnumFacing.EAST);
    Matrix4f translateToItem = new Matrix4f();
    translateToItem.setIdentity();
    translateToItem.setTranslation(new Vector3f(0.4f, 0, 0));
    Matrix4f totalMatrix = new Matrix4f();
    totalMatrix.setIdentity();
    // The last one is applied FIRST
    totalMatrix.mul(rotation);
    totalMatrix.mul(translateToItem);
    for (BakedQuad quad : bakedQuads) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.transform(totalMatrix);
        mutable.colouri(0xFF_FF_FF_FF);
        ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, mutable);
    }
    return new FacadeItemModel(ImmutableList.copyOf(quads), sprite, DefaultVertexFormats.ITEM);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IModel(net.minecraftforge.client.model.IModel) Matrix4f(javax.vecmath.Matrix4f) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Vector3f(javax.vecmath.Vector3f) 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