Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Boolean Operations in 3D in After Effects ?

  • Boolean Operations in 3D in After Effects ?

    Posted by Thomas Giegerich on February 11, 2009 at 4:13 pm

    Hi there

    i asked a pretty similar question already two weeks ago, but could not get any help. so i hope i might find someone who understands what i am looking for today 😉

    please have a look at the attached video
    https://shorts.creativecow.net/film/150

    all that is just a test for something a lot more complex – if it works with AE at all. this is just a small model of what i need to do.

    these are 27 little white dots arranged in a 3d space, which i want to become red, whenever the surface touches them. i do not want to see the rest of the red surface however. it is somewhat like a boolean operation i am looking for. it would be pretty easy in 2d with a fill effects, which does not work in 3d 🙁

    is there any way to do something like that in AE?

    thanks for any hint.

    thomas

    Filip Vandueren replied 17 years, 6 months ago 3 Members · 6 Replies
  • 6 Replies
  • Filip Vandueren

    February 11, 2009 at 5:30 pm

    Phew,

    that was a hard nut to crack…
    After googling some vector math I solved it.

    On your white points add a “Tint” Effect, set both colors to Red.

    For Amount to Tint put this expression:
    (change the first line to use the name of your red solid)


    l=thisComp.layer("Red Solid 1");

    // any three points on the plane that don't form a straight line
    p1=l.toWorld([2,3,0]);
    p2=l.toWorld([2,-2,0]);
    p3=l.toWorld([1,1,0]);

    // find the plane's equation for three points
    a=p1[1]*(p2[2]-p3[2])+p2[1]*(p3[2]-p1[2])+p3[1]*(p1[2]-p2[2]);
    b=p1[2]*(p2[0]-p3[0])+p2[2]*(p3[0]-p1[0])+p3[2]*(p1[0]-p2[0]);
    c=p1[0]*(p2[1]-p3[1])+p2[0]*(p3[1]-p1[1])+p3[0]*(p1[1]-p2[1]);
    d=-(p1[0]*(p2[1]*p3[2]-p3[1]*p2[2])+p2[0]*(p3[1]*p1[2]-p1[1]*p3[2])+p3[0]*(p1[1]*p2[2]-p2[1]*p1[2]));

    // the plane ax+bx+cx+d=0

    // the position of the current layer
    p4=toWorld(anchorPoint);

    // distance from plane to point
    distance = Math.abs ( (a*p4[0] + b*p4[1] + c*p4[2] + d) / Math.sqrt(a*a + b*b + c*c) );

    distance > width/2 ? 0 : 100;

    Copy the Tint Effect and paste to all White layers.
    You can now make the red solid invisible and rotate it.

    Notes:
    This uses the infinite plane of the Red Solid, not just where the solid actually would touch a layer.
    Also, the white dots act as if they are spheres with regards to the collision, so sometimes a corner of the white dots will touch, before it is red.
    I put a round mask on all the dots and orient them towards the camera.

  • Thomas Giegerich

    February 11, 2009 at 5:54 pm

    Hi Filip

    thanks for that. as i have no clue about expressions yet, some more questions:

    will this only work for rotating a layer in there? or can i generally move around pretty much anything in there?

    will it only work for that 3x3x3 matrix thing? because the actual thing will be 20x25x25 pixels.

    thanks for your help and i would apreaciate any more input.

    thomas

  • Filip Vandueren

    February 11, 2009 at 6:01 pm

    This expression only checks how close the current layer is to the infinite plane of that 1 red solid.

    You can apply it to as many 3d layers as you want. But you can only check for 1 plane.

    If you need more checks let me know.

  • Thomas Giegerich

    February 12, 2009 at 8:49 am

    Hey, thanks for that. I will play around with it. Looks pretty much like what i was looking for. Thanks a million.

  • Dan Ebberts

    February 12, 2009 at 4:41 pm

    Hey Filip,

    That’s some pretty cool math. Where did you find it?

    For this application, I think you could just use layer space transforms to put the small layers in the layer space of the large layer like this (I set this up as an opacity expression so the layer disappears when the other layer touches it):

    l=thisComp.layer(“Red Solid 1”);

    // get my position in other layer’s space

    p = l.fromWorld(toWorld(anchorPoint));

    if (p[0] >= -width/2 && p[0] <= l.width + width/2 && p[1] >= -height/2 && p[1] <= l.height + height/2 && Math.abs(p[2]) < width/2) 0 else 100; Dan

  • Filip Vandueren

    February 12, 2009 at 4:58 pm

    Hey Dan,

    Those damn layer transforms ! 🙂
    Just when I think I’ve got them figured out…
    You see, I thought transforming from anything to the layer’s space always yielded a 2D value !

    I found the math for 3points to ax+by+cz=d at:

    https://local.wasp.uwa.edu.au/~pbourke/geometry/planeeq/

    As usual when vector Math is involved, your solution blows mine out of the water 😉

    Cheers,

    Filip

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy