Search in sources :

Example 1 with Vec3f

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

the class Vertexer method vertexLine.

public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, LineColor lineColor) {
    Matrix4f model = matrices.peek().getPositionMatrix();
    Matrix3f normal = matrices.peek().getNormalMatrix();
    Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
    int[] color1 = lineColor.getColor(x1, y1, z1, 0);
    int[] color2 = lineColor.getColor(x2, y2, z2, 1);
    vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
    vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vec3f(net.minecraft.util.math.Vec3f)

Example 2 with Vec3f

use of net.minecraft.util.math.Vec3f in project BleachHack by BleachDrinker420.

the class Vertexer method vertexLine.

public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, LineColor lineColor) {
    Matrix4f model = matrices.peek().getModel();
    Matrix3f normal = matrices.peek().getNormal();
    Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
    int[] color1 = lineColor.getColor(x1, y1, z1, 0);
    int[] color2 = lineColor.getColor(x2, y2, z2, 1);
    vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
    vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vec3f(net.minecraft.util.math.Vec3f)

Example 3 with Vec3f

use of net.minecraft.util.math.Vec3f in project BleachHack by BleachDrinker420.

the class WorldRenderer 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 = shaderLight.clone();
    DiffuseLighting.disableGuiDepthLighting();
    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 4 with Vec3f

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

the class SkyboxGenerationTest method init.

@Test
public void init() throws IOException {
    DefaultProperties props = new DefaultProperties.Builder().changesFog().rotates().rotation(new Rotation(new Vec3f(0.1F, 0.0F, 0.1F), new Vec3f(0.0F, 0.0F, 0.0F), 1)).maxAlpha(0.99F).transitionSpeed(0.7F).fade(new Fade(1000, 2000, 11000, 12000, false)).build();
    Conditions conditions = new Conditions.Builder().biomes(new Identifier("minecraft:plains")).worlds(new Identifier("minecraft:overworld")).weather(Weather.CLEAR).yRanges(new MinMaxEntry(40, 120)).build();
    Decorations decorations = new Decorations(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, true, true, false, Rotation.DEFAULT);
    Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().setLenient().create();
    this.test(gson, MonoColorSkybox.CODEC, new MonoColorSkybox(props, conditions, decorations, new RGBA(0.5F, 0.8F, 0.6F, 0.99F)));
    this.test(gson, SquareTexturedSkybox.CODEC, new SquareTexturedSkybox(props, conditions, decorations, Blend.DEFAULT, new Textures(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, new Identifier("missingno"))));
    this.test(gson, AnimatedSquareTexturedSkybox.CODEC, new AnimatedSquareTexturedSkybox(props, conditions, decorations, Blend.DEFAULT, Arrays.asList(new Textures(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, new Identifier("missingno")), new Textures(SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, new Identifier("missingno"), SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE), new Textures(SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE)), 0.2F));
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) AnimatedSquareTexturedSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.AnimatedSquareTexturedSkybox) Vec3f(net.minecraft.util.math.Vec3f) Identifier(net.minecraft.util.Identifier) SquareTexturedSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.SquareTexturedSkybox) AnimatedSquareTexturedSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.AnimatedSquareTexturedSkybox) MonoColorSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.MonoColorSkybox) Test(org.junit.jupiter.api.Test)

Example 5 with Vec3f

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

the class ShriekParticleNX2 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(-1.0F, -1.0F, 0.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)

Aggregations

Vec3f (net.minecraft.util.math.Vec3f)25 Quaternion (net.minecraft.util.math.Quaternion)13 Vec3d (net.minecraft.util.math.Vec3d)8 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 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 Environment (net.fabricmc.api.Environment)1