Copy link to clipboard
Copied
plugin newbie,
looking for information about copying an image (a relatively small layer, selected in a menu)
into my effected layer, with rotation.
currently using :
WorldTransformSuite1()->composite_rect (
to do my copy, but I do not see anything about a transform matrix or a way to transform the world prior to doing the copy (with any of the different macros I found.)
what am I missing?
thnx,
-td
Copy link to clipboard
Copied
transform_world()
Copy link to clipboard
Copied
ok... I like that. straight forward. Thanks.
I do have a question or two about that though:
1. I've been staring at the documentation for transform_world() for a while, and it says :
The matrices pointer points to a matrix array used for motion-blur.
there's only 1 reference to a matrix. the documentation seems to be saying that the matrix is strictly used for information regarding motion blur. this is untrue?
2. the only example that Adobe ships that uses transform_world, sadly does not rotate the image. Could you point out an example somewhere? Thanks.
Copy link to clipboard
Copied
Hi,
1.Use an array of matrices only if you want motion blur.
You can check this thread:
Transform_world and motion blur
Otherwise just pass a simple matrix like so:
ERR(suites.WorldTransformSuite1()->transform_world( in_data->effect_ref,
in_data->quality,
PF_MF_Alpha_STRAIGHT,
PF_Field_FRAME,
&sourceWorld,
&compositeMode,
NULL,
&mat, //here's your matrix
1L,
FALSE,
&dstRect,
&newWorld));
2.And here you'll find the matrix transform functions you need (thanx to Shachar):
The order I use is this one:
PF_FloatMatrix mat;
SetIdentityMatrix( &mat);
TranslateMatrix( &mat, posX, posY, NULL, NULL);
RotateMatrix( &mat, in_data, angle, NULL, NULL);
ScaleMatrix( &mat, scale, scale, NULL, NULL);
TranslateMatrix( &mat, - anchorX, - anchorY, NULL, NULL);
Then transform_world()
Have fun!
heers,
François
Copy link to clipboard
Copied
this is wonderful, thank you.
Copy link to clipboard
Copied
Hi Francois;
I came across this post while searching for the matrix transform functions (I need to perform basic 2D translation, rotation and scale). However, all your links are dead.
Would it be possible for you to post those functions for me? I don't see them anywhere in the SDK. It would be highly appreciated.
Thanks!
Rich
Copy link to clipboard
Copied
From CCU:
static void CCU_ConcatMatrix(
const PF_FloatMatrix *src_matrixP,
PF_FloatMatrix *dst_matrixP)
{
PF_FloatMatrix tmp;
PF_FpLong tempF = 0;
for (register A_long iL = 0; iL < 3; iL++) {
for (register A_long jL = 0; jL < 3; jL++) {
tempF = dst_matrixP->mat[iL][0] * src_matrixP->mat[0][jL] +
dst_matrixP->mat[iL][1] * src_matrixP->mat[1][jL] +
dst_matrixP->mat[iL][2] * src_matrixP->mat[2][jL];
tmp.mat[iL][jL] = tempF;
}
}
*dst_matrixP = tmp;
}
void SetIdentityMatrix(
PF_FloatMatrix *matrixP)
{
matrixP->mat[0][0] =
matrixP->mat[1][1] =
matrixP->mat[2][2] = 1;
matrixP->mat[0][1] =
matrixP->mat[0][2] =
matrixP->mat[1][0] =
matrixP->mat[1][2] =
matrixP->mat[2][0] =
matrixP->mat[2][1] = 0;
}
PF_Err TranslateMatrix(
PF_FloatMatrix *mP,
PF_FpLong offsetX,
PF_FpLong offsetY)
{
PF_Err err = PF_Err_NONE;
PF_FloatMatrix translate;
translate.mat[0][0] = 1;
translate.mat[0][1] = 0;
translate.mat[0][2] = 0;
translate.mat[1][0] = 0;
translate.mat[1][1] = 1;
translate.mat[1][2] = 0;
translate.mat[2][0] = 0.0 + offsetX;
translate.mat[2][1] = 0.0 + offsetY;
translate.mat[2][2] = 1;
CCU_ConcatMatrix(&translate, mP);
return err;
}
PF_Err SkewMatrix(
PF_FloatMatrix *mP,
PF_FpLong skewX,
PF_FpLong skewY)
{
PF_Err err = PF_Err_NONE;
PF_FloatMatrix skew;
skew.mat[0][0] = 1;
skew.mat[0][1] = skewY;
skew.mat[0][2] = 0;
skew.mat[1][0] = skewX;
skew.mat[1][1] = 1;
skew.mat[1][2] = 0;
skew.mat[2][0] = 0;
skew.mat[2][1] = 0;
skew.mat[2][2] = 1;
CCU_ConcatMatrix(&skew, mP);
return err;
}
PF_Err ScaleMatrix(
PF_FloatMatrix *mP,
PF_FpLong scaleX,
PF_FpLong scaleY)
{
PF_Err err = PF_Err_NONE;
PF_FloatMatrix scale;
if (scaleX != 1.0 || scaleY != 1.0)
{
scale.mat[0][0] = scaleX;
scale.mat[0][1] = 0;
scale.mat[0][2] = 0;
scale.mat[1][0] = 0;
scale.mat[1][1] = scaleY;
scale.mat[1][2] = 0;
scale.mat[2][0] = 0;
scale.mat[2][1] = 0;
scale.mat[2][2] = 1;
CCU_ConcatMatrix(&scale, mP);
}
return err;
}
PF_Err RotateMatrix (
PF_FloatMatrix *matrixP,
PF_InData *in_data,
PF_FpLong degreesF,
PF_FpLong aboutXF,
PF_FpLong aboutYF )
{
AEGP_SuiteHandler suites(in_data->pica_basicP);
PF_Err err = PF_Err_NONE;
PF_FloatMatrix rotate;
PF_FpLong radiansF = 0,
sF = 0,
cF = 0;
if (degreesF){
radiansF = PF_RAD_PER_DEGREE * degreesF;
sF = suites.ANSICallbacksSuite1()->sin(radiansF);
cF = suites.ANSICallbacksSuite1()->cos(radiansF);
rotate.mat[0][0] = cF;
rotate.mat[0][1] = sF;
rotate.mat[0][2] = 0;
rotate.mat[1][0] = -sF;
rotate.mat[1][1] = cF;
rotate.mat[1][2] = 0;
rotate.mat[2][0] = (aboutXF * (1.0 - cF) + aboutYF * sF);
rotate.mat[2][1] = (aboutYF * (1.0 - cF) - aboutXF * sF);
rotate.mat[2][2] = 1;
CCU_ConcatMatrix(&rotate, matrixP);
}
return err;
}
Copy link to clipboard
Copied
James, you sir, are the best. 🙂
Thank you!
-Rich