Search in sources :

Example 21 with Vec3f

use of net.minecraft.util.math.Vec3f in project wildmod by Osmiooo.

the class ShriekParticleX method buildGeometry.

@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float f) {
    Vec3d vec3d = camera.getPos();
    float g = (float) (MathHelper.lerp((double) f, this.prevPosX, this.x) - vec3d.getX());
    float h = (float) (MathHelper.lerp((double) f, this.prevPosY, this.y) - vec3d.getY());
    float i = (float) (MathHelper.lerp((double) f, this.prevPosZ, this.z) - vec3d.getZ());
    Quaternion quaternion;
    quaternion = new Quaternion(0.2F, -0.8F, 0.8F, -0.2F);
    Vec3f j = new Vec3f(0.0F, -1.0F, -1.0F);
    j.rotate(quaternion);
    Vec3f[] vec3fs = new Vec3f[] { new Vec3f(-1.0F, -1.0F, 0.0F), new Vec3f(-1.0F, 1.0F, 0.0F), new Vec3f(1.0F, 1.0F, 0.0F), new Vec3f(1.0F, -1.0F, 0.0F) };
    float k = this.getSize(f);
    for (int l = 0; l < 4; ++l) {
        Vec3f vec3f = vec3fs[l];
        vec3f.rotate(quaternion);
        vec3f.scale((float) (((this.age) / (9.8)) / 7));
        vec3f.add(g, h, i);
        this.setAlpha((float) (this.age - this.maxAge) * 6);
    }
    float l = this.getMinU();
    float vec3f = this.getMaxU();
    float m = this.getMinV();
    float n = this.getMaxV();
    int o = this.getBrightness(f);
    vertexConsumer.vertex((double) vec3fs[0].getX(), (double) vec3fs[0].getY(), (double) vec3fs[0].getZ()).texture(vec3f, n).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[1].getX(), (double) vec3fs[1].getY(), (double) vec3fs[1].getZ()).texture(vec3f, m).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[2].getX(), (double) vec3fs[2].getY(), (double) vec3fs[2].getZ()).texture(l, m).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[3].getX(), (double) vec3fs[3].getY(), (double) vec3fs[3].getZ()).texture(l, n).color(this.red, this.green, this.blue, this.alpha).light(o).next();
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) Vec3f(net.minecraft.util.math.Vec3f) Vec3d(net.minecraft.util.math.Vec3d)

Example 22 with Vec3f

use of net.minecraft.util.math.Vec3f in project meteor-client by MeteorDevelopment.

the class AbstractQuadRendererMixin method whBufferQuad.

// https://github.com/FabricMC/fabric/blob/351679a7decdd3044d778e74001de67463bee205/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/render/AbstractQuadRenderer.java#L86
// Again, nasty problem with mixins and for loops, hopefully I can fix this at a later date - Wala
private static void whBufferQuad(VertexConsumer buff, MutableQuadViewImpl quad, Matrix4f matrix, int overlay, Matrix3f normalMatrix, Vec3f normalVec, int alpha) {
    final boolean useNormals = quad.hasVertexNormals();
    if (useNormals) {
        quad.populateMissingNormals();
    } else {
        final Vec3f faceNormal = quad.faceNormal();
        normalVec.set(faceNormal.getX(), faceNormal.getY(), faceNormal.getZ());
        normalVec.transform(normalMatrix);
    }
    for (int i = 0; i < 4; i++) {
        buff.vertex(matrix, quad.x(i), quad.y(i), quad.z(i));
        final int color = quad.spriteColor(i, 0);
        buff.color(color & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF, alpha);
        buff.texture(quad.spriteU(i, 0), quad.spriteV(i, 0));
        buff.overlay(overlay);
        buff.light(quad.lightmap(i));
        if (useNormals) {
            normalVec.set(quad.normalX(i), quad.normalY(i), quad.normalZ(i));
            normalVec.transform(normalMatrix);
        }
        buff.normal(normalVec.getX(), normalVec.getY(), normalVec.getZ());
        buff.next();
    }
}
Also used : Vec3f(net.minecraft.util.math.Vec3f)

Example 23 with Vec3f

use of net.minecraft.util.math.Vec3f in project fabricskyboxes by AMereBagatelle.

the class AbstractSkybox method renderDecorations.

public void renderDecorations(WorldRendererAccess worldRendererAccess, MatrixStack matrices, Matrix4f matrix4f, float tickDelta, BufferBuilder bufferBuilder, float alpha) {
    if (!SkyboxManager.getInstance().hasRenderedDecorations()) {
        Vec3f rotationStatic = decorations.getRotation().getStatic();
        Vec3f rotationAxis = decorations.getRotation().getAxis();
        RenderSystem.enableTexture();
        matrices.push();
        matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(rotationStatic.getX()));
        matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotationStatic.getY()));
        matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(rotationStatic.getZ()));
        ClientWorld world = MinecraftClient.getInstance().world;
        assert world != null;
        RenderSystem.enableTexture();
        RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
        matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(rotationAxis.getX()));
        matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotationAxis.getY()));
        matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(rotationAxis.getZ()));
        matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F));
        matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(world.getSkyAngle(tickDelta) * 360.0F * decorations.getRotation().getRotationSpeed()));
        matrices.multiply(Vec3f.NEGATIVE_Z.getDegreesQuaternion(rotationAxis.getZ()));
        matrices.multiply(Vec3f.NEGATIVE_Y.getDegreesQuaternion(rotationAxis.getY()));
        matrices.multiply(Vec3f.NEGATIVE_X.getDegreesQuaternion(rotationAxis.getX()));
        // sun
        RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
        Matrix4f matrix4f2 = matrices.peek().getPositionMatrix();
        float s = 30.0F;
        RenderSystem.setShader(GameRenderer::getPositionTexShader);
        if (decorations.isSunEnabled()) {
            RenderSystem.setShaderTexture(0, this.decorations.getSunTexture());
            bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
            bufferBuilder.vertex(matrix4f2, -s, 100.0F, -s).texture(0.0F, 0.0F).next();
            bufferBuilder.vertex(matrix4f2, s, 100.0F, -s).texture(1.0F, 0.0F).next();
            bufferBuilder.vertex(matrix4f2, s, 100.0F, s).texture(1.0F, 1.0F).next();
            bufferBuilder.vertex(matrix4f2, -s, 100.0F, s).texture(0.0F, 1.0F).next();
            bufferBuilder.end();
            BufferRenderer.draw(bufferBuilder);
        }
        // moon
        s = 20.0F;
        if (decorations.isMoonEnabled()) {
            RenderSystem.setShaderTexture(0, this.decorations.getMoonTexture());
            int u = world.getMoonPhase();
            int v = u % 4;
            int w = u / 4 % 2;
            float x = v / 4.0F;
            float p = w / 2.0F;
            float q = (v + 1) / 4.0F;
            float r = (w + 1) / 2.0F;
            bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
            bufferBuilder.vertex(matrix4f2, -s, -100.0F, s).texture(q, r).next();
            bufferBuilder.vertex(matrix4f2, s, -100.0F, s).texture(x, r).next();
            bufferBuilder.vertex(matrix4f2, s, -100.0F, -s).texture(x, p).next();
            bufferBuilder.vertex(matrix4f2, -s, -100.0F, -s).texture(q, p).next();
            bufferBuilder.end();
            BufferRenderer.draw(bufferBuilder);
        }
        // stars
        if (decorations.isStarsEnabled()) {
            RenderSystem.disableTexture();
            float ab = world.method_23787(tickDelta) * s;
            if (ab > 0.0F) {
                RenderSystem.setShaderColor(ab, ab, ab, ab);
                worldRendererAccess.getStarsBuffer().setShader(matrices.peek().getPositionMatrix(), matrix4f, GameRenderer.getPositionShader());
            }
        }
        matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(rotationStatic.getZ()));
        matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotationStatic.getY()));
        matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(rotationStatic.getX()));
        RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
        RenderSystem.disableBlend();
        matrices.pop();
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) ClientWorld(net.minecraft.client.world.ClientWorld) Vec3f(net.minecraft.util.math.Vec3f)

