1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package makamys.neodymium.renderer;
import makamys.neodymium.Compat;
import makamys.neodymium.Neodymium;
import makamys.neodymium.config.Config;
import makamys.neodymium.util.BufferWriter;
import makamys.neodymium.util.Util;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;
import java.util.Locale;
public class MeshQuad {
public final static int DEFAULT_BRIGHTNESS = Util.createBrightness(15, 15);
public final static int DEFAULT_COLOR = 0xFFFFFFFF;
//region common
public float[] xs = new float[4];
public float[] ys = new float[4];
public float[] zs = new float[4];
public float[] us = new float[4];
public float[] vs = new float[4];
public int[] cs = new int[4];
// TODO normals?
public int[] bs = new int[4];
//endregion common
//region RPLE
// bs used as RED
public int[] bsG = new int[4];
public int[] bsB = new int[4];
//endregion RPLE
//region Shaders
public int[] e1 = new int[4];
public int[] e2 = new int[4];
public float[] xn = new float[4];
public float[] yn = new float[4];
public float[] zn = new float[4];
public float[] xt = new float[4];
public float[] yt = new float[4];
public float[] zt = new float[4];
public float[] wt = new float[4];
public float[] um = new float[4];
public float[] vm = new float[4];
//endregion Shaders
//region Shaders + RPLE
public float[] ue = new float[4];
public float[] ve = new float[4];
//endregion Shaders + RPLE
public boolean deleted;
public QuadNormal normal;
private static Vector3f vectorA = new Vector3f();
private static Vector3f vectorB = new Vector3f();
private static Vector3f vectorC = new Vector3f();
public void setState(int[] rawBuffer, int tessellatorVertexSize, int offset, ChunkMesh.Flags flags, int drawMode, float offsetX, float offsetY, float offsetZ) {
deleted = false;
Neodymium.util.readMeshQuad(this, rawBuffer, tessellatorVertexSize, offset, offsetX, offsetY, offsetZ, drawMode, flags);
if(xs[0] == xs[1] && xs[1] == xs[2] && xs[2] == xs[3] && ys[0] == ys[1] && ys[1] == ys[2] && ys[2] == ys[3]) {
// ignore empty quads (e.g. alpha pass of EnderIO item conduits)
deleted = true;
return;
}
vectorA.set(xs[1] - xs[0], ys[1] - ys[0], zs[1] - zs[0]);
vectorB.set(xs[2] - xs[1], ys[2] - ys[1], zs[2] - zs[1]);
Vector3f.cross(vectorA, vectorB, vectorC);
normal = QuadNormal.fromVector(vectorC);
}
@Override
public String toString() {
return String.format(Locale.ENGLISH, "%s[(%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f)]", deleted ? "XXX " : "", xs[0], ys[0], zs[0], xs[1], ys[1], zs[1], xs[2], ys[2], zs[2], xs[3], ys[3], zs[3]);
}
public static boolean isValid(MeshQuad q) {
return q != null && !q.deleted;
}
}
|