Java Code Examples for org.lwjgl.util.vector.Vector3f#normalise()

The following examples show how to use org.lwjgl.util.vector.Vector3f#normalise() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 2
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 3
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 4
Source File: Trackball.java    From OpenModsLib with MIT License 6 votes vote down vote up
private Matrix4f getTransform(float mouseX, float mouseY) {
	Preconditions.checkNotNull(dragStart, "Draging not started");
	Vector3f current = calculateSpherePoint(mouseX, mouseY);

	float dot = Vector3f.dot(dragStart, current);
	if (Math.abs(dot - 1) < 0.0001) return lastTransform;

	Vector3f axis = Vector3f.cross(dragStart, current, null);

	try {
		axis.normalise();
	} catch (IllegalStateException e) { // Zero length vector
		return lastTransform;
	}

	float angle = 2 * (float)(Math.acos(dot));

	Matrix4f rotation = new Matrix4f();
	rotation.rotate(angle, axis);
	return Matrix4f.mul(rotation, lastTransform, null);

}
 
Example 5
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 6
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 7
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 8
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 9
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 10
Source File: FaceBakery.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void fillNormal(int[] faceData) {
	Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
	Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
	Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
	Vector3f result1 = new Vector3f();
	Vector3f result2 = new Vector3f();
	Vector3f result3 = new Vector3f();
	Vector3f.sub(v1, t, result1);
	t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
	Vector3f.sub(v2, t, result2);
	Vector3f.cross(result2, result1, result3);
	result3.normalise();

	int x = ((byte) (result3.x * 127)) & 0xFF;
	int y = ((byte) (result3.y * 127)) & 0xFF;
	int z = ((byte) (result3.z * 127)) & 0xFF;
	for (int i = 0; i < 4; i++) {
		faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
	}
}
 
Example 11
Source File: BillboardPainter.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
private final static void initClipPlane(int clip_enum, int face_index, int vertex_index1, int vertex_index2, short[] indices, float[] face_tex_coords, float handedness) {
	float u1 = getElement(face_index, vertex_index1, 0, 2, indices, face_tex_coords);
	float v1 = getElement(face_index, vertex_index1, 1, 2, indices, face_tex_coords);
	float u2 = getElement(face_index, vertex_index2, 0, 2, indices, face_tex_coords);
	float v2 = getElement(face_index, vertex_index2, 1, 2, indices, face_tex_coords);
	Vector3f vec1 = new Vector3f(0f, 0f, 1f);
	Vector3f vec2 = new Vector3f(u2 - u1, v2 - v1, 0);
	Vector3f vec3 = new Vector3f();
	Vector3f.cross(vec1, vec2, vec3);
	vec3.scale(handedness);
	vec3.normalise();
	vec1.set(u1, v1, 0f);
	float d = -Vector3f.dot(vec3, vec1);
	plane_buf.put(0, vec3.x).put(1, vec3.y).put(2, vec3.z).put(3, d);
	GL11.glClipPlane(clip_enum, plane_buf);
}
 
Example 12
Source File: PerspectiveCamera.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Vector3f getForward()
{
	Vector3f forward = new Vector3f();
	
	forward.x = lookAt.x - eye.x;
	forward.y = lookAt.y - eye.y;
	forward.z = lookAt.z - eye.z;
	
	forward.normalise();
	
	return forward;
}
 
Example 13
Source File: OrthoCamera.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Vector3f getForward()
{
	Vector3f forward = new Vector3f();
	
	forward.x = lookAt.x - eye.x;
	forward.y = lookAt.y - eye.y;
	forward.z = lookAt.z - eye.z;
	
	forward.normalise();
	
	return forward;
}
 
Example 14
Source File: Frustum.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Vector3f cross(Vector3f lhs, Vector3f rhs)
{
	Vector3f normLeft = new Vector3f(lhs);
	normLeft.normalise();
	Vector3f normRight = new Vector3f(rhs);
	normRight.normalise();
	
	Vector3f res = new Vector3f();
	
	Vector3f.cross(normLeft, normRight, res);
	
	return res;
}
 
