Пример #1
0
  public void loadWater() {
    System.out.println("Load water");

    water = Loader.load(assetManager, map, "water", false, Water.class);
    if (water == null) {
      water = new Water();
    }
    water.init(this, terrain, null, reflectNode);
  }
Пример #2
0
  public MouseStatus getMouseCollision() {
    if (gui.isMouseOver()) {
      return null;
    }

    Vector3f origin = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);
    Vector3f direction = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);
    direction.subtractLocal(origin).normalizeLocal();

    Ray ray = new Ray(origin, direction);
    CollisionResults results = new CollisionResults();
    clickableNode.collideWith(ray, results);

    Vector3f v3f = null;
    Model m = null;

    if (results.size() > 0) {

      CollisionResult closest = results.getClosestCollision();
      Geometry g = closest.getGeometry();

      v3f = closest.getContactPoint();
      m = Model.Geometry2Model(g);

      // return new
      // MouseStatus(m,closest.getContactPoint().getX(),closest.getContactPoint().getZ());
    }

    if (water != null) {
      Vector3f waterv = water.collision(ray);
      if (waterv != null && (v3f == null || waterv.distance(origin) < v3f.distance(origin))) {
        v3f = waterv;
      }
    }

    if (v3f != null) return new MouseStatus(m, v3f.getX(), v3f.getZ());

    return null;
  }