Search in sources :

Example 1 with Transformation

use of codechicken.lib.vec.Transformation 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 Transformation

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

the class GridConnection method computePosition.

private Position computePosition() {
    Transformation orientation = TextureArea.createOrientation(parentElementSize, parentOrientation.rotationValue);
    PositionedRect parentRect = TextureArea.transformRect(orientation, parentElementRect);
    switch(getOrientation()) {
        case LEFT:
            return new Position(0, connectionOffset);
        case RIGHT:
            return new Position(parentRect.position.x + parentRect.size.width, connectionOffset);
        case TOP:
            return new Position(connectionOffset, 0);
        case BOTTOM:
            return new Position(connectionOffset, parentRect.position.y + parentRect.size.height);
        default:
            return Position.ORIGIN;
    }
}
Also used : Transformation(codechicken.lib.vec.Transformation) Position(gregtech.api.util.Position) PositionedRect(gregtech.api.util.PositionedRect)

Example 3 with Transformation

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

the class TextureArea method createOrientation.

public static Transformation createOrientation(Size areaSize, int orientation) {
    Transformation transformation = new Rotation(Math.toRadians(orientation * 90.0), 0.0, 0.0, 1.0).at(new Vector3(areaSize.width / 2.0, areaSize.height / 2.0, 0.0));
    Size orientedSize = transformSize(transformation, areaSize);
    double offsetX = (areaSize.width - orientedSize.width) / 2.0;
    double offsetY = (areaSize.height - orientedSize.height) / 2.0;
    return transformation.with(new Translation(-offsetX, -offsetY, 0.0));
}
Also used : Transformation(codechicken.lib.vec.Transformation) Translation(codechicken.lib.vec.Translation) Size(gregtech.api.util.Size) Vector3(codechicken.lib.vec.Vector3) Rotation(codechicken.lib.vec.Rotation)

Example 4 with Transformation

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

the class TextureArea method drawRotated.

@SideOnly(Side.CLIENT)
public void drawRotated(int x, int y, Size areaSize, PositionedRect positionedRect, int orientation) {
    Transformation transformation = createOrientation(areaSize, orientation);
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 0.0f);
    transformation.glApply();
    draw(positionedRect.position.x, positionedRect.position.y, positionedRect.size.width, positionedRect.size.height);
    GlStateManager.popMatrix();
}
Also used : Transformation(codechicken.lib.vec.Transformation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Transformation (codechicken.lib.vec.Transformation)4 Rotation (codechicken.lib.vec.Rotation)2 Translation (codechicken.lib.vec.Translation)2 UVTranslation (codechicken.lib.render.uv.UVTranslation)1 Scale (codechicken.lib.vec.Scale)1 TransformationList (codechicken.lib.vec.TransformationList)1 Vector3 (codechicken.lib.vec.Vector3)1 Position (gregtech.api.util.Position)1 PositionedRect (gregtech.api.util.PositionedRect)1 Size (gregtech.api.util.Size)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1