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