/** * Returns a coefficient of the surface the VivaeObject is on or 0 if there is no surface. * * @param actor */ public float getFrictionOfSurface(VivaeObject actor) { Vector<Surface> surfacesActorIsOn = new Vector<Surface>(); Surface srfc; for (Surface surface : surfaces) { srfc = surface; Area actArea = actor.getArea(); actArea.intersect(srfc.getArea()); if (!actArea.isEmpty()) { surfacesActorIsOn.add(srfc); } } if (surfacesActorIsOn.isEmpty()) { return 0f; } srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1); return srfc.getFriction(); }
/** * Returns a coefficient of the surface the VivaeObject is on or 0 if there is no surface. * * @param actor */ public float getFrictionOfSurface(VivaeObject actor) { ArrayList<Surface> surfacesActorIsOn = new ArrayList<Surface>(); Surface srfc; Area actArea = actor.getArea(); for (Surface surface : surfaces) { srfc = surface; Area actor2intersect = (Area) actArea.clone(); actor2intersect.intersect(srfc.getArea()); if (!actor2intersect.isEmpty()) { surfacesActorIsOn.add(srfc); } } if (surfacesActorIsOn.isEmpty()) { return 0f; } srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1); float res = srfc.getFriction(); // System.out.println("Surface = " + srfc.getClass().toString() + " has friction " + // res); return res; }