/** * <code>normalizeLocal</code> makes this vector into a unit vector of * itself. * * @return this. */ public Vector2f normalizeLocal() { float length = length(); if (length != 0) { return divideLocal(length); } return divideLocal(1); }
/** * The method computes the UV coordinates of the face middle point. * @param face * the face of the mesh * @return a map whose key is the name of the UV set and value is the UV coordinate of the face's middle point */ private Map<String, Vector2f> computeFaceUVs(Face face) { Map<String, Vector2f> result = null; Map<String, List<Vector2f>> uvSets = face.getUvSets(); if (uvSets != null && uvSets.size() > 0) { result = new HashMap<String, Vector2f>(uvSets.size()); for (Entry<String, List<Vector2f>> entry : uvSets.entrySet()) { Vector2f faceUV = new Vector2f(); for (Vector2f uv : entry.getValue()) { faceUV.addLocal(uv); } faceUV.divideLocal(entry.getValue().size()); result.put(entry.getKey(), faceUV); } } return result; }
Vector2f uv2 = uvset.getValue().get(indexOfvNextIndex).add(uv1).divideLocal(2); Vector2f uv3 = faceUV.get(uvset.getKey()); Vector2f uv4 = uvset.getValue().get(indexOfvPrevIndex).add(uv1).divideLocal(2); List<Vector2f> uvList = Arrays.asList(uv1, uv2, uv3, uv4); newUVSets.put(uvset.getKey(), new ArrayList<Vector2f>(uvList));
/** * <code>normalizeLocal</code> makes this vector into a unit vector of * itself. * * @return this. */ public Vector2f normalizeLocal() { float length = length(); if (length != 0) { return divideLocal(length); } return divideLocal(1); }
/** * <code>normalizeLocal</code> makes this vector into a unit vector of * itself. * * @return this. */ public Vector2f normalizeLocal() { float length = length(); if (length != 0) { return divideLocal(length); } return divideLocal(1); }