Exemplo n.º 1
0
 public Surface getSurfaceUnderVivaeObject(VivaeObject actor) {
   Vector<Surface> surfacesActorIsOn = new Vector<Surface>();
   Surface srfc = null;
   for (Surface surface : surfaces) {
     srfc = surface;
     Area actArea = actor.getArea();
     actArea.intersect(srfc.getArea());
     if (!actArea.isEmpty()) {
       surfacesActorIsOn.add(srfc);
     }
   }
   if (surfacesActorIsOn.isEmpty()) {
     return null;
   }
   srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);
   return srfc;
 }
Exemplo n.º 2
0
  /**
   * 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;
  }