Java Code Examples for org.joml.Vector3f#set()
The following examples show how to use
org.joml.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: ShadowCascade.java From lwjglbook with Apache License 2.0 | 5 votes |
public void update(Window window, Matrix4f viewMatrix, DirectionalLight light) { // Build projection view matrix for this cascade float aspectRatio = (float) window.getWidth() / (float) window.getHeight(); projViewMatrix.setPerspective(Window.FOV, aspectRatio, zNear, zFar); projViewMatrix.mul(viewMatrix); // Calculate frustum corners in world space float maxZ = Float.MIN_VALUE; float minZ = Float.MAX_VALUE; for (int i = 0; i < FRUSTUM_CORNERS; i++) { Vector3f corner = frustumCorners[i]; corner.set(0, 0, 0); projViewMatrix.frustumCorner(i, corner); centroid.add(corner); centroid.div(8.0f); minZ = Math.min(minZ, corner.z); maxZ = Math.max(maxZ, corner.z); } // Go back from the centroid up to max.z - min.z in the direction of light Vector3f lightDirection = light.getDirection(); Vector3f lightPosInc = new Vector3f().set(lightDirection); float distance = maxZ - minZ; lightPosInc.mul(distance); Vector3f lightPosition = new Vector3f(); lightPosition.set(centroid); lightPosition.add(lightPosInc); updateLightViewMatrix(lightDirection, lightPosition); updateLightProjectionMatrix(); }
Example 2
Source File: ShadowCascade.java From lwjglbook with Apache License 2.0 | 5 votes |
public void update(Window window, Matrix4f viewMatrix, DirectionalLight light) { // Build projection view matrix for this cascade float aspectRatio = (float) window.getWidth() / (float) window.getHeight(); projViewMatrix.setPerspective(Window.FOV, aspectRatio, zNear, zFar); projViewMatrix.mul(viewMatrix); // Calculate frustum corners in world space float maxZ = Float.MIN_VALUE; float minZ = Float.MAX_VALUE; for (int i = 0; i < FRUSTUM_CORNERS; i++) { Vector3f corner = frustumCorners[i]; corner.set(0, 0, 0); projViewMatrix.frustumCorner(i, corner); centroid.add(corner); centroid.div(8.0f); minZ = Math.min(minZ, corner.z); maxZ = Math.max(maxZ, corner.z); } // Go back from the centroid up to max.z - min.z in the direction of light Vector3f lightDirection = light.getDirection(); Vector3f lightPosInc = new Vector3f().set(lightDirection); float distance = maxZ - minZ; lightPosInc.mul(distance); Vector3f lightPosition = new Vector3f(); lightPosition.set(centroid); lightPosition.add(lightPosInc); updateLightViewMatrix(lightDirection, lightPosition); updateLightProjectionMatrix(); }
Example 3
Source File: ShadowCascade.java From lwjglbook with Apache License 2.0 | 5 votes |
public void update(Window window, Matrix4f viewMatrix, DirectionalLight light) { // Build projection view matrix for this cascade float aspectRatio = (float) window.getWidth() / (float) window.getHeight(); projViewMatrix.setPerspective(Window.FOV, aspectRatio, zNear, zFar); projViewMatrix.mul(viewMatrix); // Calculate frustum corners in world space float maxZ = Float.MIN_VALUE; float minZ = Float.MAX_VALUE; for (int i = 0; i < FRUSTUM_CORNERS; i++) { Vector3f corner = frustumCorners[i]; corner.set(0, 0, 0); projViewMatrix.frustumCorner(i, corner); centroid.add(corner); centroid.div(8.0f); minZ = Math.min(minZ, corner.z); maxZ = Math.max(maxZ, corner.z); } // Go back from the centroid up to max.z - min.z in the direction of light Vector3f lightDirection = light.getDirection(); Vector3f lightPosInc = new Vector3f().set(lightDirection); float distance = maxZ - minZ; lightPosInc.mul(distance); Vector3f lightPosition = new Vector3f(); lightPosition.set(centroid); lightPosition.add(lightPosInc); updateLightViewMatrix(lightDirection, lightPosition); updateLightProjectionMatrix(); }
Example 4
Source File: ShadowCascade.java From lwjglbook with Apache License 2.0 | 5 votes |
public void update(Window window, Matrix4f viewMatrix, DirectionalLight light) { // Build projection view matrix for this cascade float aspectRatio = (float) window.getWidth() / (float) window.getHeight(); projViewMatrix.setPerspective(Window.FOV, aspectRatio, zNear, zFar); projViewMatrix.mul(viewMatrix); // Calculate frustum corners in world space float maxZ = Float.MIN_VALUE; float minZ = Float.MAX_VALUE; for (int i = 0; i < FRUSTUM_CORNERS; i++) { Vector3f corner = frustumCorners[i]; corner.set(0, 0, 0); projViewMatrix.frustumCorner(i, corner); centroid.add(corner); centroid.div(8.0f); minZ = Math.min(minZ, corner.z); maxZ = Math.max(maxZ, corner.z); } // Go back from the centroid up to max.z - min.z in the direction of light Vector3f lightDirection = light.getDirection(); Vector3f lightPosInc = new Vector3f().set(lightDirection); float distance = maxZ - minZ; lightPosInc.mul(distance); Vector3f lightPosition = new Vector3f(); lightPosition.set(centroid); lightPosition.add(lightPosInc); updateLightViewMatrix(lightDirection, lightPosition); updateLightProjectionMatrix(); }
Example 5
Source File: Rotate3f.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void compute(final Vector3f v, final Quaternionfc q, final Vector3f vDot) { vDot.set(v); vDot.rotate(q); }