Example 15
Source File: MatrixUtil.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Matrix4f createLookAt(Vector3f eye, Vector3f lookAt, Vector3f up)
{
	Matrix4f matrix = new Matrix4f();
	matrix.setIdentity();
	
	// Create the basis vectors
	Vector3f forwards = Vector3f.sub(eye, lookAt, null);
	forwards.normalise();
	
	Vector3f right = Vector3f.cross(up, forwards, null);
	right.normalise();
	
	Vector3f actualUp = Vector3f.cross(forwards, right, null);
	actualUp.normalise();
	
	// Right vector across the top
	matrix.m00 = right.x;
	matrix.m10 = right.y;
	matrix.m20 = right.z;
	
	// Up vector across the middle row
	matrix.m01 = actualUp.x;
	matrix.m11 = actualUp.y;
	matrix.m21 = actualUp.z;
	
	// Forwards vector across the bottom row
	matrix.m02 = forwards.x;
	matrix.m12 = forwards.y;
	matrix.m22 = forwards.z;
	
	// Negative translation in the last column
	Matrix4f translation = new Matrix4f();
	translation.setIdentity();
	translation.translate(new Vector3f(-eye.x, -eye.y, -eye.z));
	
	return Matrix4f.mul(matrix, translation, null);
}
 
Example 16
Source File: Maths.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
/**
 * Calculates the normal of the triangle made from the 3 vertices. The vertices must be specified in counter-clockwise order.
 * @param vertex0
 * @param vertex1
 * @param vertex2
 * @return
 */
public static Vector3f calcNormal(Vector3f vertex0, Vector3f vertex1, Vector3f vertex2) {
	Vector3f tangentA = Vector3f.sub(vertex1, vertex0, null);
	Vector3f tangentB = Vector3f.sub(vertex2, vertex0, null);
	Vector3f normal = Vector3f.cross(tangentA, tangentB, null);
	normal.normalise();
	return normal;
}
 
Example 17
Source File: ArrowBlunt.java    From ldparteditor with MIT License 4 votes vote down vote up
private Matrix4f makeRotationDir(Vector3f direction) {
    final Vector3f direction2 = new Vector3f();
    Matrix4f arrowRotation = new Matrix4f();
    direction.normalise();

    // Calculate point from hesse normal plane

    int rank = 0;
    if (Math.abs(direction.x) < EPSILON)
        rank++;
    if (Math.abs(direction.y) < EPSILON)
        rank++;
    if (Math.abs(direction.z) < EPSILON)
        rank++;

    if (rank == 1) {
        if (Math.abs(direction.x) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.y) < EPSILON)
            direction2.set(0f, 1f, 0f);
        else if (Math.abs(direction.z) < EPSILON)
            direction2.set(0f, 0f, 1f);
    } else if (rank == 2) {
        if (Math.abs(direction.x) < EPSILON && Math.abs(direction.y) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.x) < EPSILON && Math.abs(direction.z) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.y) < EPSILON && Math.abs(direction.z) < EPSILON)
            direction2.set(0f, 1f, 0f);
    } else {
        direction2.setX(0f);
        direction2.setY(direction.y * 10f);
        direction2.setZ(-direction.y * 10f / direction.z);
        ;
    }

    final Vector3f xbase;
    final Vector3f ybase = new Vector3f(direction);
    final Vector3f zbase;

    xbase = Vector3f.cross(direction2, direction, null);
    zbase = Vector3f.cross(direction, xbase, null);

    xbase.normalise();
    zbase.normalise();

    arrowRotation.m00 = xbase.x;
    arrowRotation.m10 = ybase.x;
    arrowRotation.m20 = zbase.x;

    arrowRotation.m01 = xbase.y;
    arrowRotation.m11 = ybase.y;
    arrowRotation.m21 = zbase.y;

    arrowRotation.m02 = xbase.z;
    arrowRotation.m12 = ybase.z;
    arrowRotation.m22 = zbase.z;

    arrowRotation.m33 = 1f;

    return arrowRotation;
}
 
