|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tbasefx.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "timage_io.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamcontainer.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFxUtil::setParam(const TFxP &fx, std::string paramName, double value) {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP param = TParamP(fx->getParams()->getParam(paramName));
|
|
Shinya Kitaoka |
120a6e |
assert(param);
|
|
Shinya Kitaoka |
120a6e |
param->setDefaultValue(value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFxUtil::setParam(const TFxP &fx, std::string paramName, TPixel32 color) {
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP param = TParamP(fx->getParams()->getParam(paramName));
|
|
Shinya Kitaoka |
120a6e |
assert(param);
|
|
Shinya Kitaoka |
120a6e |
param->setDefaultValue(color);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFxP TFxUtil::makeColorCard(TPixel32 color) {
|
|
Shinya Kitaoka |
120a6e |
TFxP fx = TFx::create("colorCardFx");
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
setParam(fx, "color", color);
|
|
Shinya Kitaoka |
120a6e |
return fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFxP TFxUtil::makeCheckboard() {
|
|
Shinya Kitaoka |
120a6e |
return makeCheckboard(TPixel32(255, 200, 200), TPixel32(180, 190, 190), 50);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DVAPI TFxP TFxUtil::makeCheckboard(TPixel32 c1, TPixel32 c2, double size) {
|
|
Shinya Kitaoka |
120a6e |
TFxP fx = TFx::create("checkBoardFx");
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
setParam(fx, "color1", c1);
|
|
Shinya Kitaoka |
120a6e |
setParam(fx, "color2", c2);
|
|
Shinya Kitaoka |
120a6e |
setParam(fx, "size", size);
|
|
Shinya Kitaoka |
120a6e |
return fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFxP TFxUtil::makeOver(const TFxP &dn, const TFxP &up) {
|
|
Shinya Kitaoka |
120a6e |
if (!dn)
|
|
Shinya Kitaoka |
120a6e |
return up;
|
|
Shinya Kitaoka |
120a6e |
else if (!up)
|
|
Shinya Kitaoka |
120a6e |
return dn;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(up && dn);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFxP overFx = TFx::create("overFx");
|
|
Shinya Kitaoka |
120a6e |
if (!overFx) {
|
|
Shinya Kitaoka |
120a6e |
assert(overFx);
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!overFx->connect("Source1", up.getPointer()) ||
|
|
Shinya Kitaoka |
120a6e |
!overFx->connect("Source2", dn.getPointer()))
|
|
Shinya Kitaoka |
120a6e |
assert(!"Could not connect ports!");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return overFx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// ------------------------------------------------------------------ -
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFxP TFxUtil::makeDarken(const TFxP &dn, const TFxP &up) {
|
|
Shinya Kitaoka |
120a6e |
if (!dn)
|
|
Shinya Kitaoka |
120a6e |
return up;
|
|
Shinya Kitaoka |
120a6e |
else if (!up)
|
|
Shinya Kitaoka |
120a6e |
return dn;
|
|
Shinya Kitaoka |
120a6e |
assert(dn);
|
|
Shinya Kitaoka |
120a6e |
assert(up);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*-- TODO: FxId名変更となる可能性が高い。DarkenFx実装後に修正のこと。2016/2/3
|
|
Shinya Kitaoka |
120a6e |
* shun_iwasawa --*/
|
|
Shinya Kitaoka |
120a6e |
TFxP darkenFx = TFx::create("STD_inoDarkenFx");
|
|
Shinya Kitaoka |
120a6e |
assert(darkenFx);
|
|
Shinya Kitaoka |
120a6e |
if (!darkenFx) return 0;
|
|
Shinya Kitaoka |
120a6e |
darkenFx->connect("Back", dn.getPointer());
|
|
Shinya Kitaoka |
120a6e |
darkenFx->connect("Fore", up.getPointer());
|
|
Shinya Kitaoka |
120a6e |
return darkenFx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFxP TFxUtil::makeAffine(const TFxP &arg, const TAffine &aff) {
|
|
Shinya Kitaoka |
120a6e |
if (aff == TAffine()) return arg;
|
|
Shinya Kitaoka |
120a6e |
if (!arg) return TFxP();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
NaAffineFx *affFx = new NaAffineFx();
|
|
Shinya Kitaoka |
120a6e |
assert(affFx);
|
|
Shinya Kitaoka |
120a6e |
TFxP fx = affFx;
|
|
Shinya Kitaoka |
120a6e |
affFx->setAffine(aff);
|
|
Shinya Kitaoka |
120a6e |
if (!affFx->connect("source", arg.getPointer()))
|
|
Shinya Kitaoka |
120a6e |
assert(!"Could not connect ports!");
|
|
Shinya Kitaoka |
120a6e |
return fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFxP TFxUtil::makeBlur(const TFxP &arg, double blurValue) {
|
|
Shinya Kitaoka |
120a6e |
TFxP fx = TFx::create("STD_blurFx");
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
setParam(fx, "value", blurValue);
|
|
Shinya Kitaoka |
120a6e |
if (!fx->connect("Source", arg.getPointer()))
|
|
Shinya Kitaoka |
120a6e |
assert(!"Could not connect ports!");
|
|
Shinya Kitaoka |
120a6e |
return fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFxUtil::getKeyframeStatus(const TFxP &fx, int frame) {
|
|
Shinya Kitaoka |
120a6e |
bool keyframed = false, notKeyframed = false;
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < fx->getParams()->getParamCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TParamP param = fx->getParams()->getParam(i);
|
|
Shinya Kitaoka |
120a6e |
if (param->isAnimatable()) {
|
|
Shinya Kitaoka |
120a6e |
if (param->isKeyframe(frame))
|
|
Shinya Kitaoka |
120a6e |
keyframed = true;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
notKeyframed = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (keyframed == false)
|
|
Shinya Kitaoka |
120a6e |
return TFxUtil::NO_KEYFRAMES;
|
|
Shinya Kitaoka |
120a6e |
else if (notKeyframed == false)
|
|
Shinya Kitaoka |
120a6e |
return TFxUtil::ALL_KEYFRAMES;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return TFxUtil::SOME_KEYFRAMES;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFxUtil::deleteKeyframes(const TFxP &fx, int frame) {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < fx->getParams()->getParamCount(); i++)
|
|
Shinya Kitaoka |
120a6e |
fx->getParams()->getParam(i)->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFxUtil::setKeyframe(const TFxP &dstFx, int dstFrame, const TFxP &srcFx,
|
|
Shinya Kitaoka |
120a6e |
int srcFrame, bool changedOnly) {
|
|
Shinya Kitaoka |
120a6e |
if (dstFx->getFxType() != srcFx->getFxType()) return;
|
|
Shinya Kitaoka |
120a6e |
assert(dstFx->getParams()->getParamCount() ==
|
|
Shinya Kitaoka |
120a6e |
srcFx->getParams()->getParamCount());
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < dstFx->getParams()->getParamCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TParamP dstParam = dstFx->getParams()->getParam(i);
|
|
Shinya Kitaoka |
120a6e |
TParamP srcParam = srcFx->getParams()->getParam(i);
|
|
Shinya Kitaoka |
120a6e |
dstParam->assignKeyframe(dstFrame, srcParam, srcFrame, changedOnly);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|