Search in sources :

Example 1 with Translation

use of codechicken.lib.vec.Translation in project BluePower by Qmunity.

the class SawRenderFMP method renderItem.

@Override
public void renderItem(ItemRenderType renderType, ItemStack item, Object... data) {
    double pi = Math.PI;
    Transformation t;
    switch(renderType) {
        case INVENTORY:
            t = new TransformationList(new Scale(1.8), new Translation(0, 0, -0.6), new Rotation(-pi / 4, 1, 0, 0), new Rotation(pi * 3 / 4, 0, 1, 0));
            break;
        case ENTITY:
            t = new TransformationList(new Scale(1), new Translation(0, 0, -0.25), new Rotation(-pi / 4, 1, 0, 0));
            break;
        case EQUIPPED_FIRST_PERSON:
            t = new TransformationList(new Scale(1.5), new Rotation(-pi / 3, 1, 0, 0), new Rotation(pi * 3 / 4, 0, 1, 0), new Translation(0.5, 0.5, 0.5));
            break;
        case EQUIPPED:
            t = new TransformationList(new Scale(1.5), new Rotation(-pi / 5, 1, 0, 0), new Rotation(-pi * 3 / 4, 0, 1, 0), new Translation(0.75, 0.5, 0.75));
            break;
        default:
            t = null;
            break;
    }
    CCRenderState.reset();
    CCRenderState.useNormals = true;
    CCRenderState.pullLightmap();
    CCRenderState.changeTexture("microblock:textures/items/saw.png");
    CCRenderState.startDrawing();
    handle.render(t);
    holder.render(t);
    CCRenderState.draw();
    GL11.glDisable(GL11.GL_CULL_FACE);
    CCRenderState.changeTexture(Refs.MODID + ":textures/items/fmpsaw.png");
    CCRenderState.startDrawing();
    int tex = 0;
    if (item.getItem() == BPItems.ruby_saw) {
        tex = 0;
    } else if (item.getItem() == BPItems.amethyst_saw) {
        tex = 1;
    } else if (item.getItem() == BPItems.sapphire_saw) {
        tex = 2;
    }
    blade.render(t, new UVTranslation(0, tex * 4 / 64D));
    CCRenderState.draw();
    GL11.glEnable(GL11.GL_CULL_FACE);
}
Also used : Transformation(codechicken.lib.vec.Transformation) Translation(codechicken.lib.vec.Translation) UVTranslation(codechicken.lib.render.uv.UVTranslation) UVTranslation(codechicken.lib.render.uv.UVTranslation) Scale(codechicken.lib.vec.Scale) TransformationList(codechicken.lib.vec.TransformationList) Rotation(codechicken.lib.vec.Rotation)

Example 2 with Translation

use of codechicken.lib.vec.Translation in project GregTech by GregTechCE.

the class MetaTileEntityRenderer method renderBlock.

@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
    if (metaTileEntity == null)
        return false;
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.lightMatrix.locate(world, pos);
    IVertexOperation[] pipeline = new IVertexOperation[2];
    pipeline[0] = new Translation(pos);
    pipeline[1] = renderState.lightMatrix;
    metaTileEntity.renderMetaTileEntity(renderState, pipeline);
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) Translation(codechicken.lib.vec.Translation) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) CCRenderState(codechicken.lib.render.CCRenderState)

Example 3 with Translation

use of codechicken.lib.vec.Translation in project GregTech by GregTechCE.

the class MetaTileEntityRenderer method handleRenderBlockDamage.

