Search in sources :

Example 1 with Quaternion

use of net.minecraft.util.math.vector.Quaternion in project Overloaded by CJ-MC-Mods.

the class ItemInterfaceRenderer method render.

@Override
public void render(@Nonnull TileItemInterface te, float v, @Nonnull MatrixStack matrixStack, @Nonnull IRenderTypeBuffer iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
    ItemStack stack = te.getStoredItem();
    if (stack.isEmpty())
        return;
    matrixStack.pushPose();
    matrixStack.translate(0.5, 0.32, 0.5);
    matrixStack.pushPose();
    long angle = (System.currentTimeMillis() / 10) % 360;
    matrixStack.mulPose(new Quaternion(Vector3f.YN, angle, true));
    RenderSystem.enableLighting();
    Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemCameraTransforms.TransformType.GROUND, combinedLightIn, 0, matrixStack, iRenderTypeBuffer);
    RenderSystem.disableLighting();
    matrixStack.popPose();
    matrixStack.popPose();
}
Also used : Quaternion(net.minecraft.util.math.vector.Quaternion) ItemStack(net.minecraft.item.ItemStack)

Example 2 with Quaternion

use of net.minecraft.util.math.vector.Quaternion in project Overloaded by CJ-MC-Mods.

the class PlayerInterfaceRenderer method renderPlayer.

private void renderPlayer(TilePlayerInterface te, PlayerEntity player, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int lightLevel) {
    matrixStack.pushPose();
    matrixStack.translate(0.5, 0.32, 0.5);
    matrixStack.scale(.2f, .2f, .2f);
    matrixStack.pushPose();
    long angle = (System.currentTimeMillis() / 10) % 360;
    matrixStack.mulPose(new Quaternion(Vector3f.YN, angle, true));
    Minecraft.getInstance().getEntityRenderDispatcher().setRenderShadow(false);
    Minecraft.getInstance().getEntityRenderDispatcher().render(player, 0, 0, 0, 0, Minecraft.getInstance().getFrameTime(), matrixStack, iRenderTypeBuffer, lightLevel);
    Minecraft.getInstance().getEntityRenderDispatcher().setRenderShadow(false);
    matrixStack.popPose();
    matrixStack.popPose();
}
Also used : Quaternion(net.minecraft.util.math.vector.Quaternion)

Example 3 with Quaternion

use of net.minecraft.util.math.vector.Quaternion in project AgriCraft by AgriCraft.

the class TileEntitySeedAnalyzerSeedRenderer method renderGenome.

protected void renderGenome(TileEntitySeedAnalyzer tile, float partialTick, MatrixStack transforms, IRenderTypeBuffer buffer) {
    // fetch genes
    List<IAgriGenePair<?>> genes = tile.getGenesToRender();
    if (genes == null) {
        // should never be possible
        return;
    }
    // push a new matrix to the stack
    transforms.push();
    // fetch helpers
    SeedAnalyzerViewPointHandler viewHandler = SeedAnalyzerViewPointHandler.getInstance();
    AgriGenomeRenderer renderer = AgriGenomeRenderer.getInstance();
    // fetch scroll position
    int index = viewHandler.getScrollIndex();
    float partial = viewHandler.getPartialScrollProgress(partialTick);
    // fetch orientation
    BlockState state = tile.getBlockState();
    Direction dir = BlockSeedAnalyzer.ORIENTATION.fetch(state);
    // helix dimensions
    float h = Constants.HALF;
    float r = h / 10;
    // transform to the desired position
    float dx = Constants.HALF + Constants.UNIT * dir.getXOffset();
    float dy = 5 * Constants.UNIT;
    float dz = Constants.HALF + Constants.UNIT * dir.getZOffset();
    transforms.translate(dx, dy, dz);
    transforms.rotate(new Quaternion(Vector3f.YP, tile.getHorizontalAngle(), true));
    // render the helix
    renderer.renderDoubleHelix(genes, transforms, buffer, index, partial, r, h, 1.0F, false);
    // render the text
    if (index >= 0 && index < genes.size()) {
        transforms.push();
        transforms.translate(0, 0, -3 * Constants.UNIT);
        transforms.rotate(TEXT_ROTATION);
        float scale = 2.0F / Math.max(this.getScaledWindowWidth(), this.getScaledWindowHeight());
        transforms.scale(scale, scale, 1);
        renderer.renderTextOverlay(transforms, genes.get(index));
        transforms.pop();
    }
    // pop the matrix off the stack
    transforms.pop();
}
Also used : IAgriGenePair(com.infinityraider.agricraft.api.v1.genetics.IAgriGenePair) BlockState(net.minecraft.block.BlockState) Quaternion(net.minecraft.util.math.vector.Quaternion) SeedAnalyzerViewPointHandler(com.infinityraider.agricraft.handler.SeedAnalyzerViewPointHandler) Direction(net.minecraft.util.Direction) AgriGenomeRenderer(com.infinityraider.agricraft.render.plant.AgriGenomeRenderer)

