|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TargetSpotFx : public TStandardZeraryFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(TargetSpotFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_z;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_angle;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_decay;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_sizex;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_sizey;
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TargetSpotFx()
|
|
Shinya Kitaoka |
120a6e |
: m_z(100) // args, "Z")
|
|
Shinya Kitaoka |
120a6e |
, m_angle(10) // args, "Angle")
|
|
Shinya Kitaoka |
120a6e |
, m_decay(.01) // args, "Angle")
|
|
Shinya Kitaoka |
120a6e |
, m_sizex(1) // args, "SizeX")
|
|
Shinya Kitaoka |
120a6e |
, m_sizey(1) // args, "sizeY")
|
|
Shinya Kitaoka |
120a6e |
, m_color(TPixel::White) // args, "Color")
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "z", m_z);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "angle", m_angle);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "decay", m_decay);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "sizeX", m_sizex);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "sizeY", m_sizey);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "color", m_color);
|
|
Shinya Kitaoka |
120a6e |
m_decay->setValueRange(0.0, 1.0);
|
|
Shinya Kitaoka |
120a6e |
m_sizex->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_sizey->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_z->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_angle->setMeasureName("angle");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~TargetSpotFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
return true; // si potrebbe/dovrebbe fare meglio
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool canHandle(const TRenderSettings &info, double frame) override { return false; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename pixel=""></typename>
|
|
Shinya Kitaoka |
120a6e |
void doTargetSpot(const TRasterPT<pixel> &ras, TPixel32 m_color0, double sizex,</pixel>
|
|
Shinya Kitaoka |
120a6e |
double sizey, double angle, double decay, double z,
|
|
Shinya Kitaoka |
120a6e |
TPointD tilepos) {
|
|
Shinya Kitaoka |
120a6e |
PIXEL color1 = PIXEL::Black;
|
|
Shinya Kitaoka |
120a6e |
PIXEL color0 = PixelConverter<pixel>::from(m_color0);</pixel>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double normx = 1 / sizex;
|
|
Shinya Kitaoka |
120a6e |
double normy = 1 / sizey;
|
|
Shinya Kitaoka |
120a6e |
double reference = 5 * z;
|
|
Shinya Kitaoka |
120a6e |
angle = angle * M_PI_180;
|
|
Shinya Kitaoka |
120a6e |
double ttan;
|
|
Shinya Kitaoka |
120a6e |
ttan = tan(angle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
ras->lock();
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < ras->getLy(); j++) {
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tilepos;
|
|
Shinya Kitaoka |
120a6e |
pos.y += j;
|
|
Shinya Kitaoka |
120a6e |
PIXEL *pix = ras->pixels(j);
|
|
Shinya Kitaoka |
120a6e |
PIXEL *endPix = pix + ras->getLx();
|
|
Shinya Kitaoka |
120a6e |
while (pix < endPix) {
|
|
Shinya Kitaoka |
120a6e |
double dist, norm;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pos.x += 1.0;
|
|
Shinya Kitaoka |
120a6e |
const double ztmp(-ttan * pos.x + z);
|
|
Shinya Kitaoka |
120a6e |
const double zz(ztmp * ztmp);
|
|
Shinya Kitaoka |
120a6e |
const double distxy(pos.x * pos.x * normx + pos.y * pos.y * normy);
|
|
Shinya Kitaoka |
120a6e |
dist = distxy - zz;
|
|
Shinya Kitaoka |
120a6e |
norm = sqrt(distxy + zz);
|
|
Shinya Kitaoka |
120a6e |
if (norm < 0) norm *= -1;
|
|
Shinya Kitaoka |
120a6e |
if (dist < 0 && (-ttan * pos.x + z) > 0) {
|
|
Shinya Kitaoka |
120a6e |
*pix++ =
|
|
Shinya Kitaoka |
120a6e |
blend(color0, color1,
|
|
Shinya Kitaoka |
120a6e |
norm * decay > 1 ? 1 : (norm * decay < 0 ? 0 : norm * decay));
|
|
Shinya Kitaoka |
120a6e |
} else if (dist < reference && ztmp > 0) {
|
|
Shinya Kitaoka |
120a6e |
PIXEL tmp =
|
|
Shinya Kitaoka |
120a6e |
blend(color0, color1,
|
|
Shinya Kitaoka |
120a6e |
norm * decay > 1 ? 1 : (norm * decay < 0 ? 0 : norm * decay));
|
|
Shinya Kitaoka |
120a6e |
*pix++ = blend(tmp, color1, dist / (reference));
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
*pix++ = color1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TargetSpotFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
Shinya Kitaoka |
120a6e |
double z = m_z->getValue(frame) * ri.m_affine.a11;
|
|
Shinya Kitaoka |
120a6e |
double angle = m_angle->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
double sizex = m_sizex->getValue(frame) / (ri.m_shrinkX * ri.m_shrinkX);
|
|
Shinya Kitaoka |
120a6e |
double sizey = m_sizey->getValue(frame) / (ri.m_shrinkX * ri.m_shrinkX);
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 m_color0 = m_color->getPremultipliedValue(frame);
|
|
Shinya Kitaoka |
120a6e |
double decay = m_decay->getValue(frame) / 100;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tile.m_pos;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRaster32P raster32 = tile.getRaster();
|
|
Shinya Kitaoka |
120a6e |
if (raster32)
|
|
Shinya Kitaoka |
120a6e |
doTargetSpot<tpixel32>(raster32, m_color0, sizex, sizey, angle, decay, z,</tpixel32>
|
|
Shinya Kitaoka |
120a6e |
pos);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TRaster64P raster64 = tile.getRaster();
|
|
Shinya Kitaoka |
120a6e |
if (raster64)
|
|
Shinya Kitaoka |
120a6e |
doTargetSpot<tpixel64>(raster64, m_color0, sizex, sizey, angle, decay, z,</tpixel64>
|
|
Shinya Kitaoka |
120a6e |
pos);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
throw TException("Brightness&Contrast: unsupported Pixel Type");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(TargetSpotFx, "targetSpotFx")
|