@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
    BlockMachine blockMachine = ((BlockMachine) state.getBlock());
    Collection<AxisAlignedBB> boxes = blockMachine.getSelectedBoundingBoxes(world, pos, state);
    List<Cuboid6> cuboid6List = boxes.stream().map(aabb -> new Cuboid6(aabb).subtract(pos)).collect(Collectors.toList());
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    IVertexOperation[] pipeline = new IVertexOperation[2];
    pipeline[0] = new Translation(pos);
    pipeline[1] = new IconTransformation(sprite);
    BlockFace blockFace = blockFaces.get();
    for (Cuboid6 boundingBox : cuboid6List) {
        for (EnumFacing face : EnumFacing.VALUES) {
            blockFace.loadCuboidFace(boundingBox, face.getIndex());
            renderState.setPipeline(blockFace, 0, blockFace.verts.length, pipeline);
            renderState.render();
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) IconTransformation(codechicken.lib.vec.uv.IconTransformation) TransformType(net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) Matrix4f(javax.vecmath.Matrix4f) Block(net.minecraft.block.Block) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) RenderHelper(net.minecraft.client.renderer.RenderHelper) GL11(org.lwjgl.opengl.GL11) ModelBlock(net.minecraft.client.renderer.block.model.ModelBlock) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IIconRegister(codechicken.lib.texture.TextureUtils.IIconRegister) GlStateManager(net.minecraft.client.renderer.GlStateManager) IModelState(net.minecraftforge.common.model.IModelState) Collection(java.util.Collection) ItemTransformVec3f(net.minecraft.client.renderer.block.model.ItemTransformVec3f) Collectors(java.util.stream.Collectors) ICCBlockRenderer(codechicken.lib.render.block.ICCBlockRenderer) List(java.util.List) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Translation(codechicken.lib.vec.Translation) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IItemRenderer(codechicken.lib.render.item.IItemRenderer) IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureUtils(codechicken.lib.texture.TextureUtils) HashMap(java.util.HashMap) BlockFace(codechicken.lib.render.BlockRenderer.BlockFace) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IResource(net.minecraft.client.resources.IResource) IBlockAccess(net.minecraft.world.IBlockAccess) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) CCRenderState(codechicken.lib.render.CCRenderState) GTLog(gregtech.api.util.GTLog) TextureMap(net.minecraft.client.renderer.texture.TextureMap) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException) BlockRenderingRegistry(codechicken.lib.render.block.BlockRenderingRegistry) InputStreamReader(java.io.InputStreamReader) IBlockState(net.minecraft.block.state.IBlockState) MinecraftForge(net.minecraftforge.common.MinecraftForge) GTValues(gregtech.api.GTValues) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemBlock(net.minecraft.item.ItemBlock) LightUtil(net.minecraftforge.client.model.pipeline.LightUtil) BlockMachine(gregtech.api.block.machines.BlockMachine) Cuboid6(codechicken.lib.vec.Cuboid6) IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) Translation(codechicken.lib.vec.Translation) BlockMachine(gregtech.api.block.machines.BlockMachine) BlockFace(codechicken.lib.render.BlockRenderer.BlockFace) EnumFacing(net.minecraft.util.EnumFacing) Cuboid6(codechicken.lib.vec.Cuboid6) CCRenderState(codechicken.lib.render.CCRenderState) IconTransformation(codechicken.lib.vec.uv.IconTransformation)

Aggregations

Translation (codechicken.lib.vec.Translation)3 CCRenderState (codechicken.lib.render.CCRenderState)2 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)2 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)2 BlockFace (codechicken.lib.render.BlockRenderer.BlockFace)1 BlockRenderingRegistry (codechicken.lib.render.block.BlockRenderingRegistry)1 ICCBlockRenderer (codechicken.lib.render.block.ICCBlockRenderer)1 IItemRenderer (codechicken.lib.render.item.IItemRenderer)1 UVTranslation (codechicken.lib.render.uv.UVTranslation)1 TextureUtils (codechicken.lib.texture.TextureUtils)1 IIconRegister (codechicken.lib.texture.TextureUtils.IIconRegister)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Rotation (codechicken.lib.vec.Rotation)1 Scale (codechicken.lib.vec.Scale)1 Transformation (codechicken.lib.vec.Transformation)1 TransformationList (codechicken.lib.vec.TransformationList)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 GTValues (gregtech.api.GTValues)1 BlockMachine (gregtech.api.block.machines.BlockMachine)1 MachineItemBlock (gregtech.api.block.machines.MachineItemBlock)1