ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Child rotation ignoring parent in 3D

FAQ   •   VIEW ALL
 Child rotation ignoring parent in 3D on Jul 23, 2014 at 9:08:33 am

Hello everyone,

I have a layer called Emitter and a layer called Particle. I parent the Particle to the Emitter to define the emitter of the particle. When I rotate the Emitter in [X, Y, Z] I want the Particle to move along but remain facing towards the screen. I know I have to calculate the counter 3D rotation of the particle but I don't know how. Can you help me?

Thanks a lot!
Quang

 Re: Child rotation ignoring parent in 3Don Jul 23, 2014 at 2:45:01 pm

Probably the easiest way is to use another intermediate null.

Emitter (null, not parented to anything)
Particle Point (null, parented to Emitter)
Particle (layer, not parented to anything)

As you rotate Emitter, Particle Point will follow and its orientation will change.

Apply this expression to the Particle layer's position property (alt+click the Position stopwatch and paste:)
`thisComp.layer("Particle Point").toWorld(thisComp.layer("Particle Point").transform.anchorPoint)`

This expression returns the position of the Particle Point layer's anchor point in world space. Because Particle is not actually parented, it does not track Emitter's orientation.

Walter Soyka
Motion Graphics, Widescreen Events, Presentation Design, and Consulting

 Re: Child rotation ignoring parent in 3Don Jul 24, 2014 at 3:04:16 am

Thank you Walker Soyka for your solution. Unfortunately I want to make the particle system as simple as possible for my users to use and reuse. I should keep the number pf layers to minimum and parent the particles to the emitter and just these 2 types of layers so that when my users copy and paste they can make a new particle system in the same composition.

I have successfully counter the position and scale of these child particles, but for rotation in 3d it is very difficult. Can you help me with the method of no intermediate null?

 Re: Child rotation ignoring parent in 3Don Jul 24, 2014 at 8:06:56 am

Dan Ebberts has helped me solve it with this:
``` u = fromWorldVec([1,0,0]); v = fromWorldVec([0,1,0]); w = fromWorldVec([0,0,1]); sinb = clamp(w[0],-1,1); b = Math.asin(sinb); cosb = Math.cos(b); if (Math.abs(cosb) > .0005){ c = -Math.atan2(v[0],u[0]); a = -Math.atan2(w[1],w[2]); }else{ a = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]); c = 0; } [radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)] ```
Thank you all!