Transform_world working differently for image vs shape
Hi gang;
I am trying to understand what I'm doing wrong to get transform_world working correctly.
To explain, I have a circle image (circle.png) on a layer that I've imported into AE.
I also have a circle shape I created within After Effects on another layer.
My code below allows me to checkout either one through a dropdown. You can see I first checkout the selected layer. If a layer has data, I then draw over it (for testing purposes), and then transform it using transform_world. The issue is that it won't work with the circle image layer, but it will work with circle shape layer. I don't understand why?
if (!err) {
if (checkoutLayer.u.ld.data) {
ERR(suites.WorldSuite1()->new_world(in_data->effect_ref, max(checkoutLayer.u.ld.width * psize,1), max(checkoutLayer.u.ld.height * psize,1),
flags, &particle_world));
ERR(PF_ABORT(in_data));
if (PF_Quality_HI == in_data->quality)
{
ERR(suites.WorldTransformSuite1()->copy_hq(in_data->effect_ref, &checkoutLayer.u.ld, &particle_world, NULL, NULL));
} else {
ERR(suites.WorldTransformSuite1()->copy(in_data->effect_ref, &checkoutLayer.u.ld, &particle_world, NULL, NULL));
}
ERR(PF_ABORT(in_data));
// Let's draw some pixels in the effect world drawPixel32B(px2, py2, color, &particle_world);
PF_CompositeMode mode;
mode.opacity = alpha * 255 + 0.5;
mode.opacitySu = alpha * 32768 + 0.5;
mode.rgb_only = false;
mode.xfer = PF_Xfer_IN_FRONT;
PF_FloatMatrix mat1;
double ratio = (double)in_data->downsample_x.num / (double)in_data->downsample_x.den;
double scale = 1.0 * ratio;
mat1.mat[0][0] = scale;
mat1.mat[0][1] = 0.0;
mat1.mat[0][2] = 0.0;
mat1.mat[1][0] = 0.0;
mat1.mat[1][1] = scale;
mat1.mat[1][2] = 0.0;
mat1.mat[2][0] = px2 - checkoutLayer.u.ld.width * psize / 2;
mat1.mat[2][1] = py2 - checkoutLayer.u.ld.height * psize / 2; mat1.mat[2][2] = scale;
PF_FloatMatrix my_matrices[1];
my_matrices[0] = mat1;
PF_Rect dest;
dest.bottom = in_data->height;
dest.left = 0;
dest.right = in_data->width;
dest.top = 0;
int quality = PF_Quality_HI;
err = suites.WorldTransformSuite1()->transform_world(in_data->effect_ref, quality, PF_MF_Alpha_STRAIGHT, PF_Field_FRAME, &particle_world, &mode, NULL, my_matrices, 1L, true, &dest, output);
ERR(suites.WorldSuite1()->dispose_world(in_data->effect_ref, &particle_world));
} // checkout data
} // err
Sorry for the formatting - I had a lot of trouble posting it here in a readable way.
Could someone help explain what I'm doing wrong? Why can I draw on me effect world when the shape layer is selected but not when the circle.png image layer is selected?
Thanks,
-Richard
