Search in sources :

Example 16 with Direction

use of net.minecraft.util.math.Direction in project fabric by FabricMC.

the class TerrainFallbackConsumer method accept.

@Override
public void accept(BakedModel model) {
    final Supplier<Random> random = blockInfo.randomSupplier;
    final Value defaultMaterial = blockInfo.defaultAo && model.useAmbientOcclusion() ? MATERIAL_SHADED : MATERIAL_FLAT;
    final BlockState blockState = blockInfo.blockState;
    for (int i = 0; i < 6; i++) {
        Direction face = ModelHelper.faceFromIndex(i);
        List<BakedQuad> quads = model.getQuads(blockState, face, random.get());
        final int count = quads.size();
        if (count != 0 && blockInfo.shouldDrawFace(face)) {
            for (int j = 0; j < count; j++) {
                BakedQuad q = quads.get(j);
                renderQuad(q, face, defaultMaterial);
            }
        }
    }
    List<BakedQuad> quads = model.getQuads(blockState, null, random.get());
    final int count = quads.size();
    if (count != 0) {
        for (int j = 0; j < count; j++) {
            BakedQuad q = quads.get(j);
            renderQuad(q, null, defaultMaterial);
        }
    }
}
Also used : BakedQuad(net.minecraft.client.render.model.BakedQuad) BlockState(net.minecraft.block.BlockState) Random(java.util.Random) Value(net.fabricmc.indigo.renderer.RenderMaterialImpl.Value) Direction(net.minecraft.util.math.Direction)

Example 17 with Direction

use of net.minecraft.util.math.Direction in project fabric by FabricMC.

the class AoCalculator method vanillaPartialFace.

private void vanillaPartialFace(QuadViewImpl quad, boolean isOnLightFace) {
    final Direction lightFace = quad.lightFace();
    AoFaceData faceData = computeFace(lightFace, isOnLightFace);
    final WeightFunction wFunc = AoFace.get(lightFace).weightFunc;
    final float[] w = this.w;
    for (int i = 0; i < 4; i++) {
        wFunc.apply(quad, i, w);
        light[i] = faceData.weightedCombinedLight(w);
        ao[i] = faceData.weigtedAo(w);
    }
}
Also used : WeightFunction(net.fabricmc.indigo.renderer.aocalc.AoFace.WeightFunction) Direction(net.minecraft.util.math.Direction)

Example 18 with Direction

use of net.minecraft.util.math.Direction in project fabric by FabricMC.

the class AoCalculator method blendedPartialFace.

private void blendedPartialFace(QuadViewImpl quad) {
    final Direction lightFace = quad.lightFace();
    AoFaceData faceData = blendedInsetFace(quad, 0, lightFace);
    final WeightFunction wFunc = AoFace.get(lightFace).weightFunc;
    for (int i = 0; i < 4; i++) {
        wFunc.apply(quad, i, w);
        light[i] = faceData.weightedCombinedLight(w);
        ao[i] = faceData.weigtedAo(w);
    }
}
Also used : WeightFunction(net.fabricmc.indigo.renderer.aocalc.AoFace.WeightFunction) Direction(net.minecraft.util.math.Direction)

Example 19 with Direction

use of net.minecraft.util.math.Direction in project fabric by FabricMC.

the class GeometryHelper method computeShapeFlags.

/**
 * Analyzes the quad and returns a value with some combination
 * of {@link #AXIS_ALIGNED_FLAG}, {@link #LIGHT_FACE_FLAG} and {@link #CUBIC_FLAG}.
 * Intended use is to optimize lighting when the geometry is regular.
 * Expects convex quads with all points co-planar.
 */
public static int computeShapeFlags(QuadView quad) {
    Direction lightFace = quad.lightFace();
    int bits = 0;
    if (isQuadParallelToFace(lightFace, quad)) {
        bits |= AXIS_ALIGNED_FLAG;
        if (isParallelQuadOnFace(lightFace, quad)) {
            bits |= LIGHT_FACE_FLAG;
        }
    }
    if (isQuadCubic(lightFace, quad)) {
        bits |= CUBIC_FLAG;
    }
    return bits;
}
Also used : Direction(net.minecraft.util.math.Direction) AxisDirection(net.minecraft.util.math.Direction.AxisDirection)

Example 20 with Direction

use of net.minecraft.util.math.Direction in project fabric by FabricMC.

the class NormalHelper method computeFaceNormal.

/**
 * Computes the face normal of the given quad and saves it in the provided non-null vector.
 * If {@link QuadView#nominalFace()} is set will optimize by confirming quad is parallel to that
 * face and, if so, use the standard normal for that face direction.<p>
 *
 * Will work with triangles also. Assumes counter-clockwise winding order, which is the norm.
 * Expects convex quads with all points co-planar.
 */
public static void computeFaceNormal(Vector3f saveTo, QuadView q) {
    final Direction nominalFace = q.nominalFace();
    if (GeometryHelper.isQuadParallelToFace(nominalFace, q)) {
        Vec3i vec = nominalFace.getVector();
        saveTo.set(vec.getX(), vec.getY(), vec.getZ());
        return;
    }
    final float x0 = q.x(0);
    final float y0 = q.y(0);
    final float z0 = q.z(0);
    final float x1 = q.x(1);
    final float y1 = q.y(1);
    final float z1 = q.z(1);
    final float x2 = q.x(2);
    final float y2 = q.y(2);
    final float z2 = q.z(2);
    final float x3 = q.x(3);
    final float y3 = q.y(3);
    final float z3 = q.z(3);
    final float dx0 = x2 - x0;
    final float dy0 = y2 - y0;
    final float dz0 = z2 - z0;
    final float dx1 = x3 - x1;
    final float dy1 = y3 - y1;
    final float dz1 = z3 - z1;
    float normX = dy0 * dz1 - dz0 * dy1;
    float normY = dz0 * dx1 - dx0 * dz1;
    float normZ = dx0 * dy1 - dy0 * dx1;
    float l = (float) Math.sqrt(normX * normX + normY * normY + normZ * normZ);
    if (l != 0) {
        normX /= l;
        normY /= l;
        normZ /= l;
    }
    saveTo.set(normX, normY, normZ);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) Direction(net.minecraft.util.math.Direction)

Aggregations

Direction (net.minecraft.util.math.Direction)238 BlockPos (net.minecraft.util.math.BlockPos)118 BlockState (net.minecraft.block.BlockState)66 Vec3d (net.minecraft.util.math.Vec3d)23 ModTags (com.ordana.immersive_weathering.registry.ModTags)20 BlockHitResult (net.minecraft.util.hit.BlockHitResult)16 Random (java.util.Random)15 Block (net.minecraft.block.Block)15 Box (net.minecraft.util.math.Box)11 Inject (org.spongepowered.asm.mixin.injection.Inject)11 net.minecraft.block (net.minecraft.block)10 World (net.minecraft.world.World)10 Nullable (org.jetbrains.annotations.Nullable)10 ServerWorld (net.minecraft.server.world.ServerWorld)9 SculkVeinBlock (frozenblock.wild.mod.blocks.SculkVeinBlock)7 Fluids (net.minecraft.fluid.Fluids)7 ItemStack (net.minecraft.item.ItemStack)7 ArrayList (java.util.ArrayList)6 Blocks (net.minecraft.block.Blocks)6 VoxelShape (net.minecraft.util.shape.VoxelShape)6