Example 4 with Quaternion

use of net.minecraft.util.math.vector.Quaternion in project Overloaded by CJ-MC-Mods.

the class PlayerInterfaceRenderer method renderItem.

private void renderItem(TilePlayerInterface te, ItemStack stack, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer) {
    matrixStack.pushPose();
    matrixStack.translate(0.5, 0.32, 0.5);
    matrixStack.pushPose();
    long angle = (System.currentTimeMillis() / 10) % 360;
    matrixStack.mulPose(new Quaternion(Vector3f.YN, angle, true));
    RenderSystem.enableLighting();
    Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemCameraTransforms.TransformType.GROUND, te.getLevel().getBrightness(LightType.BLOCK, te.getBlockPos()) * 16, 0, matrixStack, iRenderTypeBuffer);
    RenderSystem.disableLighting();
    matrixStack.popPose();
    matrixStack.popPose();
}
Also used : Quaternion(net.minecraft.util.math.vector.Quaternion)

Example 5 with Quaternion

use of net.minecraft.util.math.vector.Quaternion in project AgriCraft by AgriCraft.

the class AgriGenomeRenderer method renderDoubleHelix.

/**
 * Renders an AgriCraft genome.
 *
 * Renders a right-hand, double helix with the dominant alleles on the left, and the recessive ones on the right,
 * The helix will be rotated so that the selected gene (denoted by index) is along the X-axis,
 * with a smooth transition towards the next gene.
 *
 * Notes:
 *  - The full double helix will be rendered, therefore it might appear squished or stretched based on the height
 *  - The selected gene will be colored with its color, the inactive ones will be greyed out
 *
 * @param genePairs the genome for which to draw an overlay
 * @param transforms matrix stack for the transformation
 * @param buffer the vertex buffer to draw with
 * @param index the index denoting the selected gene
 * @param transition a double denoting the transition progress to the next/previous gene (bounded by 1 and -1)
 * @param radius the radius of the double helix
 * @param height the height of the double helix
 * @param alpha the transparency of the helix
 * @param color if inactive genes should be colored or greyed
 */
public void renderDoubleHelix(List<IAgriGenePair<?>> genePairs, MatrixStack transforms, IRenderTypeBuffer buffer, int index, float transition, float radius, float height, float alpha, boolean color) {
    // Define helix properties
    int count = genePairs.size();
    if (count == 0 || radius == 0 || height == 0) {
        // Should never happen
        return;
    }
    int points = POINTS_PER_GENE * count;
    float heightStep = (height + 0.0F) / points;
    float angleStep = -(RADIANS_PER_GENE + 0.0F) / POINTS_PER_GENE;
    float angleOffset = RADIANS_PER_GENE / 2;
    float rotation = (index + transition) * RADIANS_PER_GENE;
    // Push transformation matrix
    transforms.push();
    // Rotate according to the index
    transforms.rotate(new Quaternion(Vector3f.YP, rotation, false));
    // Fetch transformation matrix
    Matrix4f matrix = transforms.getLast().getMatrix();
    // First helix
    this.drawHelix(genePairs, index, radius, angleOffset, heightStep, angleStep, points, buffer, matrix, true, alpha, color);
    // Second helix
    this.drawHelix(genePairs, index, radius, PI + angleOffset, heightStep, angleStep, points, buffer, matrix, false, alpha, color);
    // Spokes
    this.drawSpokes(genePairs, index, radius, angleOffset, PI + angleOffset, heightStep, angleStep, buffer, matrix, alpha, color);
    // Pop transformation matrix from the stack
    transforms.pop();
}
Also used : Matrix4f(net.minecraft.util.math.vector.Matrix4f) Quaternion(net.minecraft.util.math.vector.Quaternion)

Aggregations

Quaternion (net.minecraft.util.math.vector.Quaternion)5 IAgriGenePair (com.infinityraider.agricraft.api.v1.genetics.IAgriGenePair)1 SeedAnalyzerViewPointHandler (com.infinityraider.agricraft.handler.SeedAnalyzerViewPointHandler)1 AgriGenomeRenderer (com.infinityraider.agricraft.render.plant.AgriGenomeRenderer)1 BlockState (net.minecraft.block.BlockState)1 ItemStack (net.minecraft.item.ItemStack)1 Direction (net.minecraft.util.Direction)1 Matrix4f (net.minecraft.util.math.vector.Matrix4f)1