Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "trop.h"
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Toshihiro Shimizu 890ddd
#include "perlinnoise.h"
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Toshihiro Shimizu 890ddd
#include "tspectrumparam.h"
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class CloudsFx final : public TStandardZeraryFx {
Shinya Kitaoka 120a6e
  FX_PLUGIN_DECLARATION(CloudsFx)
Shinya Kitaoka 120a6e
  TIntEnumParamP m_type;
Shinya Kitaoka 120a6e
  TDoubleParamP m_size;
Shinya Kitaoka 120a6e
  TDoubleParamP m_min;
Shinya Kitaoka 120a6e
  TDoubleParamP m_max;
Shinya Kitaoka 120a6e
  TDoubleParamP m_evol;
Shinya Kitaoka 120a6e
  TSpectrumParamP m_colors;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  CloudsFx()
Shinya Kitaoka 120a6e
      : m_type(new TIntEnumParam(PNOISE_CLOUDS, "Clouds"))
Shinya Kitaoka 120a6e
      , m_size(100.0)
Shinya Kitaoka 120a6e
      , m_min(0.0)
Shinya Kitaoka 120a6e
      , m_max(1.0)
Shinya Kitaoka 120a6e
      , m_evol(0.0) {
Shinya Kitaoka 120a6e
    bindParam(this, "type", m_type);
Shinya Kitaoka 120a6e
    m_type->addItem(PNOISE_WOODS, "Marble/Wood");
Shinya Kitaoka 120a6e
    bindParam(this, "size", m_size);
Shinya Kitaoka 120a6e
    bindParam(this, "min", m_min);
Shinya Kitaoka 120a6e
    bindParam(this, "max", m_max);
Shinya Kitaoka 120a6e
    bindParam(this, "evolution", m_evol);
Shinya Kitaoka 120a6e
    TSpectrum::ColorKey colors[] = {
Shinya Kitaoka 120a6e
        TSpectrum::ColorKey(0, TPixel32::White),
Shinya Kitaoka 120a6e
        TSpectrum::ColorKey(1, TPixel32::Transparent)};
Shinya Kitaoka 120a6e
    m_colors = TSpectrumParamP(tArrayCount(colors), colors);
Shinya Kitaoka 120a6e
    bindParam(this, "colors", m_colors);
Shinya Kitaoka 120a6e
    m_size->setValueRange(0, 200);
Shinya Kitaoka 120a6e
    m_min->setValueRange(0, 1.0);
Shinya Kitaoka 120a6e
    m_max->setValueRange(0, 1.0);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ~CloudsFx(){};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  bool doGetBBox(double, TRectD &bbox, const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    bbox = TConsts::infiniteRectD;
Shinya Kitaoka 120a6e
    return true;
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 38fd86
  bool canHandle(const TRenderSettings &info, double frame) override {
Shinya Kitaoka 38fd86
    return false;
Shinya Kitaoka 38fd86
  }
Shinya Kitaoka 120a6e
  // TAffine handledAffine(const TRenderSettings& info, double frame) {return
Shinya Kitaoka 120a6e
  // TAffine();}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CloudsFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri) {
Shinya Kitaoka 120a6e
  double scale          = sqrt(fabs(ri.m_affine.det()));
Shinya Kitaoka 120a6e
  int type              = m_type->getValue();
Shinya Kitaoka 120a6e
  double min            = m_min->getValue(frame);
Shinya Kitaoka 120a6e
  double max            = m_max->getValue(frame);
Shinya Kitaoka 120a6e
  double evolution      = m_evol->getValue(frame);
Shinya Kitaoka 120a6e
  double size           = m_size->getValue(frame) / ri.m_shrinkX;
Shinya Kitaoka 120a6e
  size                  = fabs(size);
Shinya Kitaoka 120a6e
  if (size < 0.01) size = 0.01;
Shinya Kitaoka 120a6e
  TPointD pos           = tile.m_pos;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  doClouds(tile.getRaster(), m_colors, pos, evolution, size, min, max, type,
Shinya Kitaoka 120a6e
           scale, frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(CloudsFx, "cloudsFx");