Example 18
Source File: ArcInv.java    From ldparteditor with MIT License 4 votes vote down vote up
private Matrix4f makeRotationDir(Vector3f direction) {
    final Vector3f direction2 = new Vector3f();
    Matrix4f arrowRotation = new Matrix4f();
    direction.normalise();

    // Calculate point from hesse normal plane

    int rank = 0;
    if (Math.abs(direction.x) < EPSILON)
        rank++;
    if (Math.abs(direction.y) < EPSILON)
        rank++;
    if (Math.abs(direction.z) < EPSILON)
        rank++;

    if (rank == 1) {
        if (Math.abs(direction.x) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.y) < EPSILON)
            direction2.set(0f, 1f, 0f);
        else if (Math.abs(direction.z) < EPSILON)
            direction2.set(0f, 0f, 1f);
    } else if (rank == 2) {
        if (Math.abs(direction.x) < EPSILON && Math.abs(direction.y) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.x) < EPSILON && Math.abs(direction.z) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.y) < EPSILON && Math.abs(direction.z) < EPSILON)
            direction2.set(0f, 1f, 0f);
    } else {
        direction2.setX(0f);
        direction2.setY(direction.y * 10f);
        direction2.setZ(-direction.y * 10f / direction.z);
        ;
    }

    final Vector3f xbase;
    final Vector3f ybase = new Vector3f(direction);
    final Vector3f zbase;

    xbase = Vector3f.cross(direction2, direction, null);
    zbase = Vector3f.cross(direction, xbase, null);

    xbase.normalise();
    zbase.normalise();

    arrowRotation.m00 = xbase.x;
    arrowRotation.m10 = ybase.x;
    arrowRotation.m20 = zbase.x;

    arrowRotation.m01 = xbase.y;
    arrowRotation.m11 = ybase.y;
    arrowRotation.m21 = zbase.y;

    arrowRotation.m02 = xbase.z;
    arrowRotation.m12 = ybase.z;
    arrowRotation.m22 = zbase.z;

    arrowRotation.m33 = 1f;

    return arrowRotation;
}
 
Example 19
Source File: Arc.java    From ldparteditor with MIT License 4 votes vote down vote up
private Matrix4f makeRotationDir(Vector3f direction) {
    final Vector3f direction2 = new Vector3f();
    Matrix4f arrowRotation = new Matrix4f();
    direction.normalise();

    // Calculate point from hesse normal plane

    int rank = 0;
    if (Math.abs(direction.x) < EPSILON)
        rank++;
    if (Math.abs(direction.y) < EPSILON)
        rank++;
    if (Math.abs(direction.z) < EPSILON)
        rank++;

    if (rank == 1) {
        if (Math.abs(direction.x) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.y) < EPSILON)
            direction2.set(0f, 1f, 0f);
        else if (Math.abs(direction.z) < EPSILON)
            direction2.set(0f, 0f, 1f);
    } else if (rank == 2) {
        if (Math.abs(direction.x) < EPSILON && Math.abs(direction.y) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.x) < EPSILON && Math.abs(direction.z) < EPSILON)
            direction2.set(1f, 0f, 0f);
        else if (Math.abs(direction.y) < EPSILON && Math.abs(direction.z) < EPSILON)
            direction2.set(0f, 1f, 0f);
    } else {
        direction2.setX(0f);
        direction2.setY(direction.y * 10f);
        direction2.setZ(-direction.y * 10f / direction.z);
        ;
    }

    final Vector3f xbase;
    final Vector3f ybase = new Vector3f(direction);
    final Vector3f zbase;

    xbase = Vector3f.cross(direction2, direction, null);
    zbase = Vector3f.cross(direction, xbase, null);

    xbase.normalise();
    zbase.normalise();

    arrowRotation.m00 = xbase.x;
    arrowRotation.m10 = ybase.x;
    arrowRotation.m20 = zbase.x;

    arrowRotation.m01 = xbase.y;
    arrowRotation.m11 = ybase.y;
    arrowRotation.m21 = zbase.y;

    arrowRotation.m02 = xbase.z;
    arrowRotation.m12 = ybase.z;
    arrowRotation.m22 = zbase.z;

    arrowRotation.m33 = 1f;

    return arrowRotation;
}
 
Example 20
Source File: Trackball.java    From OpenModsLib with MIT License 3 votes vote down vote up
private static Vector3f calculateSpherePoint(float x, float y) {
	Vector3f result = new Vector3f(x, y, 0);

	float sqrZ = 1 - Vector3f.dot(result, result);

	if (sqrZ > 0) result.z = (float)Math.sqrt(sqrZ);
	else result.normalise();

	return result;
}