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);
Tact Yoshida 1d7cf9
    std::vector<tspectrum::colorkey> colors = {</tspectrum::colorkey>
Shinya Kitaoka 120a6e
        TSpectrum::ColorKey(0, TPixel32::White),
Shinya Kitaoka 120a6e
        TSpectrum::ColorKey(1, TPixel32::Transparent)};
Tact Yoshida 1d7cf9
    m_colors = TSpectrumParamP(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) {
shun-iwasawa fe2893
  double scale     = sqrt(fabs(ri.m_affine.det()));
shun-iwasawa fe2893
  int type         = m_type->getValue();
shun-iwasawa fe2893
  double min       = m_min->getValue(frame);
shun-iwasawa fe2893
  double max       = m_max->getValue(frame);
shun-iwasawa fe2893
  double evolution = m_evol->getValue(frame);
shun-iwasawa fe2893
  double size      = m_size->getValue(frame) / ri.m_shrinkX;
shun-iwasawa fe2893
  size             = fabs(size);
Shinya Kitaoka 120a6e
  if (size < 0.01) size = 0.01;
shun-iwasawa fe2893
  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");