FORUMS: list search recent posts

Expression to mimic parenting between sets of point and angle controls.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dustin Bailey
Expression to mimic parenting between sets of point and angle controls.
on Mar 17, 2015 at 11:50:22 pm

Hi everyone,

Been a fan of the forum for many years now. This is the first time I haven't found what I was looking for and thought maybe someone can help point me in the right direction.

I'd like to daisy chain points controls together and have them be able to rotate around one another with angle controls tied to them through expressions. I know, I know, I know this can be done very easily with null objects parented together, but would it be possible to mimic a parent/child relationship between sets of point & angle controllers?

Thanks in advance for any help out there!

Cheers,
Dustin

---
This probably isn't useful, but I'm including an expression I thought was getting me close. Then, I realized the parent position moved if I offset the child's position. That's because the distance from center is predefined. I was hoping using the length() function would help, but it didn't produce the results I expected and I'm over my head with trigonometry.
----

P= effect("PointRig")("Point 1"); //parent point control position
C= effect("PointRig")("Point 2"); //child point control position;

R = effect("PointRig")("Point 1 Rotation"); // parent rotation control, degrees
D = 150; // Distance from parent
rad = degreesToRadians((R * -1)-180);
x = D * Math.sin(rad);
y = D * Math.cos(rad);
[x, y] + P + C;


Return to posts index

Xavier Gomez
Re: Expression to mimic parenting between sets of point and angle controls.
on Mar 18, 2015 at 10:36:06 am

To rotate C around P by angle a (in radians):
u=sub(C, P);
c=Math.cos(a);
s=Math.sin(a);

x = c*u[0]-s*u[1];
y = s*u[0]+c*u[1];

[P[0]+x, P[1]+y]; // result (rotated C)


That's only valid in 2D if P and C's coordinates are expressed in the same referential (for instance, point2D controls on the same layer).

If they are not in the same referential, you should use the fromComp and toComp methods to convert back and forth to the same referential. And in 3D it is slightly more complicated.


Return to posts index

Dustin Bailey
Re: Expression to mimic parenting between sets of point and angle controls.
on Mar 18, 2015 at 6:09:55 pm

Thanks Xavier for such a quick response. I've seen your posts all over the forum and am geeking out a bit that you responded.

I had some time to try out the expression and it's kinda close, but it's not the exact parent/child relationship I was looking for. Here's the hiccups I'm noticing.

  • Rotation is off from angle control. Fixed by adding degreesToRadians();
  • Child doesn't follow the parents position.
  • Child does rotates around the parent point. Even if I move the parent. However, if I offset the rotation of the parent and then try to drag the child point around, the child point floats away from the cursor.


Ideally I'd be able to daisy chain a few of these together to help with a rig I'm building. I feel like I'm reinventing the wheel, but I know the rig will be so cool if this is possible. I'm going to continue to tinker, but I'd love to hear your thoughts. Thanks again!

P=effect("Character Rig")("Point 1");
C=effect("Character Rig")("Point 2");

R=effect("Character Rig")("Point 1 Rotation")
a=degreesToRadians(R);

u=sub(C, P);
c=Math.cos(a);
s=Math.sin(a);

x = c*u[0]-s*u[1];
y = s*u[0]+c*u[1];

[P[0]+x, P[1]+y]; // result (rotated C)


Return to posts index


Xavier Gomez
Re: Expression to mimic parenting between sets of point and angle controls.
on Mar 18, 2015 at 8:25:59 pm

Hi Dustin,

my answer was to help out for the rotation part.
For the entire problem, i must say i don't know, and actually i don't understand it.

So let's say you have 2 point constrols or similar on a layer, C1 and C2. You apply your "rig" (a set of expression controls, with one point "P", an angle "R" and may some other params like scale) on the same layer, and once set, when you move P, C1 and C2 move along, when you change R, the two children rotate around P, and may be also, if you change the scale params, the point configuration will scale out from P, and so on. Is that it ?


Return to posts index

Dustin Bailey
Re: Expression to mimic parenting between sets of point and angle controls.
on Mar 19, 2015 at 3:23:58 pm

Hi Xavier,

Sorry if I lost you on the last post. Your description is accurate, but I'll still need to be able to offset C2 and C1 from P. Like if you have one object parented to another, you can still move the child around indepentedly, but it also remains tied to it's parents position and rotation. At the moment I don't foresee the need to scale the relationship.

Maybe a little background could help. I've been doing a lot of character animation recently using puppet pins tied to a rig of nulls. These nulls are all parented together, e.g. hand to elbow to arm to torso. If I move/rotate the arm, the elbow and hand follow. And I can still keyframe and offset the hand and elbow nulls if needed.

My projects have gotten very messy with the amount of nulls being key framed. If I want to copy a pose I've used before, I have to go to each null separately and copy and paste keyframes. Thinking I could later mimic a parent/child relationship between point controllers, I built a pseudo effect with a position/angle controller for each null I'd normally use. I then tied my puppet pins to these. This keeps all my points on one effect and all my keyframes on one layer. This allows me to copy and paste poses all at once.

Does any of this make sense? I fear I'm confusing the the issue more rather than clarifying it. I've attached a screenshot to my current rig if it helps.



Return to posts index

Xavier Gomez
Re: Expression to mimic parenting between sets of point and angle controls.
on Mar 19, 2015 at 6:27:35 pm

Yes it does make sense and i also understand that you try to build something like this for the reasons you said.

But i think it is not a good direction, and even if you succed (honestly, i don't see how) it would be so heavy that things won't move.

Your idea assumes driving, from a unique layer, a configuration of points (all the pins controlling one character) that normally (1) belong to layers that move with respect to each other, and (2) even pins that belong to the same layer can move with respect to eachother.
Needless to say, you'll need far more point controls than just head/torso/etc/
Missing: all layer positions and anchorPoints, which are otherwise automatically handled by parenting to nulls.
Then you'll need a bunch of home-made transform expressions to reproduce the rig on this control layer, not only the pins relative transformations but also the layers relative transformations, and then undo everything with another bunch of layer.fromComp(controlLayer.toComp(point)) expressions to actually drive the art layers transformations and pins positions. It might be that i am exagerating the complexity, but it seems hopeless to me.

Another thing which is easier to explain is that to encode over time a rotation around some point + a translation you need an angle, an anchor (center of rotation) and a position (related to the translation part of the thing), so 2 points and one angle. If you only specify one point (interpreted either as position or anchorPoint) you will miss some info.
This is to explain (does it ?) why the child does not follow the parent when you move the parent.

Xavier.


Return to posts index


Dustin Bailey
Re: Expression to mimic parenting between sets of point and angle controls.
on Mar 19, 2015 at 6:40:45 pm

Yes it does. And thank you for taking the time to explain the complexity of what I was asking to do. I hope in the future a simpler solution can be found, but for now I'll happily handle these nulls. Thank you so much for your time.

Cheers,
Dustin


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]