Search in sources :

Example 1 with Quaternion

use of pl.asie.charset.lib.utils.Quaternion in project Charset by CharsetMC.

the class TileProjectorRenderer method render.

@Override
public void render(TileProjector projector, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (projector == null || projector.getStack().isEmpty()) {
        return;
    }
    ItemStack stack = projector.getStack();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    Orientation bo = projector.getOrientation();
    EnumFacing face = bo.top;
    if (SpaceUtils.sign(face) == 1) {
        GlStateManager.translate(face.getDirectionVec().getX(), face.getDirectionVec().getY(), face.getDirectionVec().getZ());
    }
    GlStateManager.translate(0.5 * (1 - Math.abs(face.getDirectionVec().getX())), 0.5 * (1 - Math.abs(face.getDirectionVec().getY())), 0.5 * (1 - Math.abs(face.getDirectionVec().getZ())));
    Quaternion quat = Quaternion.fromOrientation(bo);
    quat.glRotate();
    GlStateManager.rotate(90, 0, 1, 0);
    GlStateManager.translate(0.25, 0.25 - 1.0 / 16.0, 31.0 / 128.0);
    GlStateManager.enableAlpha();
    GlStateManager.enableLighting();
    GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    handleRenderItem(stack, projector);
    GlStateManager.popMatrix();
    GlStateManager.disableBlend();
}
Also used : Quaternion(pl.asie.charset.lib.utils.Quaternion) EnumFacing(net.minecraft.util.EnumFacing) ItemStack(net.minecraft.item.ItemStack) Orientation(pl.asie.charset.lib.utils.Orientation)

Example 2 with Quaternion

use of pl.asie.charset.lib.utils.Quaternion in project Charset by CharsetMC.

the class BlockProjector method getBoundingBox.

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
    AxisAlignedBB base = BOUNDING_BOX;
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileProjector) {
        Quaternion quaternion = Quaternion.fromOrientation(((TileProjector) tile).getOrientation());
        base = quaternion.applyRotation(BOUNDING_BOX_ROTATE).offset(0.5, 0.5, 0.5);
    }
    return base;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TileEntity(net.minecraft.tileentity.TileEntity) Quaternion(pl.asie.charset.lib.utils.Quaternion)

Aggregations

Quaternion (pl.asie.charset.lib.utils.Quaternion)2 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 Orientation (pl.asie.charset.lib.utils.Orientation)1