Got Rift rendering to work correctly. Still needs alot of work.
This commit is contained in:
parent
dcf649674c
commit
ab2681bc35
4 changed files with 21 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.dimdev.dimdoors.client;
|
package org.dimdev.dimdoors.client;
|
||||||
|
|
||||||
import com.flowpowered.math.TrigMath;
|
import com.flowpowered.math.TrigMath;
|
||||||
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import org.dimdev.dimdoors.ModConfig;
|
import org.dimdev.dimdoors.ModConfig;
|
||||||
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
|
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
|
||||||
import org.dimdev.dimdoors.client.tesseract.Tesseract;
|
import org.dimdev.dimdoors.client.tesseract.Tesseract;
|
||||||
|
@ -32,6 +33,8 @@ public class DetachedRiftBlockEntityRenderer extends BlockEntityRenderer<Detache
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(DetachedRiftBlockEntity rift, float tickDelta, MatrixStack matrices, VertexConsumerProvider vcs, int breakProgress, int alpha) {
|
public void render(DetachedRiftBlockEntity rift, float tickDelta, MatrixStack matrices, VertexConsumerProvider vcs, int breakProgress, int alpha) {
|
||||||
|
Matrix4f model = matrices.peek().getModel();
|
||||||
|
|
||||||
if (ModConfig.GRAPHICS.showRiftCore) {
|
if (ModConfig.GRAPHICS.showRiftCore) {
|
||||||
renderTesseract(vcs.getBuffer(MyRenderLayer.TESSERACT), rift, matrices, tickDelta);
|
renderTesseract(vcs.getBuffer(MyRenderLayer.TESSERACT), rift, matrices, tickDelta);
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,13 +44,13 @@ public class DetachedRiftBlockEntityRenderer extends BlockEntityRenderer<Detache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCrack(vcs.getBuffer(RenderLayer.getLightning()), matrices, rift);
|
renderCrack(vcs.getBuffer(MyRenderLayer.CRACK), matrices, rift);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderCrack(VertexConsumer vc, MatrixStack matrices, DetachedRiftBlockEntity rift) {
|
private void renderCrack(VertexConsumer vc, MatrixStack matrices, DetachedRiftBlockEntity rift) {
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(0.5, 0.5, 0.5);
|
matrices.translate(0.5, 0.5, 0.5);
|
||||||
RiftCrackRenderer.drawCrack(vc, 0, CURVE, ModConfig.GRAPHICS.riftSize * rift.size, 0xF1234568L * rift.getPos().hashCode());
|
RiftCrackRenderer.drawCrack(matrices.peek().getModel(), vc, 0, CURVE, ModConfig.GRAPHICS.riftSize * rift.size, 0xF1234568L * rift.getPos().hashCode());
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ public class DetachedRiftBlockEntityRenderer extends BlockEntityRenderer<Detache
|
||||||
matrices.translate(0.5, 0.5, 0.5);
|
matrices.translate(0.5, 0.5, 0.5);
|
||||||
matrices.scale(0.25f, 0.25f, 0.25f);
|
matrices.scale(0.25f, 0.25f, 0.25f);
|
||||||
|
|
||||||
TESSERACT.draw(vc, color, radian);
|
TESSERACT.draw(matrices.peek().getModel(), vc, color, radian);
|
||||||
|
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.dimdev.dimdoors.client;
|
package org.dimdev.dimdoors.client;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import org.dimdev.dimdoors.ModConfig;
|
import org.dimdev.dimdoors.ModConfig;
|
||||||
|
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
|
@ -9,7 +10,7 @@ import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public final class RiftCrackRenderer {
|
public final class RiftCrackRenderer {
|
||||||
public static void drawCrack(VertexConsumer vc, float riftRotation, RiftCurves.PolygonInfo poly, double size, long riftRandom) {
|
public static void drawCrack(Matrix4f model, VertexConsumer vc, float riftRotation, RiftCurves.PolygonInfo poly, double size, long riftRandom) {
|
||||||
// Calculate the proper size for the rift render
|
// Calculate the proper size for the rift render
|
||||||
double scale = size / (poly.maxX - poly.minX);
|
double scale = size / (poly.maxX - poly.minX);
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public final class RiftCrackRenderer {
|
||||||
y *= scale;
|
y *= scale;
|
||||||
z *= scale;
|
z *= scale;
|
||||||
|
|
||||||
vc.vertex(x,y,z).color(0.08f, 0.08f, 0.08f, .3f).next();
|
vc.vertex(model, (float) x, (float) y, (float) z).color(0.08f, 0.08f, 0.08f, .3f).next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,19 @@ public class Plane {
|
||||||
vectors = new Vector4f[]{vec1, vec2, vec3, vec4};
|
vectors = new Vector4f[]{vec1, vec2, vec3, vec4};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(VertexConsumer vc, RGBA color, double radian) {
|
public void draw(net.minecraft.util.math.Matrix4f model, VertexConsumer vc, RGBA color, double radian) {
|
||||||
drawVertex(vc, rotYW(vectors[0], radian), 0, 0, color);
|
drawVertex(model, vc, rotYW(vectors[0], radian), 0, 0, color);
|
||||||
drawVertex(vc, rotYW(vectors[1], radian), 0, 1, color);
|
drawVertex(model, vc, rotYW(vectors[1], radian), 0, 1, color);
|
||||||
drawVertex(vc, rotYW(vectors[2], radian), 1, 1, color);
|
drawVertex(model, vc, rotYW(vectors[2], radian), 1, 1, color);
|
||||||
drawVertex(vc, rotYW(vectors[3], radian), 1, 0, color);
|
drawVertex(model, vc, rotYW(vectors[3], radian), 1, 0, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawVertex(VertexConsumer vc, Vector4f vector, int u, int v, RGBA color) {
|
private static void drawVertex(net.minecraft.util.math.Matrix4f model, VertexConsumer vc, Vector4f vector, int u, int v, RGBA color) {
|
||||||
double scalar = 1d / (vector.getW() + 1);
|
double scalar = 1d / (vector.getW() + 1);
|
||||||
Vector3f scaled = vector.toVector3().mul(scalar);
|
Vector3f scaled = vector.toVector3().mul(scalar);
|
||||||
|
vc.vertex(model, scaled.getX(), scaled.getY(), scaled.getZ())
|
||||||
vc.vertex(scaled.getX(), scaled.getY(), scaled.getZ())
|
|
||||||
.texture(u, v)
|
|
||||||
.color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha())
|
.color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha())
|
||||||
|
.texture(u, v)
|
||||||
.next();
|
.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.client.render.VertexConsumer;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import org.dimdev.dimdoors.util.RGBA;
|
import org.dimdev.dimdoors.util.RGBA;
|
||||||
|
|
||||||
public class Tesseract {
|
public class Tesseract {
|
||||||
|
@ -182,9 +183,9 @@ public class Tesseract {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void draw(VertexConsumer vc, RGBA color, double radian) {
|
public void draw(Matrix4f model, VertexConsumer vc, RGBA color, double radian) {
|
||||||
for (Plane plane : planes) {
|
for (Plane plane : planes) {
|
||||||
plane.draw(vc, color, radian);
|
plane.draw(model, vc, color, radian);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue