public Vector3f[] getNormals() { final Vector3f[] normals = new Vector3f[nVertices]; for (int i = 0; i < nVertices; i++) normals[i] = new Vector3f(); final Vector3f v1 = new Vector3f(), v2 = new Vector3f(); for (int i = 0; i < nFaces; i += 3) { final int f1 = faces[i]; final int f2 = faces[i + 1]; final int f3 = faces[i + 2]; v1.sub(vertices[f2], vertices[f1]); v2.sub(vertices[f3], vertices[f1]); v1.cross(v1, v2); normals[f1].add(v1); normals[f2].add(v1); normals[f3].add(v1); } for (int i = 0; i < nVertices; i++) normals[i].normalize(); return normals; }
if (f == fnsize) { normals[n].add(facetNorms[triangle]); fn[fnsize++] = facetNorms[triangle]; } else if ((DEBUG & 128) != 0) {
public void getVertexNormal(final Vertex v, final Vector3f ret) { ret.set(0, 0, 0); final Vector3f tn = new Vector3f(); for (final int fIdx : v.triangles) { getFaceNormal(fIdx, tn); ret.add(tn); } ret.normalize(); }
public static void decompose(final Matrix4f mat, final Vector3f origin, final AxisAngle4f rotation, final Vector3f translation) { final Matrix3f rot = new Matrix3f(); mat.get(rot); rotation.set(rot); final Point3f tmp = new Point3f(origin); rot.transform(tmp); tmp.sub(origin); mat.get(translation); translation.add(tmp); }
Vector3f newCameraLocation=boxsCentre.add(perpendicularFromTheAction.mult(distance));