use of net.modificationstation.stationapi.api.util.math.Vector3f in project StationAPI by ModificationStation.
the class StationTessellator method quad.
@Override
default void quad(MatrixStack.Entry matrixEntry, BakedQuad quad, float[] brightnesses, float red, float green, float blue, int[] lights, int overlay, boolean useQuadColorData) {
float[] fs = new float[] { brightnesses[0], brightnesses[1], brightnesses[2], brightnesses[3] };
int[] is = new int[] { lights[0], lights[1], lights[2], lights[3] };
int[] js = quad.getVertexData();
Vec3i vec3i = quad.getFace().vector;
Vector3f vec3f = new Vector3f(vec3i.x, vec3i.y, vec3i.z);
Matrix4f matrix4f = matrixEntry.getModel();
vec3f.transform(matrixEntry.getNormal());
int j = js.length / 8;
ByteBuffer byteBuffer = BUFFER;
IntBuffer intBuffer = byteBuffer.asIntBuffer();
for (int k = 0; k < j; ++k) {
float q;
float p;
float o;
float n;
float m;
intBuffer.clear();
intBuffer.put(js, k * 8, 8);
float f = byteBuffer.getFloat(0);
float g = byteBuffer.getFloat(4);
float h = byteBuffer.getFloat(8);
if (useQuadColorData) {
float l = (float) (byteBuffer.get(20) & 0xFF) / 255.0f;
m = (float) (byteBuffer.get(21) & 0xFF) / 255.0f;
n = (float) (byteBuffer.get(22) & 0xFF) / 255.0f;
o = l * fs[k] * red;
p = m * fs[k] * green;
q = n * fs[k] * blue;
} else {
o = fs[k] * red;
p = fs[k] * green;
q = fs[k] * blue;
}
int r = is[k];
m = byteBuffer.getFloat(12);
n = byteBuffer.getFloat(16);
Vector4f vector4f = new Vector4f(f, g, h, 1.0f);
vector4f.transform(matrix4f);
this.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), o, p, q, 1.0f, m, n, overlay, r, vec3f.getX(), vec3f.getY(), vec3f.getZ());
}
}
use of net.modificationstation.stationapi.api.util.math.Vector3f in project StationAPI by ModificationStation.
the class VertexConsumer method quad.
default void quad(MatrixStack.Entry matrixEntry, BakedQuad quad, float[] brightnesses, float red, float green, float blue, int[] lights, int overlay, boolean useQuadColorData) {
float[] fs = new float[] { brightnesses[0], brightnesses[1], brightnesses[2], brightnesses[3] };
int[] is = new int[] { lights[0], lights[1], lights[2], lights[3] };
int[] js = quad.getVertexData();
Vec3i vec3i = quad.getFace().vector;
Vector3f vec3f = new Vector3f(vec3i.x, vec3i.y, vec3i.z);
Matrix4f matrix4f = matrixEntry.getModel();
vec3f.transform(matrixEntry.getNormal());
int j = js.length / 8;
ByteBuffer byteBuffer = BUFFER;
IntBuffer intBuffer = byteBuffer.asIntBuffer();
for (int k = 0; k < j; ++k) {
float q;
float p;
float o;
float n;
float m;
intBuffer.clear();
intBuffer.put(js, k * 8, 8);
float f = byteBuffer.getFloat(0);
float g = byteBuffer.getFloat(4);
float h = byteBuffer.getFloat(8);
if (useQuadColorData) {
float l = (float) (byteBuffer.get(12) & 0xFF) / 255.0f;
m = (float) (byteBuffer.get(13) & 0xFF) / 255.0f;
n = (float) (byteBuffer.get(14) & 0xFF) / 255.0f;
o = l * fs[k] * red;
p = m * fs[k] * green;
q = n * fs[k] * blue;
} else {
o = fs[k] * red;
p = fs[k] * green;
q = fs[k] * blue;
}
int r = is[k];
m = byteBuffer.getFloat(16);
n = byteBuffer.getFloat(20);
Vector4f vector4f = new Vector4f(f, g, h, 1.0f);
vector4f.transform(matrix4f);
this.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), o, p, q, 1.0f, m, n, overlay, r, vec3f.getX(), vec3f.getY(), vec3f.getZ());
}
}
use of net.modificationstation.stationapi.api.util.math.Vector3f in project StationAPI by ModificationStation.
the class ModelHelper method makeTransform.
/**
* The vanilla model transformation logic is closely coupled with model deserialization.
* That does little good for modded model loaders and procedurally generated models.
* This convenient construction method applies the same scaling factors used for vanilla models.
* This means you can use values from a vanilla JSON file as inputs to this method.
*/
private static Transformation makeTransform(float rotationX, float rotationY, @SuppressWarnings("SameParameterValue") float rotationZ, @SuppressWarnings("SameParameterValue") float translationX, float translationY, @SuppressWarnings("SameParameterValue") float translationZ, float scaleX, float scaleY, float scaleZ) {
Vector3f translation = new Vector3f(translationX, translationY, translationZ);
translation.scale(0.0625f);
translation.clamp(-5.0F, 5.0F);
return new Transformation(new Vector3f(rotationX, rotationY, rotationZ), translation, new Vector3f(scaleX, scaleY, scaleZ));
}
use of net.modificationstation.stationapi.api.util.math.Vector3f in project StationAPI by ModificationStation.
the class QuadViewImpl method copyNormal.
@Override
public Vector3f copyNormal(int vertexIndex, Vector3f target) {
if (hasNormal(vertexIndex)) {
if (target == null) {
target = new Vector3f();
}
final int normal = data[normalIndex(vertexIndex)];
target.set(NormalHelper.getPackedNormalComponent(normal, 0), NormalHelper.getPackedNormalComponent(normal, 1), NormalHelper.getPackedNormalComponent(normal, 2));
return target;
} else {
return null;
}
}
use of net.modificationstation.stationapi.api.util.math.Vector3f in project StationAPI by ModificationStation.
the class QuadViewImpl method copyPos.
@Override
public Vector3f copyPos(int vertexIndex, Vector3f target) {
if (target == null) {
target = new Vector3f();
}
final int index = baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_X;
target.set(Float.intBitsToFloat(data[index]), Float.intBitsToFloat(data[index + 1]), Float.intBitsToFloat(data[index + 2]));
return target;
}
Aggregations