Search in sources :

Example 16 with Matrix4

use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.

the class TileEntityConnectorStructural method applyTransformations.

@Override
public Optional<TRSRTransformation> applyTransformations(IBlockState object, String group, Optional<TRSRTransformation> transform) {
    Matrix4 mat = transform.isPresent() ? new Matrix4(transform.get().getMatrix()) : new Matrix4();
    mat = mat.translate(.5, 0, .5).rotate(Math.toRadians(rotation), 0, 1, 0).translate(-.5, 0, -.5);
    transform = Optional.of(new TRSRTransformation(mat.toMatrix4f()));
    return transform;
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)

Example 17 with Matrix4

use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method preInit.

@Override
public void preInit() {
    //Enabling FBO stencils
    ClientUtils.mc().getFramebuffer().enableStencil();
    ModelLoaderRegistry.registerLoader(IEOBJLoader.instance);
    OBJLoader.INSTANCE.addDomain("immersiveengineering");
    IEOBJLoader.instance.addDomain("immersiveengineering");
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemBullet, 1, 2), new ImmersiveModelRegistry.ItemModelReplacement() {

        @Override
        public IBakedModel createBakedModel(IBakedModel existingModel) {
            return new ModelItemDynamicOverride(existingModel, null);
        }
    });
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemShader), new ImmersiveModelRegistry.ItemModelReplacement() {

        @Override
        public IBakedModel createBakedModel(IBakedModel existingModel) {
            return new ModelItemDynamicOverride(existingModel, null);
        }
    });
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemTool, 1, 2), new ImmersiveModelRegistry.ItemModelReplacement_OBJ("immersiveengineering:models/item/tool/voltmeter.obj").setTransformations(TransformType.FIRST_PERSON_RIGHT_HAND, new Matrix4().translate(-.25, .375, .3125).rotate(-Math.PI * .5, 0, 1, 0)).setTransformations(TransformType.FIRST_PERSON_LEFT_HAND, new Matrix4().translate(-.25, .375, -.625).rotate(-Math.PI * .5, 0, 1, 0)).setTransformations(TransformType.THIRD_PERSON_RIGHT_HAND, new Matrix4().translate(-0.25, .125, .25).scale(.625f, .625f, .625f).rotate(-Math.PI * .375, 0, 1, 0)).setTransformations(TransformType.THIRD_PERSON_LEFT_HAND, new Matrix4().translate(-0.5, .125, -.3125).scale(.625f, .625f, .625f).rotate(-Math.PI * .375, 0, 1, 0)).setTransformations(TransformType.FIXED, new Matrix4().translate(-.5, .5, -.5).scale(1, 1, 1).rotate(Math.PI, 0, 1, 0)).setTransformations(TransformType.GUI, new Matrix4().translate(0, .5, 0).scale(1.125, 1.125, 1.125).rotate(-Math.PI * .25, 0, 1, 0)).setTransformations(TransformType.GROUND, new Matrix4().translate(.25, .25, .25).scale(.5, .5, .5)));
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemToolbox), new ImmersiveModelRegistry.ItemModelReplacement_OBJ("immersiveengineering:models/item/toolbox.obj").setTransformations(TransformType.FIRST_PERSON_RIGHT_HAND, new Matrix4().scale(.375, .375, .375).translate(-.75, 1.25, .3125).rotate(-Math.PI * .75, 0, 1, 0)).setTransformations(TransformType.FIRST_PERSON_LEFT_HAND, new Matrix4().scale(.375, .375, .375).translate(-.125, 1.25, .9375).rotate(Math.PI * .25, 0, 1, 0)).setTransformations(TransformType.THIRD_PERSON_RIGHT_HAND, new Matrix4().translate(-.25, .1875, .3125).scale(.625, .625, .625).rotate(Math.PI, 0, 1, 0).rotate(-Math.PI * .5, 1, 0, 0)).setTransformations(TransformType.THIRD_PERSON_LEFT_HAND, new Matrix4().translate(-.25, -.4375, .3125).scale(.625, .625, .625).rotate(Math.PI * .5, 1, 0, 0)).setTransformations(TransformType.FIXED, new Matrix4().translate(.5, .875, -.5).scale(1, 1, 1).rotate(Math.PI * .5, 0, 1, 0)).setTransformations(TransformType.GUI, new Matrix4().translate(-.625, .75, 0).scale(.875, .875, .875).rotate(-Math.PI * .6875, 0, 1, 0)).setTransformations(TransformType.GROUND, new Matrix4().translate(.25, .5, .25).scale(.5, .5, .5)));
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemRevolver, 1, 0), new ImmersiveModelRegistry.ItemModelReplacement_OBJ("immersiveengineering:models/item/revolver/revolver.obj").setTransformations(TransformType.FIRST_PERSON_RIGHT_HAND, new Matrix4().rotate(Math.toRadians(-90), 0, 1, 0).scale(.1875, .25, .25).translate(-.5, .4375, .5)).setTransformations(TransformType.FIRST_PERSON_LEFT_HAND, new Matrix4().rotate(Math.toRadians(90), 0, 1, 0).scale(.1875, .25, .25).translate(.45, .4375, .5)).setTransformations(TransformType.THIRD_PERSON_RIGHT_HAND, new Matrix4().translate(-.125, .125, -.125).scale(.125, .125, .125).rotate(Math.toRadians(-90), 0, 1, 0).rotate(Math.toRadians(-10), 0, 0, 1)).setTransformations(TransformType.THIRD_PERSON_LEFT_HAND, new Matrix4().translate(.0, .0625, -.125).scale(.125, .125, .125).rotate(Math.toRadians(90), 0, 1, 0).rotate(Math.toRadians(0), 0, 0, 1)).setTransformations(TransformType.GUI, new Matrix4().translate(.1875, -.0781225, -.15625).scale(.2, .2, .2).rotate(Math.toRadians(-40), 0, 1, 0).rotate(Math.toRadians(-35), 0, 0, 1)).setTransformations(TransformType.FIXED, new Matrix4().translate(-.25, 0, -.0625).scale(.1875, .1875, .1875).rotate(Math.PI, 0, 1, 0).rotate(Math.toRadians(-40), 0, 0, 1)).setTransformations(TransformType.GROUND, new Matrix4().translate(.125, 0, .0625).scale(.125, .125, .125)));
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemDrill, 1, 0), new ImmersiveModelRegistry.ItemModelReplacement_OBJ("immersiveengineering:models/item/drill/drill_diesel.obj").setTransformations(TransformType.FIRST_PERSON_RIGHT_HAND, new Matrix4().scale(.375, .375, .375).translate(-.25, 1, .5).rotate(Math.PI * .5, 0, 1, 0)).setTransformations(TransformType.FIRST_PERSON_LEFT_HAND, new Matrix4().scale(.375, .375, .375).translate(-1.5, 1.125, .875).rotate(-Math.PI * .5, 0, 1, 0)).setTransformations(TransformType.THIRD_PERSON_RIGHT_HAND, new Matrix4().translate(.0625, .9375, .25).scale(.75, .75, .75).rotate(Math.PI * .75, 0, 1, 0).rotate(Math.PI * .375, 0, 0, 1).rotate(-Math.PI * .25, 1, 0, 0)).setTransformations(TransformType.THIRD_PERSON_LEFT_HAND, new Matrix4().translate(.0625, .9375, .25).scale(-.75, .75, .75).rotate(-Math.PI * .75, 0, 1, 0).rotate(-Math.PI * .375, 0, 0, 1).rotate(-Math.PI * .25, 1, 0, 0)).setTransformations(TransformType.FIXED, new Matrix4().translate(.1875, .0625, .15625).scale(.4375, .4375, .4375).rotate(-Math.PI * .25, 0, 0, 1)).setTransformations(TransformType.GUI, new Matrix4().translate(-.5, .25, 0).scale(.75, .75, .75).rotate(-Math.PI * .6875, 0, 1, 0).rotate(-Math.PI * .125, 0, 0, 1)).setTransformations(TransformType.GROUND, new Matrix4().translate(.125, .25, .25).scale(.5, .5, .5)));
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemChemthrower, 1, 0), new ImmersiveModelRegistry.ItemModelReplacement_OBJ("immersiveengineering:models/item/chemthrower.obj").setTransformations(TransformType.FIRST_PERSON_RIGHT_HAND, new Matrix4().scale(.375, .375, .375).translate(-.25, 1, .5).rotate(Math.PI * .5, 0, 1, 0)).setTransformations(TransformType.FIRST_PERSON_LEFT_HAND, new Matrix4().scale(.25, .25, .25).translate(-.5, 1.25, .75).rotate(-Math.PI * .5, 0, 1, 0)).setTransformations(TransformType.THIRD_PERSON_RIGHT_HAND, new Matrix4().translate(-.25, .625, -.25).scale(.5, .5, .5).rotate(Math.PI * .75, 0, 1, 0).rotate(Math.PI * .25, 0, 0, 1).rotate(-Math.PI * .25, 1, 0, 0)).setTransformations(TransformType.THIRD_PERSON_LEFT_HAND, new Matrix4().translate(-.25, -.4375, .3125).scale(.625, .625, .625).rotate(Math.PI * .5, 1, 0, 0)).setTransformations(TransformType.FIXED, new Matrix4().translate(.125, .125, -.25).scale(.3125, .3125, .3125).rotate(Math.PI, 0, 1, 0).rotate(Math.PI * .25, 0, 0, 1)).setTransformations(TransformType.GUI, new Matrix4().translate(-.1875, .3125, 0).scale(.4375, .4375, .4375).rotate(-Math.PI * .6875, 0, 1, 0).rotate(-Math.PI * .125, 0, 0, 1)).setTransformations(TransformType.GROUND, new Matrix4().translate(0, .25, .125).scale(.25, .25, .25)));
    ImmersiveModelRegistry.instance.registerCustomItemModel(new ItemStack(IEContent.itemRailgun, 1, 0), new ImmersiveModelRegistry.ItemModelReplacement_OBJ("immersiveengineering:models/item/railgun.obj").setTransformations(TransformType.FIRST_PERSON_RIGHT_HAND, new Matrix4().scale(.125, .125, .125).translate(-.5, 1.5, .5).rotate(Math.PI * .46875, 0, 1, 0)).setTransformations(TransformType.FIRST_PERSON_LEFT_HAND, new Matrix4().scale(.125, .125, .125).translate(-1.75, 1.625, .875).rotate(-Math.PI * .46875, 0, 1, 0)).setTransformations(TransformType.THIRD_PERSON_RIGHT_HAND, new Matrix4().translate(0, .5625, -.09375).scale(.1875, .1875, .1875).rotate(Math.PI * .53125, 0, 1, 0).rotate(Math.PI * .34375, 0, 0, 1)).setTransformations(TransformType.THIRD_PERSON_LEFT_HAND, new Matrix4().translate(-.1875, .5625, -.09375).scale(.1875, .1875, .1875).rotate(-Math.PI * .46875, 0, 1, 0).rotate(-Math.PI * .34375, 0, 0, 1)).setTransformations(TransformType.FIXED, new Matrix4().translate(.1875, .0625, .0625).scale(.125, .125, .125).rotate(-Math.PI * .25, 0, 0, 1)).setTransformations(TransformType.GUI, new Matrix4().translate(-.1875, 0, 0).scale(.1875, .1875, .1875).rotate(-Math.PI * .6875, 0, 1, 0).rotate(-Math.PI * .1875, 0, 0, 1)).setTransformations(TransformType.GROUND, new Matrix4().translate(.125, .125, .0625).scale(.125, .125, .125)));
    RenderingRegistry.registerEntityRenderingHandler(EntityRevolvershot.class, new IRenderFactory<EntityRevolvershot>() {

        @Override
        public Render createRenderFor(RenderManager manager) {
            return new EntityRenderRevolvershot(manager);
        }
    });
    RenderingRegistry.registerEntityRenderingHandler(EntitySkylineHook.class, new IRenderFactory<EntitySkylineHook>() {

        @Override
        public Render createRenderFor(RenderManager manager) {
            return new EntityRenderNone(manager);
        }
    });
    RenderingRegistry.registerEntityRenderingHandler(EntityChemthrowerShot.class, new IRenderFactory<EntityChemthrowerShot>() {

        @Override
        public Render createRenderFor(RenderManager manager) {
            return new EntityRenderChemthrowerShot(manager);
        }
    });
    RenderingRegistry.registerEntityRenderingHandler(EntityRailgunShot.class, new IRenderFactory<EntityRailgunShot>() {

        @Override
        public Render createRenderFor(RenderManager manager) {
            return new EntityRenderRailgunShot(manager);
        }
    });
    RenderingRegistry.registerEntityRenderingHandler(EntityIEExplosive.class, new IRenderFactory<EntityIEExplosive>() {

        @Override
        public Render createRenderFor(RenderManager manager) {
            return new EntityRenderIEExplosive(manager);
        }
    });
    RenderingRegistry.registerEntityRenderingHandler(EntityFluorescentTube.class, new IRenderFactory<EntityFluorescentTube>() {

        @Override
        public Render createRenderFor(RenderManager manager) {
            return new EntityRenderFluorescentTube(manager);
        }
    });
    ModelLoaderRegistry.registerLoader(new ConnLoader());
    ModelLoaderRegistry.registerLoader(new ModelConfigurableSides.Loader());
}
Also used : Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4) ConnLoader(blusunrize.immersiveengineering.client.models.smart.ConnLoader) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) PositionedItemStack(blusunrize.lib.manual.ManualPages.PositionedItemStack)

