Re: Sweet Home 3D 5.1

by enkonyito » Mon Sep 07, 2015 5:10 am

Hi Emmanuel,

What do you think of these changes about the ceiling light for a future release?

Room.java

Code: Select all

/**
   * Returns the abscissa of the center point of this room.
   */
  public float getXCenter() { // modifié (enkonyito)
    float [][] pointsXY = this.getPoints();
    // X : pointsXY[ligne][0]
    // Y : pointsXY[ligne][1]
    Room clonePièce = this.clone();
    clonePièce.addPoint(pointsXY[0][0], pointsXY[0][1]); // ajoute un point final identique au point initial
    pointsXY = clonePièce.getPoints();
    float sommeAire = 0;
    float sommeXCenter = 0;
    for (int i=0; i<=pointsXY.length-2; i++) {
            float polynome = (float) ((pointsXY[i][0]*pointsXY[i+1][1])-(pointsXY[i+1][0]*pointsXY[i][1]));
            sommeAire += polynome;
            sommeXCenter += (pointsXY[i][0] + pointsXY[i+1][0]) * polynome;
    }
    float aire = (sommeAire / 2); // valeur en cm²
    float XCenter = (sommeXCenter / (6*aire)); // valeur en cm
    return XCenter;
  }
Similar for getYCenter() method.

PhotoRenderer.java

Code: Select all

// surperficie de la pièce en m² : room.getArea()/10000
          float power = (float)Math.sqrt((room.getArea()/10000)); // modifié (enkonyito)
          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 -50, yCenter)); // modifié (enkonyito)
          this.sunflow.parameter("radius", 25f); // modifié (enkonyito)
          this.sunflow.parameter("samples", 4);
          this.sunflow.light(UUID.randomUUID().toString(), "sphere");