Example 24 with Vec3f

use of net.minecraft.util.math.Vec3f in project Skyblocker by LifeIsAParadox.

the class RenderUtilsLiving method drawGuiItem.

/**
 * Draws a 2D gui items somewhere in the world. *
 */
public static void drawGuiItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) {
    if (item.isEmpty()) {
        return;
    }
    MatrixStack matrices = matrixFrom(x, y, z);
    Camera camera = mc.gameRenderer.getCamera();
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
    matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
    matrices.translate(offX, offY, 0);
    matrices.scale((float) scale, (float) scale, 0.001f);
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180f));
    // mc.getBufferBuilders().getEntityVertexConsumers().draw();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    Vec3f[] currentLight = getCurrentLight();
    DiffuseLighting.disableGuiDepthLighting();
    mc.getBufferBuilders().getEntityVertexConsumers().draw();
    mc.getItemRenderer().renderItem(item, ModelTransformation.Mode.GUI, 0xF000F0, OverlayTexture.DEFAULT_UV, matrices, mc.getBufferBuilders().getEntityVertexConsumers(), 0);
    mc.getBufferBuilders().getEntityVertexConsumers().draw();
    RenderSystem.setShaderLights(currentLight[0], currentLight[1]);
    RenderSystem.disableBlend();
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) Camera(net.minecraft.client.render.Camera) Vec3f(net.minecraft.util.math.Vec3f)

Example 25 with Vec3f

use of net.minecraft.util.math.Vec3f in project Client by MatHax.

the class AbstractQuadRendererMixin method whBufferQuad.

// https://github.com/FabricMC/fabric/blob/351679a7decdd3044d778e74001de67463bee205/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/render/AbstractQuadRenderer.java#L86
// Again, nasty problem with mixins and for loops, hopefully I can fix this at a later date - Wala
private static void whBufferQuad(VertexConsumer buff, MutableQuadViewImpl quad, Matrix4f matrix, int overlay, Matrix3f normalMatrix, Vec3f normalVec, int alpha) {
    final boolean useNormals = quad.hasVertexNormals();
    if (useNormals)
        quad.populateMissingNormals();
    else {
        final Vec3f faceNormal = quad.faceNormal();
        normalVec.set(faceNormal.getX(), faceNormal.getY(), faceNormal.getZ());
        normalVec.transform(normalMatrix);
    }
    for (int i = 0; i < 4; i++) {
        buff.vertex(matrix, quad.x(i), quad.y(i), quad.z(i));
        final int color = quad.spriteColor(i, 0);
        buff.color(color & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF, alpha);
        buff.texture(quad.spriteU(i, 0), quad.spriteV(i, 0));
        buff.overlay(overlay);
        buff.light(quad.lightmap(i));
        if (useNormals) {
            normalVec.set(quad.normalX(i), quad.normalY(i), quad.normalZ(i));
            normalVec.transform(normalMatrix);
        }
        buff.normal(normalVec.getX(), normalVec.getY(), normalVec.getZ());
        buff.next();
    }
}
Also used : Vec3f(net.minecraft.util.math.Vec3f)

Aggregations

Vec3f (net.minecraft.util.math.Vec3f)28 Quaternion (net.minecraft.util.math.Quaternion)16 Vec3d (net.minecraft.util.math.Vec3d)10 Matrix4f (net.minecraft.util.math.Matrix4f)5 Matrix3f (net.minecraft.util.math.Matrix3f)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)3 Identifier (net.minecraft.util.Identifier)3 Color (java.awt.Color)2 Camera (net.minecraft.client.render.Camera)2 VertexConsumer (net.minecraft.client.render.VertexConsumer)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 ItemEntity (net.minecraft.entity.ItemEntity)2 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Pair (com.mojang.datafixers.util.Pair)1 CustomFont (dev.hypnotic.module.render.CustomFont)1 MonoColorSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.MonoColorSkybox)1 AnimatedSquareTexturedSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.AnimatedSquareTexturedSkybox)1 SquareTexturedSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.SquareTexturedSkybox)1