Example 18 with Matrix4

use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method drawConveyorInGui.

@Override
public boolean drawConveyorInGui(String conveyor, EnumFacing facing) {
    IConveyorBelt con = ConveyorHandler.getConveyor(new ResourceLocation(conveyor), null);
    if (con != null) {
        GlStateManager.pushMatrix();
        Set<BakedQuad> quads = ModelConveyor.getBaseConveyor(facing, 1, new Matrix4(facing), ConveyorDirection.HORIZONTAL, ClientUtils.getSprite(con.getActiveTexture()), new boolean[] { true, true }, new boolean[] { true, true }, null, 0);
        //			GL11.glTranslatef(0, 0, 1);
        ClientUtils.renderQuads(quads, 1, 1, 1, 1);
        GlStateManager.popMatrix();
        return true;
    }
    return false;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)

Example 19 with Matrix4

use of blusunrize.immersiveengineering.common.util.chickenbones.Matrix4 in project ImmersiveEngineering by BluSunrize.

the class ConveyorCovered method modifyQuads.

@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> modifyQuads(List<BakedQuad> baseModel, @Nullable TileEntity tile, EnumFacing facing) {
    ItemStack cover = this.cover != null ? this.cover : defaultCover;
    Block b = Block.getBlockFromItem(cover.getItem());
    IBlockState state = b != null ? b.getStateFromMeta(cover.getMetadata()) : Blocks.STONE.getDefaultState();
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
    if (model != null) {
        TextureAtlasSprite sprite = model.getParticleTexture();
        HashMap<EnumFacing, TextureAtlasSprite> sprites = new HashMap<>();
        ConveyorDirection conDir = this.getConveyorDirection();
        for (EnumFacing f : EnumFacing.VALUES) for (BakedQuad q : model.getQuads(state, f, 0)) if (q != null && q.getSprite() != null)
            sprites.put(f, q.getSprite());
        for (BakedQuad q : model.getQuads(state, null, 0)) if (q != null && q.getSprite() != null && q.getFace() != null)
            sprites.put(q.getFace(), q.getSprite());
        Function<EnumFacing, TextureAtlasSprite> getSprite = f -> sprites.containsKey(f) ? sprites.get(f) : sprite;
        Function<EnumFacing, TextureAtlasSprite> getSpriteHorizontal = f -> f.getAxis() == Axis.Y ? null : sprites.containsKey(f) ? sprites.get(f) : sprite;
        float[] colour = { 1, 1, 1, 1 };
        Matrix4 matrix = new Matrix4(facing);
        boolean wallLeft = tile == null || this.renderWall(tile, facing, 0);
        boolean wallRight = tile == null || this.renderWall(tile, facing, 1);
        Function<Vector3f[], Vector3f[]> vertexTransformer = conDir == ConveyorDirection.HORIZONTAL ? vertices -> vertices : vertices -> {
            Vector3f[] ret = new Vector3f[vertices.length];
            for (int i = 0; i < ret.length; i++) ret[i] = new Vector3f(vertices[i].x, vertices[i].y + (vertices[i].z == (conDir == ConveyorDirection.UP ? 0 : 1) ? 1 : 0), vertices[i].z);
            return ret;
        };
        baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .75f, 0), new Vector3f(1, 1, 1), matrix, facing, vertexTransformer, getSprite, colour));
        if (wallLeft)
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, 0), new Vector3f(.0625f, .75f, 1), matrix, facing, vertexTransformer, getSpriteHorizontal, colour));
        else {
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, 0), new Vector3f(.0625f, .75f, .0625f), matrix, facing, getSpriteHorizontal, colour));
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, .9375f), new Vector3f(.0625f, .75f, 1), matrix, facing, getSpriteHorizontal, colour));
        }
        if (wallRight)
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, 0), new Vector3f(1, .75f, 1), matrix, facing, vertexTransformer, getSpriteHorizontal, colour));
        else {
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, 0), new Vector3f(1, .75f, .0625f), matrix, facing, getSpriteHorizontal, colour));
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, .9375f), new Vector3f(1, .75f, 1), matrix, facing, getSpriteHorizontal, colour));
        }
    }
    return baseModel;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) IEContent(blusunrize.immersiveengineering.common.IEContent) Blocks(net.minecraft.init.Blocks) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumHand(net.minecraft.util.EnumHand) HashMap(java.util.HashMap) Function(java.util.function.Function) ClientUtils(blusunrize.immersiveengineering.client.ClientUtils) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) Lists(com.google.common.collect.Lists) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) OreDictionary(net.minecraftforge.oredict.OreDictionary) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nullable(javax.annotation.Nullable) BlockTypes_WoodenDecoration(blusunrize.immersiveengineering.common.blocks.wooden.BlockTypes_WoodenDecoration) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EntityItem(net.minecraft.entity.item.EntityItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) Utils(blusunrize.immersiveengineering.common.util.Utils) ConveyorDirection(blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection) EnumFacing(net.minecraft.util.EnumFacing) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) Vector3f(org.lwjgl.util.vector.Vector3f) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntity(net.minecraft.tileentity.TileEntity) BlockTypes_MetalDecoration1(blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration1) Axis(net.minecraft.util.EnumFacing.Axis) IBlockState(net.minecraft.block.state.IBlockState) HashMap(java.util.HashMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4) Vector3f(org.lwjgl.util.vector.Vector3f) Block(net.minecraft.block.Block) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ConveyorDirection(blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)19 Vec3d (net.minecraft.util.math.Vec3d)8 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)5 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)4 TileEntity (net.minecraft.tileentity.TileEntity)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)3 Vector3f (org.lwjgl.util.vector.Vector3f)3 ConveyorDirection (blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection)2 Utils (blusunrize.immersiveengineering.common.util.Utils)2 ArrayList (java.util.ArrayList)2 Function (java.util.function.Function)2 IBlockState (net.minecraft.block.state.IBlockState)2 Minecraft (net.minecraft.client.Minecraft)2 ItemStack (net.minecraft.item.ItemStack)2 BlockPos (net.minecraft.util.math.BlockPos)2 OBJState (net.minecraftforge.client.model.obj.OBJModel.OBJState)2 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)2 IEProperties (blusunrize.immersiveengineering.api.IEProperties)1