Package org.sunflow.math

Examples of org.sunflow.math.Point3


          float power = (float)Math.sqrt(room.getArea()) / 3;
          this.sunflow.parameter("radiance", null,
              power * (ceillingLightColor >> 16) / 0xD0 * (this.homeLightColor >> 16) / 255,
              power * ((ceillingLightColor >> 8) & 0xFF) / 0xD0 * ((this.homeLightColor >> 8) & 0xFF) / 255,
              power * (ceillingLightColor & 0xFF) / 0xD0 * (this.homeLightColor & 0xFF) / 255);
          this.sunflow.parameter("center", new Point3(xCenter, roomHeight - 25, yCenter));                   
          this.sunflow.parameter("radius", 20f);
          this.sunflow.parameter("samples", 4);
          this.sunflow.light(UUID.randomUUID().toString(), "sphere");
        }
      }
    }

    // Add visible and turned on lights
    for (HomeLight light : getLights(home.getFurniture())) {
      float lightPower = light.getPower();
      if (light.isVisible()
          && lightPower > 0f) {
        float angle = light.getAngle();
        float cos = (float)Math.cos(angle);
        float sin = (float)Math.sin(angle);
        for (LightSource lightSource : ((HomeLight)light).getLightSources()) {
          float lightRadius = lightSource.getDiameter() != null
                  ? lightSource.getDiameter() * light.getWidth() / 2
                  : 3.25f; // Default radius compatible with most lights available before version 3.0
          float power = 5 * lightPower * lightPower / (lightRadius * lightRadius);
          int lightColor = lightSource.getColor();
          this.sunflow.parameter("radiance", null,
              power * (lightColor >> 16) * (this.homeLightColor >> 16),
              power * ((lightColor >> 8) & 0xFF) * ((this.homeLightColor >> 8) & 0xFF),
              power * (lightColor & 0xFF) * (this.homeLightColor & 0xFF));
          float xLightSourceInLight = -light.getWidth() / 2 + (lightSource.getX() * light.getWidth());
          float yLightSourceInLight = light.getDepth() / 2 - (lightSource.getY() * light.getDepth());
          this.sunflow.parameter("center",
              new Point3(light.getX() + xLightSourceInLight * cos - yLightSourceInLight * sin,
                  light.getElevation() + (lightSource.getZ() * light.getHeight()),
                  light.getY() + xLightSourceInLight * sin + yLightSourceInLight * cos));                   
          this.sunflow.parameter("radius", lightRadius);
          this.sunflow.parameter("samples", 4);
          this.sunflow.light(UUID.randomUUID().toString(), "sphere");
View Full Code Here


      int sunPower = this.useAmbientOcclusion ? 40 : 10;
      this.sunflow.parameter("radiance", null,
          (this.homeLightColor >> 16) * sunPower * (float)Math.sqrt(sunColor [0]),
          ((this.homeLightColor >> 8) & 0xFF) * sunPower * (float)Math.sqrt(sunColor [1]),
          (this.homeLightColor & 0xFF) * sunPower * (float)Math.sqrt(sunColor [2]));
      this.sunflow.parameter("center", new Point3(1000000 * sunDirection [0], 1000000 * sunDirection [1], 1000000 * sunDirection [2]));
      this.sunflow.parameter("radius", 10000f)
      this.sunflow.parameter("samples", 4);
      this.sunLightName = UUID.randomUUID().toString();
      this.sunflow.light(this.sunLightName, "sphere");

      if (this.useAmbientOcclusion) {
        this.sunflow.parameter("gi.engine", "ambocc");
        this.sunflow.parameter("gi.ambocc.bright", null, new float [] {1, 1, 1});
        // Use complementary color
        this.sunflow.parameter("gi.ambocc.dark", null,
            new float [] {(sunColor [1] + sunColor [2]) / 200,
                          (sunColor [0] + sunColor [2]) / 200,
                          (sunColor [0] + sunColor [1]) / 200});
        this.sunflow.parameter("gi.ambocc.samples", 1);
        this.sunflow.options(SunflowAPI.DEFAULT_OPTIONS);
      }
    }

    // Update camera lens
    final String CAMERA_NAME = "camera";   
    switch (camera.getLens()) {
      case SPHERICAL:
        this.sunflow.camera(CAMERA_NAME, "spherical");
        break;
      case FISHEYE:
        this.sunflow.camera(CAMERA_NAME, "fisheye");
        break;
      case NORMAL:
        this.sunflow.parameter("focus.distance", 250f);
        this.sunflow.parameter("lens.radius", 1f);
        this.sunflow.camera(CAMERA_NAME, "thinlens");
        break;
      case PINHOLE:
      default:
        this.sunflow.camera(CAMERA_NAME, "pinhole");
        break;
    }
   
    // Update camera location
    Point3 eye = new Point3(camera.getX(), camera.getZ(), camera.getY());
    Matrix4 transform;
    float yaw = camera.getYaw();
    float pitch;
    if (camera.getLens() == Camera.Lens.SPHERICAL) {
      pitch = 0;
    } else {
      pitch = camera.getPitch();
    }
    double pitchCos = Math.cos(pitch);
    if (Math.abs(pitchCos) > 1E-6) {
      // Set the point the camera is pointed to
      Point3 target = new Point3(
          camera.getX() - (float)(Math.sin(yaw) * pitchCos),
          camera.getZ() - (float)Math.sin(pitch),
          camera.getY() + (float)(Math.cos(yaw) * pitchCos));
      Vector3 up = new Vector3(0, 1, 0);             
      transform = Matrix4.lookAt(eye, target, up);
View Full Code Here

TOP

Related Classes of org.sunflow.math.Point3

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.