use of com.mojang.math.Vector3f in project MinecraftForge by MinecraftForge.
the class QuadTransformer method processVertices.
private void processVertices(int[] inData, int[] outData) {
int stride = DefaultVertexFormat.BLOCK.getVertexSize();
int count = (inData.length * 4) / stride;
for (int i = 0; i < count; i++) {
int offset = POSITION + i * stride;
float x = Float.intBitsToFloat(getAtByteOffset(inData, offset));
float y = Float.intBitsToFloat(getAtByteOffset(inData, offset + 4));
float z = Float.intBitsToFloat(getAtByteOffset(inData, offset + 8));
Vector4f pos = new Vector4f(x, y, z, 1);
transform.transformPosition(pos);
pos.perspectiveDivide();
putAtByteOffset(outData, offset, Float.floatToRawIntBits(pos.x()));
putAtByteOffset(outData, offset + 4, Float.floatToRawIntBits(pos.y()));
putAtByteOffset(outData, offset + 8, Float.floatToRawIntBits(pos.z()));
}
for (int i = 0; i < count; i++) {
int offset = NORMAL + i * stride;
int normalIn = getAtByteOffset(inData, offset);
if (normalIn != 0) {
float x = ((byte) ((normalIn) >> 24)) / 127.0f;
float y = ((byte) ((normalIn << 8) >> 24)) / 127.0f;
float z = ((byte) ((normalIn << 16) >> 24)) / 127.0f;
Vector3f pos = new Vector3f(x, y, z);
transform.transformNormal(pos);
pos.normalize();
int normalOut = ((((byte) (x / 127.0f)) & 0xFF) << 24) | ((((byte) (y / 127.0f)) & 0xFF) << 16) | ((((byte) (z / 127.0f)) & 0xFF) << 8) | (normalIn & 0xFF);
putAtByteOffset(outData, offset, normalOut);
}
}
}
use of com.mojang.math.Vector3f in project MinecraftForge by MinecraftForge.
the class TransformationHelper method lerp.
public static Vector3f lerp(Vector3f from, Vector3f to, float progress) {
Vector3f res = from.copy();
res.lerp(to, progress);
return res;
}
Aggregations