|
Toshihiro Shimizu |
890ddd |
/*-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
Iwa_TileFx based on TileFx by Digital Video
|
|
Toshihiro Shimizu |
890ddd |
カメラ枠を基準にマージンを加えて敷き詰めることができ、繰り返しの有無も指定できる
|
|
Toshihiro Shimizu |
890ddd |
-------------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttzpimagefx.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "timage_io.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class Iwa_TileFx : public TStandardRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_DECLARATION(Iwa_TileFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum tileQuantity {
|
|
Toshihiro Shimizu |
890ddd |
eNoTile = 1,
|
|
Toshihiro Shimizu |
890ddd |
eOneTile = 2,
|
|
Toshihiro Shimizu |
890ddd |
eMultipleTiles = 3
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum inputSize {
|
|
Toshihiro Shimizu |
890ddd |
eBoundingBox = 1,
|
|
Toshihiro Shimizu |
890ddd |
eCameraBox = 2
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_inputSizeMode;
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_input;
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_leftQuantity;
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_rightQuantity;
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_topQuantity;
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_bottomQuantity;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_xMirror;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_yMirror;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_hmargin;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_vmargin;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Iwa_TileFx();
|
|
Toshihiro Shimizu |
890ddd |
~Iwa_TileFx();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info);
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &info, double frame);
|
|
Toshihiro Shimizu |
890ddd |
TRect getInvalidRect(const TRect &max) { return max; }
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri);
|
|
Toshihiro Shimizu |
890ddd |
int getMemoryRequirement(const TRectD &rect, double frame, const TRenderSettings &info);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void transform(
|
|
Toshihiro Shimizu |
890ddd |
double frame,
|
|
Toshihiro Shimizu |
890ddd |
int port,
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &rectOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &infoOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
TRectD &rectOnInput,
|
|
Toshihiro Shimizu |
890ddd |
TRenderSettings &infoOnInput);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool checkIfThisTileShouldBeComptedOrNot(int horizIndex, int vertIndex);
|
|
Toshihiro Shimizu |
890ddd |
bool isInRange(int quantityMode, int index);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
void makeTile(const TTile &inputTile, const TTile &tile);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Iwa_TileFx::Iwa_TileFx()
|
|
Toshihiro Shimizu |
890ddd |
: m_inputSizeMode(new TIntEnumParam(eBoundingBox, "Bounding Box")), m_leftQuantity(new TIntEnumParam(eNoTile, "No Tile")), m_rightQuantity(new TIntEnumParam(eNoTile, "No Tile")), m_topQuantity(new TIntEnumParam(eNoTile, "No Tile")), m_bottomQuantity(new TIntEnumParam(eNoTile, "No Tile")), m_xMirror(false), m_yMirror(false), m_hmargin(5.24934) /*- スタンダードサイズのカメラとLevelのマージン(2.5mm)-*/
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_vmargin(12.4934) /*- 5.95mm -*/
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Source", m_input);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "inputSize", m_inputSizeMode);
|
|
Toshihiro Shimizu |
890ddd |
m_inputSizeMode->addItem(eCameraBox, "Camera Box");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "leftQuantity", m_leftQuantity);
|
|
Toshihiro Shimizu |
890ddd |
m_leftQuantity->addItem(eOneTile, "1 Tile");
|
|
Toshihiro Shimizu |
890ddd |
m_leftQuantity->addItem(eMultipleTiles, "Mutiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "rightQuantity", m_rightQuantity);
|
|
Toshihiro Shimizu |
890ddd |
m_rightQuantity->addItem(eOneTile, "1 Tile");
|
|
Toshihiro Shimizu |
890ddd |
m_rightQuantity->addItem(eMultipleTiles, "Mutiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "xMirror", m_xMirror);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "hMargin", m_hmargin);
|
|
Toshihiro Shimizu |
890ddd |
m_hmargin->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "topQuantity", m_topQuantity);
|
|
Toshihiro Shimizu |
890ddd |
m_topQuantity->addItem(eOneTile, "1 Tile");
|
|
Toshihiro Shimizu |
890ddd |
m_topQuantity->addItem(eMultipleTiles, "Mutiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "bottomQuantity", m_bottomQuantity);
|
|
Toshihiro Shimizu |
890ddd |
m_bottomQuantity->addItem(eOneTile, "1 Tile");
|
|
Toshihiro Shimizu |
890ddd |
m_bottomQuantity->addItem(eMultipleTiles, "Mutiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "yMirror", m_yMirror);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "vMargin", m_vmargin);
|
|
Toshihiro Shimizu |
890ddd |
m_vmargin->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Iwa_TileFx::~Iwa_TileFx() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool Iwa_TileFx::canHandle(const TRenderSettings &info, double frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//Currently, only affines which transform the X and Y axis into themselves may
|
|
Toshihiro Shimizu |
890ddd |
//be handled by this fx...
|
|
Toshihiro Shimizu |
890ddd |
return (fabs(info.m_affine.a12) < 0.0001 &&
|
|
Toshihiro Shimizu |
890ddd |
fabs(info.m_affine.a21) < 0.0001) ||
|
|
Toshihiro Shimizu |
890ddd |
(fabs(info.m_affine.a11) < 0.0001 &&
|
|
Toshihiro Shimizu |
890ddd |
fabs(info.m_affine.a22) < 0.0001);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool Iwa_TileFx::doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_input.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = TConsts::infiniteRectD;
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
bBox = TRectD();
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void Iwa_TileFx::transform(
|
|
Toshihiro Shimizu |
890ddd |
double frame,
|
|
Toshihiro Shimizu |
890ddd |
int port,
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &rectOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &infoOnOutput,
|
|
Toshihiro Shimizu |
890ddd |
TRectD &rectOnInput,
|
|
Toshihiro Shimizu |
890ddd |
TRenderSettings &infoOnInput)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
infoOnInput = infoOnOutput;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD inputBox;
|
|
Toshihiro Shimizu |
890ddd |
m_input->getBBox(frame, inputBox, infoOnOutput);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(infoOnOutput.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
int hmargin = m_hmargin->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
int vmargin = m_vmargin->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
inputBox = inputBox.enlarge(hmargin, vmargin);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (inputBox.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
rectOnInput.empty();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (inputBox == TConsts::infiniteRectD) {
|
|
Toshihiro Shimizu |
890ddd |
infoOnInput = infoOnOutput;
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDimensionD size(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
size.lx = tceil(inputBox.getLx());
|
|
Toshihiro Shimizu |
890ddd |
size.ly = tceil(inputBox.getLy());
|
|
Toshihiro Shimizu |
890ddd |
rectOnInput = TRectD(inputBox.getP00(), size);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int Iwa_TileFx::getMemoryRequirement(const TRectD &rect, double frame, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD inputBox;
|
|
Toshihiro Shimizu |
890ddd |
m_input->getBBox(frame, inputBox, info);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(info.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
int hmargin = m_hmargin->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
int vmargin = m_vmargin->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
inputBox = inputBox.enlarge(hmargin, vmargin);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TRasterFx::memorySize(inputBox, info.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void Iwa_TileFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_input.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TRectD inputBox;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int inputSizeMode = m_inputSizeMode->getValue(); // eBoundingBox = 1, eCameraBox = 2
|
|
Toshihiro Shimizu |
890ddd |
if (inputSizeMode == eBoundingBox)
|
|
Toshihiro Shimizu |
890ddd |
m_input->getBBox(frame, inputBox, ri);
|
|
Toshihiro Shimizu |
890ddd |
else if (inputSizeMode == eCameraBox) {
|
|
Toshihiro Shimizu |
890ddd |
TPointD offset = tile.m_pos + tile.getRaster()->getCenterD();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inputBox = TRectD(TPointD(ri.m_cameraBox.x0 + offset.x, ri.m_cameraBox.y0 + offset.y),
|
|
Toshihiro Shimizu |
890ddd |
TDimensionD(ri.m_cameraBox.getLx(), ri.m_cameraBox.getLy()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(ri.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
int hmargin = m_hmargin->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
int vmargin = m_vmargin->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
inputBox = inputBox.enlarge(hmargin, vmargin);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (inputBox.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (inputBox == TConsts::infiniteRectD) {
|
|
Toshihiro Shimizu |
890ddd |
m_input->compute(tile, frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDimension size(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
size.lx = tceil(inputBox.getLx());
|
|
Toshihiro Shimizu |
890ddd |
size.ly = tceil(inputBox.getLy());
|
|
Toshihiro Shimizu |
890ddd |
TTile inputTile;
|
|
Toshihiro Shimizu |
890ddd |
m_input->allocateAndCompute(inputTile, inputBox.getP00(), size, tile.getRaster(), frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
makeTile(inputTile, tile);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool Iwa_TileFx::isInRange(int quantityMode, int index)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
switch (quantityMode) {
|
|
Toshihiro Shimizu |
890ddd |
case eNoTile:
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case eOneTile:
|
|
Toshihiro Shimizu |
890ddd |
return (abs(index) < 2);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case eMultipleTiles:
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
default:
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool Iwa_TileFx::checkIfThisTileShouldBeComptedOrNot(int horizIndex, int vertIndex)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int leftQuantity = m_leftQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
int rightQuantity = m_rightQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
int topQuantity = m_topQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
int bottomQuantity = m_bottomQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool horizInRange, vertInRange;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (horizIndex == 0)
|
|
Toshihiro Shimizu |
890ddd |
horizInRange = true;
|
|
Toshihiro Shimizu |
890ddd |
else if (horizIndex < 0)
|
|
Toshihiro Shimizu |
890ddd |
horizInRange = isInRange(leftQuantity, horizIndex);
|
|
Toshihiro Shimizu |
890ddd |
else //horizIndex > 0
|
|
Toshihiro Shimizu |
890ddd |
horizInRange = isInRange(rightQuantity, horizIndex);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (vertIndex == 0)
|
|
Toshihiro Shimizu |
890ddd |
vertInRange = true;
|
|
Toshihiro Shimizu |
890ddd |
else if (vertIndex < 0)
|
|
Toshihiro Shimizu |
890ddd |
vertInRange = isInRange(bottomQuantity, vertIndex);
|
|
Toshihiro Shimizu |
890ddd |
else //horizIndex > 0
|
|
Toshihiro Shimizu |
890ddd |
vertInRange = isInRange(topQuantity, vertIndex);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return horizInRange & vertInRange;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//! Make the tile of the image contained in \b inputTile in \b tile
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Iwa_TileFx::makeTile(const TTile &inputTile, const TTile &tile)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Build the mirroring pattern. It obviously repeats itself out of 2x2 tile blocks.
|
|
Toshihiro Shimizu |
890ddd |
map<pair<bool, bool="">, TRasterP> mirrorRaster;</pair<bool,>
|
|
Toshihiro Shimizu |
890ddd |
mirrorRaster[pair<bool, bool="">(false, false)] = inputTile.getRaster();</bool,>
|
|
Toshihiro Shimizu |
890ddd |
mirrorRaster[pair<bool, bool="">(false, true)] = inputTile.getRaster()->clone();</bool,>
|
|
Toshihiro Shimizu |
890ddd |
mirrorRaster[pair<bool, bool="">(false, true)]->yMirror();</bool,>
|
|
Toshihiro Shimizu |
890ddd |
mirrorRaster[pair<bool, bool="">(true, false)] = inputTile.getRaster()->clone();</bool,>
|
|
Toshihiro Shimizu |
890ddd |
mirrorRaster[pair<bool, bool="">(true, false)]->xMirror();</bool,>
|
|
Toshihiro Shimizu |
890ddd |
mirrorRaster[pair<bool, bool="">(true, true)] = mirrorRaster[pair<bool, bool="">(true, false)]->clone();</bool,></bool,>
|
|
Toshihiro Shimizu |
890ddd |
mirrorRaster[pair<bool, bool="">(true, true)]->yMirror();</bool,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint animatedPos = convert(inputTile.m_pos - tile.m_pos);
|
|
Toshihiro Shimizu |
890ddd |
TDimension inSize = inputTile.getRaster()->getSize();
|
|
Toshihiro Shimizu |
890ddd |
TDimension outSize = tile.getRaster()->getSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool mirrorX = false, mirrorY = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int leftQuantity = m_leftQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
int rightQuantity = m_rightQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
int topQuantity = m_topQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
int bottomQuantity = m_bottomQuantity->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool tileHorizontally = leftQuantity != eNoTile || rightQuantity != eNoTile;
|
|
Toshihiro Shimizu |
890ddd |
bool tileVertically = topQuantity != eNoTile || bottomQuantity != eNoTile;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*- 現在のタイルのインデックス -*/
|
|
Toshihiro Shimizu |
890ddd |
int horizIndex = 0;
|
|
Toshihiro Shimizu |
890ddd |
int vertIndex = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*- 左下のタイルのインデックスを計算 -*/
|
|
Toshihiro Shimizu |
890ddd |
//Reach the lower left tiling position
|
|
Toshihiro Shimizu |
890ddd |
while (animatedPos.x > 0 && tileHorizontally) {
|
|
Toshihiro Shimizu |
890ddd |
animatedPos.x -= inSize.lx;
|
|
Toshihiro Shimizu |
890ddd |
mirrorX = !mirrorX;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
horizIndex--;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
while (animatedPos.x + inSize.lx < 0 && tileHorizontally) {
|
|
Toshihiro Shimizu |
890ddd |
animatedPos.x += inSize.lx;
|
|
Toshihiro Shimizu |
890ddd |
mirrorX = !mirrorX;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
horizIndex++;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
while (animatedPos.y > 0 && tileVertically) {
|
|
Toshihiro Shimizu |
890ddd |
animatedPos.y -= inSize.ly;
|
|
Toshihiro Shimizu |
890ddd |
mirrorY = !mirrorY;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
vertIndex--;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
while (animatedPos.y + inSize.ly < 0 && tileVertically) {
|
|
Toshihiro Shimizu |
890ddd |
animatedPos.y += inSize.ly;
|
|
Toshihiro Shimizu |
890ddd |
mirrorY = !mirrorY;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
vertIndex++;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool doMirroX = mirrorX, doMirroY = mirrorY;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Write the tiling blocks.
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->lock();
|
|
Toshihiro Shimizu |
890ddd |
inputTile.getRaster()->lock();
|
|
Toshihiro Shimizu |
890ddd |
TPoint startTilingPos = animatedPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int horizStartIndex = horizIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
do {
|
|
Toshihiro Shimizu |
890ddd |
do {
|
|
Toshihiro Shimizu |
890ddd |
if (checkIfThisTileShouldBeComptedOrNot(horizIndex, vertIndex)) {
|
|
Toshihiro Shimizu |
890ddd |
pair<bool, bool=""> doMirror(doMirroX && m_xMirror->getValue(), doMirroY && m_yMirror->getValue());</bool,>
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->copy(mirrorRaster[doMirror], startTilingPos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
startTilingPos.x += inSize.lx;
|
|
Toshihiro Shimizu |
890ddd |
doMirroX = !doMirroX;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
horizIndex++;
|
|
Toshihiro Shimizu |
890ddd |
} while (startTilingPos.x < outSize.lx && tileHorizontally);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
startTilingPos.y += inSize.ly;
|
|
Toshihiro Shimizu |
890ddd |
startTilingPos.x = animatedPos.x;
|
|
Toshihiro Shimizu |
890ddd |
doMirroY = !doMirroY;
|
|
Toshihiro Shimizu |
890ddd |
doMirroX = mirrorX;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
horizIndex = horizStartIndex;
|
|
Toshihiro Shimizu |
890ddd |
vertIndex++;
|
|
Toshihiro Shimizu |
890ddd |
} while (startTilingPos.y < outSize.ly && tileVertically);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inputTile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(Iwa_TileFx, "iwa_TileFx");
|