Java Code Examples for org.lwjgl.util.vector.Vector3f#setX()
The following examples show how to use
org.lwjgl.util.vector.Vector3f#setX() .
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: 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; }
Example 2
Source File: ArcInv.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; }
Example 3
Source File: Circle.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; }
Example 4
Source File: Arrow.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; }
Example 5
Source File: ArrowBlunt.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; }