|
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 |
|
|
Shinya Kitaoka |
d1f6c4 |
class Iwa_TileFx final : public TStandardRasterFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(Iwa_TileFx)
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
enum tileQuantity { eNoTile = 1, eOneTile = 2, eMultipleTiles = 3 };
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
78a7b2 |
enum inputSize { eBoundingBox = 1, eCameraBox = 2, eImageSize = 3 };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TIntEnumParamP m_inputSizeMode;
|
|
Shinya Kitaoka |
120a6e |
TRasterFxPort m_input;
|
|
Shinya Kitaoka |
120a6e |
TIntEnumParamP m_leftQuantity;
|
|
Shinya Kitaoka |
120a6e |
TIntEnumParamP m_rightQuantity;
|
|
Shinya Kitaoka |
120a6e |
TIntEnumParamP m_topQuantity;
|
|
Shinya Kitaoka |
120a6e |
TIntEnumParamP m_bottomQuantity;
|
|
Shinya Kitaoka |
120a6e |
TBoolParamP m_xMirror;
|
|
Shinya Kitaoka |
120a6e |
TBoolParamP m_yMirror;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_hmargin;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_vmargin;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
Iwa_TileFx();
|
|
Shinya Kitaoka |
120a6e |
~Iwa_TileFx();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
bool doGetBBox(double frame, TRectD &bBox,
|
|
Shinya Kitaoka |
38fd86 |
const TRenderSettings &info) override;
|
|
Shinya Kitaoka |
473e70 |
bool canHandle(const TRenderSettings &info, double frame) override;
|
|
Shinya Kitaoka |
120a6e |
TRect getInvalidRect(const TRect &max) { return max; }
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
120a6e |
int getMemoryRequirement(const TRectD &rect, double frame,
|
|
Shinya Kitaoka |
473e70 |
const TRenderSettings &info) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void transform(double frame, int port, const TRectD &rectOnOutput,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &infoOnOutput, TRectD &rectOnInput,
|
|
Shinya Kitaoka |
473e70 |
TRenderSettings &infoOnInput) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool checkIfThisTileShouldBeComptedOrNot(int horizIndex, int vertIndex);
|
|
Shinya Kitaoka |
120a6e |
bool isInRange(int quantityMode, int index);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
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()
|
|
Shinya Kitaoka |
120a6e |
: m_inputSizeMode(new TIntEnumParam(eBoundingBox, "Bounding Box"))
|
|
Shinya Kitaoka |
120a6e |
, m_leftQuantity(new TIntEnumParam(eNoTile, "No Tile"))
|
|
Shinya Kitaoka |
120a6e |
, m_rightQuantity(new TIntEnumParam(eNoTile, "No Tile"))
|
|
Shinya Kitaoka |
120a6e |
, m_topQuantity(new TIntEnumParam(eNoTile, "No Tile"))
|
|
Shinya Kitaoka |
120a6e |
, m_bottomQuantity(new TIntEnumParam(eNoTile, "No Tile"))
|
|
Shinya Kitaoka |
120a6e |
, m_xMirror(false)
|
|
Shinya Kitaoka |
120a6e |
, m_yMirror(false)
|
|
Shinya Kitaoka |
120a6e |
, m_hmargin(
|
|
Shinya Kitaoka |
120a6e |
5.24934) /*- スタンダードサイズのカメラとLevelのマージン(2.5mm)-*/
|
|
Shinya Kitaoka |
120a6e |
, m_vmargin(12.4934) /*- 5.95mm -*/
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
addInputPort("Source", m_input);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "inputSize", m_inputSizeMode);
|
|
Shinya Kitaoka |
120a6e |
m_inputSizeMode->addItem(eCameraBox, "Camera Box");
|
|
shun-iwasawa |
78a7b2 |
m_inputSizeMode->addItem(eImageSize, "Image Size");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "leftQuantity", m_leftQuantity);
|
|
Shinya Kitaoka |
120a6e |
m_leftQuantity->addItem(eOneTile, "1 Tile");
|
|
luz paz |
6454c4 |
m_leftQuantity->addItem(eMultipleTiles, "Multiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "rightQuantity", m_rightQuantity);
|
|
Shinya Kitaoka |
120a6e |
m_rightQuantity->addItem(eOneTile, "1 Tile");
|
|
luz paz |
6454c4 |
m_rightQuantity->addItem(eMultipleTiles, "Multiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "xMirror", m_xMirror);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "hMargin", m_hmargin);
|
|
Shinya Kitaoka |
120a6e |
m_hmargin->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "topQuantity", m_topQuantity);
|
|
Shinya Kitaoka |
120a6e |
m_topQuantity->addItem(eOneTile, "1 Tile");
|
|
luz paz |
6454c4 |
m_topQuantity->addItem(eMultipleTiles, "Multiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "bottomQuantity", m_bottomQuantity);
|
|
Shinya Kitaoka |
120a6e |
m_bottomQuantity->addItem(eOneTile, "1 Tile");
|
|
luz paz |
6454c4 |
m_bottomQuantity->addItem(eMultipleTiles, "Multiple Tiles");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "yMirror", m_yMirror);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "vMargin", m_vmargin);
|
|
Shinya Kitaoka |
120a6e |
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 |
|
|
Shinya Kitaoka |
120a6e |
bool Iwa_TileFx::canHandle(const TRenderSettings &info, double frame) {
|
|
Shinya Kitaoka |
120a6e |
// Currently, only affines which transform the X and Y axis into themselves
|
|
Shinya Kitaoka |
120a6e |
// may
|
|
Shinya Kitaoka |
120a6e |
// be handled by this fx...
|
|
Shinya Kitaoka |
120a6e |
return (fabs(info.m_affine.a12) < 0.0001 &&
|
|
Shinya Kitaoka |
120a6e |
fabs(info.m_affine.a21) < 0.0001) ||
|
|
Shinya Kitaoka |
120a6e |
(fabs(info.m_affine.a11) < 0.0001 && fabs(info.m_affine.a22) < 0.0001);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool Iwa_TileFx::doGetBBox(double frame, TRectD &bBox,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &info) {
|
|
Shinya Kitaoka |
120a6e |
if (m_input.isConnected()) {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
bBox = TRectD();
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void Iwa_TileFx::transform(double frame, int port, const TRectD &rectOnOutput,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &infoOnOutput,
|
|
Shinya Kitaoka |
120a6e |
TRectD &rectOnInput, TRenderSettings &infoOnInput) {
|
|
Shinya Kitaoka |
120a6e |
infoOnInput = infoOnOutput;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
e526d5 |
if (!m_input.isConnected()) {
|
|
shun-iwasawa |
e526d5 |
rectOnInput.empty();
|
|
shun-iwasawa |
e526d5 |
return;
|
|
shun-iwasawa |
e526d5 |
}
|
|
shun-iwasawa |
e526d5 |
|
|
Shinya Kitaoka |
120a6e |
TRectD inputBox;
|
|
Shinya Kitaoka |
120a6e |
m_input->getBBox(frame, inputBox, infoOnOutput);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double scale = sqrt(fabs(infoOnOutput.m_affine.det()));
|
|
Shinya Kitaoka |
120a6e |
int hmargin = m_hmargin->getValue(frame) * scale;
|
|
Shinya Kitaoka |
120a6e |
int vmargin = m_vmargin->getValue(frame) * scale;
|
|
Shinya Kitaoka |
120a6e |
inputBox = inputBox.enlarge(hmargin, vmargin);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (inputBox.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
rectOnInput.empty();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (inputBox == TConsts::infiniteRectD) {
|
|
Shinya Kitaoka |
120a6e |
infoOnInput = infoOnOutput;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDimensionD size(0, 0);
|
|
Shinya Kitaoka |
120a6e |
size.lx = tceil(inputBox.getLx());
|
|
Shinya Kitaoka |
120a6e |
size.ly = tceil(inputBox.getLy());
|
|
Shinya Kitaoka |
120a6e |
rectOnInput = TRectD(inputBox.getP00(), size);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int Iwa_TileFx::getMemoryRequirement(const TRectD &rect, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &info) {
|
|
shun-iwasawa |
e526d5 |
if (!m_input.isConnected()) return 0;
|
|
shun-iwasawa |
e526d5 |
|
|
Shinya Kitaoka |
120a6e |
TRectD inputBox;
|
|
Shinya Kitaoka |
120a6e |
m_input->getBBox(frame, inputBox, info);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double scale = sqrt(fabs(info.m_affine.det()));
|
|
Shinya Kitaoka |
120a6e |
int hmargin = m_hmargin->getValue(frame) * scale;
|
|
Shinya Kitaoka |
120a6e |
int vmargin = m_vmargin->getValue(frame) * scale;
|
|
Shinya Kitaoka |
120a6e |
inputBox = inputBox.enlarge(hmargin, vmargin);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return TRasterFx::memorySize(inputBox, info.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void Iwa_TileFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_input.isConnected()) {
|
|
Shinya Kitaoka |
120a6e |
tile.getRaster()->clear();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TRectD inputBox;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int inputSizeMode =
|
|
shun-iwasawa |
78a7b2 |
m_inputSizeMode
|
|
shun-iwasawa |
78a7b2 |
->getValue(); // eBoundingBox = 1, eCameraBox = 2, eImageSize = 3
|
|
Shinya Kitaoka |
120a6e |
if (inputSizeMode == eBoundingBox)
|
|
Shinya Kitaoka |
120a6e |
m_input->getBBox(frame, inputBox, ri);
|
|
Shinya Kitaoka |
120a6e |
else if (inputSizeMode == eCameraBox) {
|
|
Shinya Kitaoka |
120a6e |
TPointD offset = tile.m_pos + tile.getRaster()->getCenterD();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inputBox = TRectD(
|
|
Shinya Kitaoka |
120a6e |
TPointD(ri.m_cameraBox.x0 + offset.x, ri.m_cameraBox.y0 + offset.y),
|
|
Shinya Kitaoka |
120a6e |
TDimensionD(ri.m_cameraBox.getLx(), ri.m_cameraBox.getLy()));
|
|
shun-iwasawa |
78a7b2 |
} else if (inputSizeMode == eImageSize) {
|
|
shun-iwasawa |
78a7b2 |
TRenderSettings riAux(ri);
|
|
shun-iwasawa |
78a7b2 |
// set a tentative flag to obtain full image size. (see
|
|
shun-iwasawa |
78a7b2 |
// TLevelColumnFx::doGetBBox)
|
|
shun-iwasawa |
78a7b2 |
riAux.m_getFullSizeBBox = true;
|
|
shun-iwasawa |
78a7b2 |
m_input->getBBox(frame, inputBox, riAux);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double scale = sqrt(fabs(ri.m_affine.det()));
|
|
Shinya Kitaoka |
120a6e |
int hmargin = m_hmargin->getValue(frame) * scale;
|
|
Shinya Kitaoka |
120a6e |
int vmargin = m_vmargin->getValue(frame) * scale;
|
|
Shinya Kitaoka |
120a6e |
inputBox = inputBox.enlarge(hmargin, vmargin);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (inputBox.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
tile.getRaster()->clear();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (inputBox == TConsts::infiniteRectD) {
|
|
Shinya Kitaoka |
120a6e |
m_input->compute(tile, frame, ri);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDimension size(0, 0);
|
|
Shinya Kitaoka |
120a6e |
size.lx = tceil(inputBox.getLx());
|
|
Shinya Kitaoka |
120a6e |
size.ly = tceil(inputBox.getLy());
|
|
Shinya Kitaoka |
120a6e |
TTile inputTile;
|
|
Shinya Kitaoka |
120a6e |
m_input->allocateAndCompute(inputTile, inputBox.getP00(), size,
|
|
Shinya Kitaoka |
120a6e |
tile.getRaster(), frame, ri);
|
|
Shinya Kitaoka |
120a6e |
makeTile(inputTile, tile);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool Iwa_TileFx::isInRange(int quantityMode, int index) {
|
|
Shinya Kitaoka |
120a6e |
switch (quantityMode) {
|
|
Shinya Kitaoka |
120a6e |
case eNoTile:
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eOneTile:
|
|
Shinya Kitaoka |
120a6e |
return (abs(index) < 2);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eMultipleTiles:
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool Iwa_TileFx::checkIfThisTileShouldBeComptedOrNot(int horizIndex,
|
|
Shinya Kitaoka |
120a6e |
int vertIndex) {
|
|
Shinya Kitaoka |
120a6e |
int leftQuantity = m_leftQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
int rightQuantity = m_rightQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
int topQuantity = m_topQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
int bottomQuantity = m_bottomQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool horizInRange, vertInRange;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (horizIndex == 0)
|
|
Shinya Kitaoka |
120a6e |
horizInRange = true;
|
|
Shinya Kitaoka |
120a6e |
else if (horizIndex < 0)
|
|
Shinya Kitaoka |
120a6e |
horizInRange = isInRange(leftQuantity, horizIndex);
|
|
Shinya Kitaoka |
120a6e |
else // horizIndex > 0
|
|
Shinya Kitaoka |
120a6e |
horizInRange = isInRange(rightQuantity, horizIndex);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (vertIndex == 0)
|
|
Shinya Kitaoka |
120a6e |
vertInRange = true;
|
|
Shinya Kitaoka |
120a6e |
else if (vertIndex < 0)
|
|
Shinya Kitaoka |
120a6e |
vertInRange = isInRange(bottomQuantity, vertIndex);
|
|
Shinya Kitaoka |
120a6e |
else // horizIndex > 0
|
|
Shinya Kitaoka |
120a6e |
vertInRange = isInRange(topQuantity, vertIndex);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
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 |
/*
|
|
shun-iwasawa |
78a7b2 |
*/
|
|
Shinya Kitaoka |
120a6e |
void Iwa_TileFx::makeTile(const TTile &inputTile, const TTile &tile) {
|
|
Shinya Kitaoka |
120a6e |
tile.getRaster()->clear();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Build the mirroring pattern. It obviously repeats itself out of 2x2 tile
|
|
Shinya Kitaoka |
120a6e |
// blocks.
|
|
Shinya Kitaoka |
120a6e |
std::map<std::pair<bool, bool="">, TRasterP> mirrorRaster;</std::pair<bool,>
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(false, false)] = inputTile.getRaster();</bool,>
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(false, true)] =</bool,>
|
|
Shinya Kitaoka |
120a6e |
inputTile.getRaster()->clone();
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(false, true)]->yMirror();</bool,>
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(true, false)] =</bool,>
|
|
Shinya Kitaoka |
120a6e |
inputTile.getRaster()->clone();
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(true, false)]->xMirror();</bool,>
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(true, true)] =</bool,>
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(true, false)]->clone();</bool,>
|
|
Shinya Kitaoka |
120a6e |
mirrorRaster[std::pair<bool, bool="">(true, true)]->yMirror();</bool,>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPoint animatedPos = convert(inputTile.m_pos - tile.m_pos);
|
|
Shinya Kitaoka |
120a6e |
TDimension inSize = inputTile.getRaster()->getSize();
|
|
Shinya Kitaoka |
120a6e |
TDimension outSize = tile.getRaster()->getSize();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool mirrorX = false, mirrorY = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int leftQuantity = m_leftQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
int rightQuantity = m_rightQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
int topQuantity = m_topQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
int bottomQuantity = m_bottomQuantity->getValue();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool tileHorizontally = leftQuantity != eNoTile || rightQuantity != eNoTile;
|
|
Shinya Kitaoka |
120a6e |
bool tileVertically = topQuantity != eNoTile || bottomQuantity != eNoTile;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*- 現在のタイルのインデックス -*/
|
|
Shinya Kitaoka |
120a6e |
int horizIndex = 0;
|
|
Shinya Kitaoka |
120a6e |
int vertIndex = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*- 左下のタイルのインデックスを計算 -*/
|
|
Shinya Kitaoka |
120a6e |
// Reach the lower left tiling position
|
|
Shinya Kitaoka |
120a6e |
while (animatedPos.x > 0 && tileHorizontally) {
|
|
Shinya Kitaoka |
120a6e |
animatedPos.x -= inSize.lx;
|
|
Shinya Kitaoka |
120a6e |
mirrorX = !mirrorX;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
horizIndex--;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
while (animatedPos.x + inSize.lx < 0 && tileHorizontally) {
|
|
Shinya Kitaoka |
120a6e |
animatedPos.x += inSize.lx;
|
|
Shinya Kitaoka |
120a6e |
mirrorX = !mirrorX;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
horizIndex++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
while (animatedPos.y > 0 && tileVertically) {
|
|
Shinya Kitaoka |
120a6e |
animatedPos.y -= inSize.ly;
|
|
Shinya Kitaoka |
120a6e |
mirrorY = !mirrorY;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
vertIndex--;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
while (animatedPos.y + inSize.ly < 0 && tileVertically) {
|
|
Shinya Kitaoka |
120a6e |
animatedPos.y += inSize.ly;
|
|
Shinya Kitaoka |
120a6e |
mirrorY = !mirrorY;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
vertIndex++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool doMirroX = mirrorX, doMirroY = mirrorY;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Write the tiling blocks.
|
|
Shinya Kitaoka |
120a6e |
tile.getRaster()->lock();
|
|
Shinya Kitaoka |
120a6e |
inputTile.getRaster()->lock();
|
|
Shinya Kitaoka |
120a6e |
TPoint startTilingPos = animatedPos;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int horizStartIndex = horizIndex;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
do {
|
|
Shinya Kitaoka |
120a6e |
do {
|
|
Shinya Kitaoka |
120a6e |
if (checkIfThisTileShouldBeComptedOrNot(horizIndex, vertIndex)) {
|
|
Shinya Kitaoka |
120a6e |
std::pair<bool, bool=""> doMirror(doMirroX && m_xMirror->getValue(),</bool,>
|
|
Shinya Kitaoka |
120a6e |
doMirroY && m_yMirror->getValue());
|
|
Shinya Kitaoka |
120a6e |
tile.getRaster()->copy(mirrorRaster[doMirror], startTilingPos);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
startTilingPos.x += inSize.lx;
|
|
Shinya Kitaoka |
120a6e |
doMirroX = !doMirroX;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
horizIndex++;
|
|
Shinya Kitaoka |
120a6e |
} while (startTilingPos.x < outSize.lx && tileHorizontally);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
startTilingPos.y += inSize.ly;
|
|
Shinya Kitaoka |
120a6e |
startTilingPos.x = animatedPos.x;
|
|
Shinya Kitaoka |
120a6e |
doMirroY = !doMirroY;
|
|
Shinya Kitaoka |
120a6e |
doMirroX = mirrorX;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
horizIndex = horizStartIndex;
|
|
Shinya Kitaoka |
120a6e |
vertIndex++;
|
|
Shinya Kitaoka |
120a6e |
} while (startTilingPos.y < outSize.ly && tileVertically);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inputTile.getRaster()->unlock();
|
|
Shinya Kitaoka |
120a6e |
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");
|