@Override
 public void read(JmeImporter im) throws IOException {
   super.read(im);
   InputCapsule ic = im.getCapsule(this);
   sampleRadius = ic.readFloat("sampleRadius", 3.0f);
   intensity = ic.readFloat("intensity", 10.2f);
   scale = ic.readFloat("scale", 3.15f);
   bias = ic.readFloat("bias", 0.025f);
   // sampleRadiusFD = ic.readFloat("sampleRadiusFD", 0.55f);
   // intensityFD = ic.readFloat("intensityFD", 2.5f);
   // scaleFD = ic.readFloat("scaleFD", 1.15f);
   // biasFD = ic.readFloat("biasFD", 0.025f);
 }
  @Override
  public void write(JmeExporter ex) throws IOException {
    super.write(ex);

    OutputCapsule oc = ex.getCapsule(this);
    oc.write(sampleRadius, "sampleRadius", 3.0f);
    oc.write(intensity, "intensity", 10.2f);
    oc.write(scale, "scale", 3.15f);
    oc.write(bias, "bias", 0.025f);
    // oc.write(sampleRadiusFD, "sampleRadiusFD", 0.55f);
    // oc.write(intensityFD, "intensityFD", 2.5f);
    // oc.write(scaleFD, "scaleFD", 1.15f);
    // oc.write(biasFD, "biasFD", 0.025f);
  }
  /**
   * The method loads library of a given ID from linked blender file.
   *
   * @param id the ID of the linked feature (it contains its name and blender path)
   * @return loaded feature or null if none was found
   * @throws BlenderFileException and exception is throw when problems with reading a blend file
   *     occur
   */
  @SuppressWarnings("unchecked")
  protected Object loadLibrary(Structure id) throws BlenderFileException {
    Pointer pLib = (Pointer) id.getFieldValue("lib");
    if (pLib.isNotNull()) {
      String fullName = id.getFieldValue("name").toString(); // we need full name with the prefix
      String nameOfFeatureToLoad = id.getName();
      Structure library = pLib.fetchData().get(0);
      String path = library.getFieldValue("filepath").toString();

      if (!blenderContext.getLinkedFeatures().keySet().contains(path)) {
        File file = new File(path);
        List<String> pathsToCheck = new ArrayList<String>();
        String currentPath = file.getName();
        do {
          pathsToCheck.add(currentPath);
          file = file.getParentFile();
          if (file != null) {
            currentPath = file.getName() + '/' + currentPath;
          }
        } while (file != null);

        Spatial loadedAsset = null;
        BlenderKey blenderKey = null;
        for (String p : pathsToCheck) {
          blenderKey = new BlenderKey(p);
          blenderKey.setLoadUnlinkedAssets(true);
          try {
            loadedAsset = blenderContext.getAssetManager().loadAsset(blenderKey);
            break; // break if no exception was thrown
          } catch (AssetNotFoundException e) {
            LOGGER.log(Level.FINEST, "Cannot locate linked resource at path: {0}.", p);
          }
        }

        if (loadedAsset != null) {
          Map<String, Map<String, Object>> linkedData = loadedAsset.getUserData("linkedData");
          for (Entry<String, Map<String, Object>> entry : linkedData.entrySet()) {
            String linkedDataFilePath = "this".equals(entry.getKey()) ? path : entry.getKey();

            List<Node> scenes = (List<Node>) entry.getValue().get("scenes");
            for (Node scene : scenes) {
              blenderContext.addLinkedFeature(linkedDataFilePath, "SC" + scene.getName(), scene);
            }
            List<Node> objects = (List<Node>) entry.getValue().get("objects");
            for (Node object : objects) {
              blenderContext.addLinkedFeature(linkedDataFilePath, "OB" + object.getName(), object);
            }
            List<TemporalMesh> meshes = (List<TemporalMesh>) entry.getValue().get("meshes");
            for (TemporalMesh mesh : meshes) {
              blenderContext.addLinkedFeature(linkedDataFilePath, "ME" + mesh.getName(), mesh);
            }
            List<MaterialContext> materials =
                (List<MaterialContext>) entry.getValue().get("materials");
            for (MaterialContext materialContext : materials) {
              blenderContext.addLinkedFeature(
                  linkedDataFilePath, "MA" + materialContext.getName(), materialContext);
            }
            List<Texture> textures = (List<Texture>) entry.getValue().get("textures");
            for (Texture texture : textures) {
              blenderContext.addLinkedFeature(
                  linkedDataFilePath, "TE" + texture.getName(), texture);
            }
            List<Texture> images = (List<Texture>) entry.getValue().get("images");
            for (Texture image : images) {
              blenderContext.addLinkedFeature(linkedDataFilePath, "IM" + image.getName(), image);
            }
            List<Animation> animations = (List<Animation>) entry.getValue().get("animations");
            for (Animation animation : animations) {
              blenderContext.addLinkedFeature(
                  linkedDataFilePath, "AC" + animation.getName(), animation);
            }
            List<Camera> cameras = (List<Camera>) entry.getValue().get("cameras");
            for (Camera camera : cameras) {
              blenderContext.addLinkedFeature(linkedDataFilePath, "CA" + camera.getName(), camera);
            }
            List<Light> lights = (List<Light>) entry.getValue().get("lights");
            for (Light light : lights) {
              blenderContext.addLinkedFeature(linkedDataFilePath, "LA" + light.getName(), light);
            }
            Spatial sky = (Spatial) entry.getValue().get("sky");
            if (sky != null) {
              blenderContext.addLinkedFeature(linkedDataFilePath, sky.getName(), sky);
            }
            List<Filter> filters = (List<Filter>) entry.getValue().get("filters");
            for (Filter filter : filters) {
              blenderContext.addLinkedFeature(linkedDataFilePath, filter.getName(), filter);
            }
          }
        } else {
          LOGGER.log(Level.WARNING, "No features loaded from path: {0}.", path);
        }
      }

      Object result = blenderContext.getLinkedFeature(path, fullName);
      if (result == null) {
        LOGGER.log(
            Level.WARNING,
            "Could NOT find asset named {0} in the library of path: {1}.",
            new Object[] {nameOfFeatureToLoad, path});
      } else {
        blenderContext.addLoadedFeatures(id.getOldMemoryAddress(), LoadedDataType.STRUCTURE, id);
        blenderContext.addLoadedFeatures(id.getOldMemoryAddress(), LoadedDataType.FEATURE, result);
      }
      return result;
    } else {
      LOGGER.warning("Library link points to nothing!");
    }
    return null;
  }