public ArrayList<ColorRGBA> generateColors(Point3f[] points) { colorList.clear(); float distance = 3f; float calcDistance = 0; int c; for (Point3f current : points) { calcDistance = ORIGIN.distance(current); c = Color.HSBtoRGB((calcDistance % distance) / distance, 1.0f, 1.0f); if (defaultColor == null) { colorList.add(new ColorRGBA(((c >> 16) & 0xFF) / 256.0f, ((c >> 8) & 0xFF) / 256.0f, ((c >> 0) & 0xFF) / 256.0f, 1.0f)); } else { colorList.add(defaultColor); } } return colorList; }
/** * Gets the vertex nearest to the location of the (x,y) location selected, * within a distance of <tt>maxDistance</tt>. Iterates through all * visible vertices and checks their distance from the click. Override this * method to provde a more efficient implementation. * @param x * @param y * @param maxDistance temporarily overrides member maxDistance */ public V getVertex(Layout<V,E> layout, Point3f p, double maxDistance) { double minDistance = maxDistance * maxDistance; V closest = null; while(true) { try { for(V v : layout.getGraph().getVertices()) { Point3f p2 = layout.transform(v); double dist = p.distance(p2); if (dist < minDistance) { minDistance = dist; closest = v; } } break; } catch(ConcurrentModificationException cme) {} } return closest; }
distance = origin.distance(p); if (distance < nearestDistance)
public void setEndpoints(Point3f p0, Point3f p1) { float length = p0.distance(p1);
if (nearest != null) CollisionResult collRes = new CollisionResult(geom, new com.jme3.math.Vector3f(nearest.getX(), nearest.getY(), nearest.getZ()), origin.distance(nearest), 0); collRes.setContactNormal(new com.jme3.math.Vector3f(0, 0, 1)); results.addCollision(collRes);