Пример #1
0
  private ALight buildLight(Model l) {
    int m = l.properties.lightType != null ? l.properties.lightType : ALight.POINT_LIGHT;
    switch (m) {
      case ALight.POINT_LIGHT: // Point
        PointLight light = new PointLight();
        light.setPosition(l.properties.lclTranslation);
        light.setX(light.getX() * -1f);
        light.setRotation(l.properties.lclRotation);
        light.setPower(l.properties.intensity / 100f);
        light.setColor(l.properties.color);
        // TODO add to scene
        // mRootObject.addLight(light);
        return light;

      case ALight.DIRECTIONAL_LIGHT: // Area
        DirectionalLight lD =
            new DirectionalLight(0, -1, 0); // TODO calculate direction based on position and
        // rotation
        lD.setPosition(l.properties.lclTranslation);
        lD.setX(lD.getX() * -1f);
        lD.setRotation(l.properties.lclRotation);
        lD.setPower(l.properties.intensity / 100f);
        lD.setColor(l.properties.color);
        // TODO add to scene
        // mRootObject.addLight(lD);
        return lD;

      default:
      case ALight.SPOT_LIGHT: // Spot
        SpotLight lS = new SpotLight(); // TODO calculate direction based on position and rotation
        lS.setPosition(l.properties.lclTranslation);
        lS.setX(lS.getX() * -1f);
        lS.setRotation(l.properties.lclRotation);
        lS.setPower(l.properties.intensity / 100f);
        lS.setCutoffAngle(l.properties.coneangle);
        lS.setColor(l.properties.color);
        lS.setLookAt(0, 0, 0);
        // TODO add to scene
        // mRootObject.addLight(lS);
        return lS;
    }
  }