Search in sources :

Example 1 with MatrixTransformStack

use of com.jozufozu.flywheel.util.transform.MatrixTransformStack in project Create_Aeronautics by Eriksonnaren.

the class StationaryPotatoCannonRenderer method renderItem.

public void renderItem(StationaryPotatoCannonTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
    ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
    MatrixTransformStack msr = MatrixTransformStack.of(ms);
    ms.pushPose();
    msr.centre();
    Vector3i facingVec = facing.getNormal();
    float itemScale = .3f;
    float normalizedTimer = (te.ItemTimer + partialTicks);
    float itemPosition = 1 - (float) Math.exp(-0.25f * normalizedTimer);
    itemPosition *= 0.7f;
    ms.translate(facingVec.getX() * itemPosition, facingVec.getY() * itemPosition, facingVec.getZ() * itemPosition);
    ms.scale(itemScale, itemScale, itemScale);
    Quaternion Q = new Quaternion((float) Math.sin(te.ItemRotationId * 0.4f), (float) Math.cos(te.ItemRotationId * 1.4f), (float) Math.sin(te.ItemRotationId * 3.0f), (float) Math.cos(te.ItemRotationId * 5.0f));
    Q.normalize();
    msr.multiply(Q);
    // msr.rotateX(itemPosition * 180);
    // msr.rotateY(itemPosition * 180);
    itemRenderer.renderStatic(te.currentStack, ItemCameraTransforms.TransformType.FIXED, light, overlay, ms, buffer);
    ms.popPose();
}
Also used : Quaternion(net.minecraft.util.math.vector.Quaternion) ItemRenderer(net.minecraft.client.renderer.ItemRenderer) Vector3i(net.minecraft.util.math.vector.Vector3i) MatrixTransformStack(com.jozufozu.flywheel.util.transform.MatrixTransformStack)

Example 2 with MatrixTransformStack

use of com.jozufozu.flywheel.util.transform.MatrixTransformStack in project FrostedHeart by TeamMoegMC.

the class DeployerActorInstanceMixin method beginFrame.

/**
 * @author khjxiaogu
 * @reason change speed of deployer animation
 */
@Overwrite(remap = false)
public void beginFrame() {
    double factor;
    if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) {
        Contraption cont = context.contraption;
        // TODO: change to ModifyConstant
        if (cont instanceof ISpeedContraption) {
            factor = MathHelper.sin(AnimationTickHolder.getRenderTime() * .5f) * .05f + .45f;
        } else
            factor = MathHelper.sin(AnimationTickHolder.getRenderTime() * .5f) * .25f + .25f;
    } else {
        Vector3d center = VecHelper.getCenterOf(new BlockPos(context.position));
        double distance = context.position.distanceTo(center);
        double nextDistance = context.position.add(context.motion).distanceTo(center);
        factor = .5f - MathHelper.clamp(MathHelper.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1);
    }
    Vector3d offset = Vector3d.copy(facing.getDirectionVec()).scale(factor);
    MatrixStack ms = new MatrixStack();
    MatrixTransformStack msr = MatrixTransformStack.of(ms);
    msr.translate(context.localPos).translate(offset);
    transformModel(msr, pole, hand, yRot, zRot, zRotPole);
}
Also used : ISpeedContraption(com.teammoeg.frostedheart.util.ISpeedContraption) Vector3d(net.minecraft.util.math.vector.Vector3d) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BlockPos(net.minecraft.util.math.BlockPos) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption) ISpeedContraption(com.teammoeg.frostedheart.util.ISpeedContraption) MatrixTransformStack(com.jozufozu.flywheel.util.transform.MatrixTransformStack) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 3 with MatrixTransformStack

use of com.jozufozu.flywheel.util.transform.MatrixTransformStack in project SteamPowered by TeamMoegMC.

the class CastIronFlywheelInstance method animate.

private void animate(float angle) {
    MatrixStack ms = new MatrixStack();
    MatrixTransformStack msr = MatrixTransformStack.of(ms);
    msr.translate(getInstancePosition());
    if (connection != null) {
        float rotation = angle * connectorAngleMult;
        ms.pushPose();
        rotateToFacing(msr, connection);
        ms.pushPose();
        transformConnector(msr, true, true, rotation, connectedLeft);
        upperRotating.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, false, true, rotation, connectedLeft);
        lowerRotating.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, true, false, rotation, connectedLeft);
        upperSliding.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, false, false, rotation, connectedLeft);
        lowerSliding.setTransform(ms);
        ms.popPose();
        ms.popPose();
    }
    msr.centre().rotate(Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()), AngleHelper.rad(angle)).unCentre();
    wheel.setTransform(ms);
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) MatrixTransformStack(com.jozufozu.flywheel.util.transform.MatrixTransformStack)

Example 4 with MatrixTransformStack

use of com.jozufozu.flywheel.util.transform.MatrixTransformStack in project SteamPowered by TeamMoegMC.

the class SteelFlywheelInstance method animate.

private void animate(float angle) {
    MatrixStack ms = new MatrixStack();
    MatrixTransformStack msr = MatrixTransformStack.of(ms);
    msr.translate(getInstancePosition());
    if (connection != null) {
        float rotation = angle * connectorAngleMult;
        ms.pushPose();
        rotateToFacing(msr, connection);
        ms.pushPose();
        transformConnector(msr, true, true, rotation, connectedLeft);
        upperRotating.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, false, true, rotation, connectedLeft);
        lowerRotating.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, true, false, rotation, connectedLeft);
        upperSliding.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, false, false, rotation, connectedLeft);
        lowerSliding.setTransform(ms);
        ms.popPose();
        ms.popPose();
    }
    msr.centre().rotate(Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()), AngleHelper.rad(angle)).unCentre();
    wheel.setTransform(ms);
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) MatrixTransformStack(com.jozufozu.flywheel.util.transform.MatrixTransformStack)

Example 5 with MatrixTransformStack

use of com.jozufozu.flywheel.util.transform.MatrixTransformStack in project SteamPowered by TeamMoegMC.

the class BronzeFlywheelInstance method animate.

private void animate(float angle) {
    MatrixStack ms = new MatrixStack();
    MatrixTransformStack msr = MatrixTransformStack.of(ms);
    msr.translate(getInstancePosition());
    if (connection != null) {
        float rotation = angle * connectorAngleMult;
        ms.pushPose();
        rotateToFacing(msr, connection);
        ms.pushPose();
        transformConnector(msr, true, true, rotation, connectedLeft);
        upperRotating.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, false, true, rotation, connectedLeft);
        lowerRotating.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, true, false, rotation, connectedLeft);
        upperSliding.setTransform(ms);
        ms.popPose();
        ms.pushPose();
        transformConnector(msr, false, false, rotation, connectedLeft);
        lowerSliding.setTransform(ms);
        ms.popPose();
        ms.popPose();
    }
    msr.centre().rotate(Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()), AngleHelper.rad(angle)).unCentre();
    wheel.setTransform(ms);
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) MatrixTransformStack(com.jozufozu.flywheel.util.transform.MatrixTransformStack)

Aggregations

MatrixTransformStack (com.jozufozu.flywheel.util.transform.MatrixTransformStack)5 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)4 Contraption (com.simibubi.create.content.contraptions.components.structureMovement.Contraption)1 ISpeedContraption (com.teammoeg.frostedheart.util.ISpeedContraption)1 ItemRenderer (net.minecraft.client.renderer.ItemRenderer)1 BlockPos (net.minecraft.util.math.BlockPos)1 Quaternion (net.minecraft.util.math.vector.Quaternion)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1 Vector3i (net.minecraft.util.math.vector.Vector3i)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1