MineLittlePony/src/main/java/com/minelittlepony/render/HornGlow.java

77 lines
2.3 KiB
Java
Raw Normal View History

2018-04-26 23:46:32 +02:00
package com.minelittlepony.render;
2015-11-17 06:09:04 +01:00
import net.minecraft.client.renderer.BufferBuilder;
import com.minelittlepony.util.coordinates.*;
/**
* Like a normal box, but with the top narrowed a bit.
*/
public class HornGlow extends Box<HornGlowRenderer> {
2015-08-02 00:36:33 +02:00
private final float alpha;
2018-04-26 23:46:32 +02:00
private Quad[] quadList;
2018-04-26 23:46:32 +02:00
public HornGlow(HornGlowRenderer renderer, int texX, int texY, float xMin, float yMin, float zMin, int w, int h, int d, float scale, float alpha) {
super(renderer, texX, texY, xMin, yMin, zMin, w, h, d, scale);
2015-08-02 00:36:33 +02:00
this.alpha = alpha;
2018-04-26 23:46:32 +02:00
float xMax = xMin + w + scale;
float yMax = yMin + h + scale;
float zMax = zMin + d + scale;
2018-04-26 23:46:32 +02:00
xMin -= scale;
yMin -= scale;
zMin -= scale;
2018-04-26 23:46:32 +02:00
if (renderer.mirror) {
float v = xMax;
xMax = xMin;
xMin = v;
2015-08-02 00:36:33 +02:00
}
float tipInset = 0.4f;
float tipXmin = xMin + w * tipInset;
float tipZmin = zMin + d * tipInset;
float tipXMax = xMax - w * tipInset;
float tipZMax = zMax - d * tipInset;
// w:west e:east d:down u:up s:south n:north
Vertex wds = vert(tipXmin, yMin, tipZmin, 0, 0);
Vertex eds = vert(tipXMax, yMin, tipZmin, 0, 8);
Vertex eus = vert(xMax, yMax, zMin, 8, 8);
Vertex wus = vert(xMin, yMax, zMin, 8, 0);
Vertex wdn = vert(tipXmin, yMin, tipZMax, 0, 0);
Vertex edn = vert(tipXMax, yMin, tipZMax, 0, 8);
Vertex eun = vert(xMax, yMax, zMax, 8, 8);
Vertex wun = vert(xMin, yMax, zMax, 8, 0);
quadList = new Quad[] {
quad(texX + d + w, d, texY + d, h, edn, eds, eus, eun),
quad(texX, d, texY + d, h, wds, wdn, wun, wus),
quad(texX + d, w, texY, d, edn, wdn, wds, eds),
quad(texX + d + w, w, texY + d, -d, eus, wus, wun, eun),
quad(texX + d, w, texY + d, h, eds, wds, wus, eus),
quad(texX + d + w + d, w, texY + d, h, wdn, edn, eun, wun)
};
if (renderer.mirror) {
for (Quad i : quadList) {
2018-04-26 16:01:31 +02:00
i.flipFace();
2015-08-02 00:36:33 +02:00
}
}
}
@Override
public void render(BufferBuilder buffer, float scale) {
parent.applyTint(alpha);
2018-04-26 23:46:32 +02:00
for (Quad i : quadList) {
2018-04-26 16:01:31 +02:00
i.draw(buffer, scale);
2015-08-02 00:36:33 +02:00
}
}
}