Package se.llbit.json

Examples of se.llbit.json.JsonObject


    atmosphereEnabled = desc.get("atmosphereEnabled").boolValue(false);
    volumetricFogEnabled = desc.get("volumetricFogEnabled").boolValue(false);
    waterHeight = desc.get("waterHeight").intValue(0);

    // load world info
    JsonObject world = desc.get("world").object();
    worldPath = world.get("path").stringValue("");
    worldDimension = world.get("dimension").intValue(0);

    camera.fromJson(desc.get("camera").object());
    sun.fromJson(desc.get("sun").object());
    sky.fromJson(desc.get("sky").object());
View Full Code Here


    // check version
    try {
      FileInputStream in = new FileInputStream(versionFile);
      JsonParser parser = new JsonParser(in);
      JsonObject obj = parser.parse().object();
      in.close();
      String versionName = obj.get("name").stringValue("");
      if (!versionName.equals(version)) {
        System.err.println("Stored version name does not match file name");
        return false;
      }
      JsonArray array = obj.get("libraries").array();
      for (JsonValue value: array.getElementList()) {
        VersionInfo.Library lib = new VersionInfo.Library(value.object());
        switch (lib.testIntegrity(libDir)) {
        case INCOMPLETE_INFO:
          System.err.println("Missing library name or checksum");
View Full Code Here

    postprocessCB.setSelectedIndex(renderMan.scene().getPostprocess().ordinal());
  }

  protected void updateCustomPresets() {
    customPreset.removeAllItems();
    JsonObject presets = renderMan.scene().getCameraPresets();
    for (JsonMember member : presets.getMemberList()) {
      String name = member.getName().trim();
      if (!name.isEmpty()) {
        customPreset.addItem(name);
      }
    }
View Full Code Here

    return mode;
  }

  @Override
  public JsonObject toJson() {
    JsonObject sky = new JsonObject();
    sky.add("skyYaw", rotation);
    sky.add("skyMirrored", mirrored);
    sky.add("skyLight", skyLightModifier);
    sky.add("mode", mode.name());
    sky.add("horizonOffset", horizonOffset);
    sky.add("cloudsEnabled", cloudsEnabled);
    sky.add("cloudSize", cloudSize);
    sky.add("cloudOffset", cloudOffset.toJson());

    // always save gradient
    sky.add("gradient", gradientJson(gradient));

    switch (mode) {
    case SKYMAP_PANORAMIC:
    case SKYMAP_SPHERICAL:
    {
      if (!skymap.isEmptyTexture()) {
        sky.add("skymap", skymapFileName);
      }
      break;
    }
    case SKYBOX:
    {
      JsonArray array = new JsonArray();
      for (int i = 0; i < 6; ++i) {
        if (!skybox[i].isEmptyTexture()) {
          array.add(skyboxFileName[i]);
        } else {
          array.add(new JsonNull());
        }
      }
      sky.add("skybox", array);
      break;
    }
    default:
      break;
    }
View Full Code Here

  }

  public static JsonArray gradientJson(Collection<Vector4d> gradient) {
    JsonArray array = new JsonArray();
    for (Vector4d stop: gradient) {
      JsonObject obj = new JsonObject();
      obj.add("rgb", Color.toString(stop.x, stop.y, stop.z));
      obj.add("pos", stop.w);
      array.add(obj);
    }
    return array;
  }
View Full Code Here

   * @return {@code null} if the gradient was not valid
   */
  public static List<Vector4d> gradientFromJson(JsonArray array) {
    List<Vector4d> gradient = new ArrayList<Vector4d>(array.getNumElement());
    for (int i = 0; i < array.getNumElement(); ++i) {
      JsonObject obj = array.getElement(i).object();
      Vector3d color = new Vector3d();
      try {
        Color.fromString(obj.get("rgb").stringValue(""), 16, color);
        Vector4d stop = new Vector4d(color.x, color.y, color.z, obj.get("pos").doubleValue(Double.NaN));
        if (!Double.isNaN(stop.w)) {
          gradient.add(stop);
        }
      } catch (NumberFormatException e) {
      }
View Full Code Here

    return projector.getMaxRecommendedFoV();
  }

  @Override
  public JsonObject toJson() {
    JsonObject camera = new JsonObject();

    camera.add("position", pos.toJson());

    JsonObject orientation = new JsonObject();
    orientation.add("roll", roll);
    orientation.add("pitch", pitch);
    orientation.add("yaw", yaw);
    camera.add("orientation", orientation);

    camera.add("projectionMode", projectionMode.name());
    camera.add("fov", fov);
    if (dof == Double.POSITIVE_INFINITY) {
View Full Code Here

  @Override
  public void fromJson(JsonObject obj) {
    pos.fromJson(obj.get("position").object());

    JsonObject orientation = obj.get("orientation").object();
    roll = orientation.get("roll").doubleValue(0);
    pitch = orientation.get("pitch").doubleValue(0);
    yaw = orientation.get("yaw").doubleValue(- HALF_PI);

    fov = obj.get("fov").doubleValue(0);
    subjectDistance = obj.get("focalOffset").doubleValue(0);
    try {
      projectionMode = ProjectionMode.valueOf(
View Full Code Here

  /**
   * Serialize
   * @return JSON object
   */
  public JsonObject toJson() {
    JsonObject object = new JsonObject();
    object.add("x", x);
    object.add("y", y);
    object.add("z", z);
    return object;
  }
View Full Code Here

    pp.print(json());
    out.close();
  }

  private JsonObject json() {
    JsonObject obj = new JsonObject();
    obj.add("name", name);
    obj.add("timestamp", timestamp);
    obj.add("notes", notes);
    JsonArray libraryArray = new JsonArray();
    for (Library lib: libraries) {
      libraryArray.add(lib.json());
    }
    obj.add("libraries", libraryArray);
    return obj;
  }
View Full Code Here

TOP

Related Classes of se.llbit.json.JsonObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.