Java Code Examples for org.lwjgl.util.vector.Vector3f#length()
The following examples show how to use
org.lwjgl.util.vector.Vector3f#length() .
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: Vertex.java From OpenGL-Animation with The Unlicense | 4 votes |
public Vertex(int index,Vector3f position, VertexSkinData weightsData){ this.index = index; this.weightsData = weightsData; this.position = position; this.length = position.length(); }
Example 2
Source File: Primitive.java From ldparteditor with MIT License | 4 votes |
public void calculateZoom() { float maxX = 0f; float maxY = 0f; float maxZ = 0f; for (PGData gd : graphicalData) { gd = gd.data(); switch (gd.type()) { case 1: float[] result = calculateZoom(maxX, maxY, maxZ, (PGData1) gd); maxX = Math.max(maxX, result[0]); maxY = Math.max(maxY, result[1]); maxZ = Math.max(maxZ, result[2]); break; case 2: PGData2 gd2 = (PGData2) gd; maxX = Math.max(maxX, Math.abs(gd2.x1)); maxX = Math.max(maxX, Math.abs(gd2.x2)); maxY = Math.max(maxY, Math.abs(gd2.y1)); maxY = Math.max(maxY, Math.abs(gd2.y2)); maxZ = Math.max(maxZ, Math.abs(gd2.z1)); maxZ = Math.max(maxZ, Math.abs(gd2.z2)); break; case 3: PGData3 gd3 = (PGData3) gd; maxX = Math.max(maxX, Math.abs(gd3.x1)); maxX = Math.max(maxX, Math.abs(gd3.x2)); maxX = Math.max(maxX, Math.abs(gd3.x3)); maxY = Math.max(maxY, Math.abs(gd3.y1)); maxY = Math.max(maxY, Math.abs(gd3.y2)); maxY = Math.max(maxY, Math.abs(gd3.y3)); maxZ = Math.max(maxZ, Math.abs(gd3.z1)); maxZ = Math.max(maxZ, Math.abs(gd3.z2)); maxZ = Math.max(maxZ, Math.abs(gd3.z3)); break; case 4: PGData4 gd4 = (PGData4) gd; maxX = Math.max(maxX, Math.abs(gd4.x1)); maxX = Math.max(maxX, Math.abs(gd4.x2)); maxX = Math.max(maxX, Math.abs(gd4.x3)); maxX = Math.max(maxX, Math.abs(gd4.x4)); maxY = Math.max(maxY, Math.abs(gd4.y1)); maxY = Math.max(maxY, Math.abs(gd4.y2)); maxY = Math.max(maxY, Math.abs(gd4.y3)); maxY = Math.max(maxY, Math.abs(gd4.y4)); maxZ = Math.max(maxZ, Math.abs(gd4.z1)); maxZ = Math.max(maxZ, Math.abs(gd4.z2)); maxZ = Math.max(maxZ, Math.abs(gd4.z3)); maxZ = Math.max(maxZ, Math.abs(gd4.z4)); break; case 5: PGData5 gd5 = (PGData5) gd; maxX = Math.max(maxX, Math.abs(gd5.x1)); maxX = Math.max(maxX, Math.abs(gd5.x2)); maxY = Math.max(maxY, Math.abs(gd5.y1)); maxY = Math.max(maxY, Math.abs(gd5.y2)); maxZ = Math.max(maxZ, Math.abs(gd5.z1)); maxZ = Math.max(maxZ, Math.abs(gd5.z2)); break; default: break; } } Vector3f maxV = new Vector3f(maxX, maxY, maxZ); float length = maxV.length(); if (length > 0.0001f) zoom = 10f / length; }