mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Fixed rendering of shields
This commit is contained in:
parent
3673d52511
commit
6d82ecc73b
4 changed files with 36 additions and 53 deletions
|
@ -5,7 +5,6 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.util.math.Matrix4f;
|
||||
|
||||
public class DiskModel extends SphereModel {
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack.Entry matrices, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
|
||||
Matrix4f model = matrices.getModel();
|
||||
|
@ -15,9 +14,8 @@ public class DiskModel extends SphereModel {
|
|||
|
||||
double radius = 1;
|
||||
|
||||
for(double zenith = 0; zenith < Math.PI; zenith += zenithIncrement) {
|
||||
for (double zenith = 0; zenith < Math.PI; zenith += zenithIncrement) {
|
||||
drawVertex(model, vertexWriter, radius, zenith, Math.PI, light, overlay, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
|
||||
public class DiskParticle extends SphereParticle {
|
||||
|
||||
|
@ -30,13 +31,10 @@ public class DiskParticle extends SphereParticle {
|
|||
|
||||
@Override
|
||||
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
|
||||
if (colorAlpha <= 0) {
|
||||
if (colorAlpha <= 0 || radius <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
MODEL.setPosition(x, y, z);
|
||||
MODEL.setRotation(rotX, rotY, rotZ);
|
||||
|
||||
float[] color = ColorHelper.changeSaturation(colorRed, colorGreen, colorBlue, 4);
|
||||
RenderSystem.setShaderColor(color[0], color[1], color[2], colorAlpha / 3F);
|
||||
|
||||
|
@ -46,7 +44,13 @@ public class DiskParticle extends SphereParticle {
|
|||
int light = getBrightness(tickDelta);
|
||||
|
||||
MatrixStack matrices = new MatrixStack();
|
||||
MODEL.render(matrices, radius, buffer, 1, light, 1, 1, 1, 1);
|
||||
matrices.push();
|
||||
matrices.translate(x, y, z);
|
||||
matrices.multiply(new Quaternion(rotX, rotY, rotZ, true));
|
||||
matrices.scale(radius, radius, radius);
|
||||
MODEL.render(matrices, buffer, 1, light, 1, 1, 1, 1);
|
||||
|
||||
matrices.pop();
|
||||
|
||||
immediate.draw();
|
||||
|
||||
|
|
|
@ -3,46 +3,11 @@ package com.minelittlepony.unicopia.client.particle;
|
|||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
import net.minecraft.util.math.Vector4f;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class SphereModel {
|
||||
|
||||
protected Vec3d pos;
|
||||
|
||||
protected Quaternion rotX = Quaternion.IDENTITY;
|
||||
protected Quaternion rotY = Quaternion.IDENTITY;
|
||||
protected Quaternion rotZ = Quaternion.IDENTITY;
|
||||
|
||||
public void setPosition(double x, double y, double z) {
|
||||
pos = new Vec3d(x, y, z);
|
||||
}
|
||||
|
||||
public void setRotation(float x, float y, float z) {
|
||||
rotX = Vec3f.POSITIVE_X.getDegreesQuaternion(x);
|
||||
rotY = Vec3f.POSITIVE_Y.getDegreesQuaternion(y);
|
||||
rotZ = Vec3f.POSITIVE_Z.getDegreesQuaternion(z);
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, float scale, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
|
||||
if (scale == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
matrices.push();
|
||||
|
||||
matrices.translate(pos.x, pos.y, pos.z);
|
||||
matrices.multiply(rotX);
|
||||
matrices.multiply(rotY);
|
||||
matrices.multiply(rotZ);
|
||||
|
||||
matrices.scale(scale, scale, scale);
|
||||
|
||||
public void render(MatrixStack matrices, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
|
||||
render(matrices.peek(), vertexWriter, light, overlay, r, g, b, a);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
public void render(MatrixStack.Entry matrices, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
|
||||
|
|
|
@ -116,13 +116,6 @@ public class SphereParticle extends Particle implements Attachment {
|
|||
return;
|
||||
}
|
||||
|
||||
MODEL.setPosition(
|
||||
MathHelper.lerp(tickDelta, prevPosX, x) - camera.getPos().x,
|
||||
MathHelper.lerp(tickDelta, prevPosY, y) - camera.getPos().y,
|
||||
MathHelper.lerp(tickDelta, prevPosZ, z) - camera.getPos().z
|
||||
);
|
||||
MODEL.setRotation(0, 0, 0);
|
||||
|
||||
float lerpedRad = MathHelper.lerp(tickDelta, prevRadius, radius);
|
||||
|
||||
float[] color = ColorHelper.changeSaturation(colorRed, colorGreen, colorBlue, 4);
|
||||
|
@ -136,8 +129,31 @@ public class SphereParticle extends Particle implements Attachment {
|
|||
int light = getBrightness(tickDelta);
|
||||
|
||||
MatrixStack matrices = new MatrixStack();
|
||||
MODEL.render(matrices, lerpedRad + thickness, buffer, light, 1, 1, 1, 1, 0.8F);
|
||||
MODEL.render(matrices, lerpedRad - thickness, buffer, light, 1, 1, 1, 1, 1);
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(
|
||||
MathHelper.lerp(tickDelta, prevPosX, x) - camera.getPos().x,
|
||||
MathHelper.lerp(tickDelta, prevPosY, y) - camera.getPos().y,
|
||||
MathHelper.lerp(tickDelta, prevPosZ, z) - camera.getPos().z
|
||||
);
|
||||
|
||||
float scale = lerpedRad + thickness;
|
||||
|
||||
if (scale > 0) {
|
||||
matrices.push();
|
||||
matrices.scale(scale, scale, scale);
|
||||
MODEL.render(matrices, buffer, light, 1, 1, 1, 1, 0.8F);
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
scale = lerpedRad - thickness;
|
||||
|
||||
if (scale > 0) {
|
||||
matrices.scale(scale, scale, scale);
|
||||
|
||||
MODEL.render(matrices, buffer, light, 1, 1, 1, 1, 1);
|
||||
}
|
||||
matrices.pop();
|
||||
|
||||
immediate.draw();
|
||||
|
||||
|
|
Loading…
Reference in a new issue