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