Java Code Examples for org.lwjgl.util.vector.Vector3f#set()
The following examples show how to use
org.lwjgl.util.vector.Vector3f#set() .
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 |
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 |
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 |
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: BillboardPainter.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
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 5
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 6 votes |
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 |
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 |
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 | 5 votes |
private void a(Vector3f vector, brg blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example 9
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, bvs blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example 10
Source File: Particle.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public Particle(float angle) { Matrix4f rot_matrix = new Matrix4f(); Vector3f axis = new Vector3f(); Vector4f uv_vector = new Vector4f(); Vector4f transform_uv_vector = new Vector4f(); rot_matrix.setIdentity(); axis.set(0f, 0f, 1f); rot_matrix.rotate(angle, axis); uv_vector.set(-.5f, -.5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u1 = transform_uv_vector.getX() + .5f; v1 = transform_uv_vector.getY() + .5f; uv_vector.set(.5f, -.5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u2 = transform_uv_vector.getX() + .5f; v2 = transform_uv_vector.getY() + .5f; uv_vector.set(.5f, .5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u3 = transform_uv_vector.getX() + .5f; v3 = transform_uv_vector.getY() + .5f; uv_vector.set(-.5f, .5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u4 = transform_uv_vector.getX() + .5f; v4 = transform_uv_vector.getY() + .5f; }
Example 11
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, bgj var1) { if (var1 != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (var1.b) { case a: Matrix4f.rotate(var1.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(var1.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(var1.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (var1.d) { if (Math.abs(var1.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(var1.a), var2, var3); } }
Example 12
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example 13
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example 14
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, boi blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example 15
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, bpb blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example 16
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example 17
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example 18
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example 19
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, bpb blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example 20
Source File: Arc.java From ldparteditor with MIT License | 4 votes |
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; }