7 Replies Latest reply on Mar 24, 2010 2:21 PM by Rick Gerard

    Opposing symmetry, or Parent-child opposition, possible?

    345712473471 Level 1

      Im doing stereoscopic animation, which basically involves moving two identical objects oppositely along the x axis, and am trying to figure out a way to do this without having to tweak them individually, like how a null object can be used to uniformly change a parameter for a group of objects. The null object would work if there was some way to have one of its childs act oppositely. Or perhaps im thinking about this too linearly?

        • 1. Re: Opposing symmetry, or Parent-child opposition, possible?
          Mylenium Most Valuable Participant

          Effects like CC Kaleida, CC Repetile and Mirror applied to pre-comp? Expressions? Your description is far too vague to really make sense of it and depending on what you mean by "stereoscopic", otehr requirements may need to be figured in as well.

           

          Mylenium

          • 2. Re: Opposing symmetry, or Parent-child opposition, possible?
            Rick Gerard Adobe Community Professional & MVP

            For 2D motion apply this expression to the Anchor point of your mirror layer. (assuming the other layer is named Master);

             

            i = [thisComp.width/2, thisComp.height/2];
            thisComp.layer("Master").position -i
            
            

            If you are using 3D layers then add a comma and a zero after height/2 (IOW .height/2, 0]

             

            If you need to mirror rotation simply add a - sign to an expression pointing to the layers rotation property.

             

            - thisComp.layer("Master").rotation
            

            That Should do it.

            1 person found this helpful
            • 3. Re: Opposing symmetry, or Parent-child opposition, possible?
              345712473471 Level 1

              It worked! thanks, thats going to save me alot of time. Im not very familiar with expression though, could you explain what exactly the script is doing? what does 'i' do?

               

              Also i want to be able to rotate my objects on the y axis so that they spin in place, but the expression you have locks the anchor point of the slaved object, keeping it from being moved to the objects center. How can i do this?

              • 4. Re: Opposing symmetry, or Parent-child opposition, possible?
                Mylenium Most Valuable Participant

                i is just a variable that holds the result values of the previous calculation. This is merely used to make the code more readable and structure it.

                 

                Also i want to be able to rotate my objects on the y axis so that they spin in place, but the expression you have locks the anchor point of the slaved object, keeping it from being moved to the objects center. How can i do this?

                 

                Simply add another level of parenting by defining a global Null object that rotates and has the mirroring stuff below it in the hierarchy.

                 

                Mylenium

                • 5. Re: Opposing symmetry, or Parent-child opposition, possible?
                  Rick Gerard Adobe Community Professional & MVP

                  To expand on Mylenium's explanation let's go through the expression, which I've modified to allow you to change the anchor point and the layers are 3D.

                   

                  i = [thisComp.width/2, thisComp.height/2, 0];
                  value + thisComp.layer("Master").position -i
                  

                   

                  The default layer position for a layer of any size is at the center of a composition. In 2D space the value for default position is half the comp width for X and half the comp height for Y. If the layer is in 3D space then the default for Z is 0.  The first line just defines a variable that is this value. If you were working in a comp that was 720 X 480 then I could also be defined as the array [320, 240, 0]. I used half the comp width and height so that the expression would work with any sized comp.

                   

                  I've added a "value +" statement to the second line. This statement allows you to change the value of the property and set keyframes as needed. The easiest way to change the value for Anchor point is to drag around the value in the Time Line window.

                   

                  Using anchor point of one layer and the position of another is just one way of mirroring the position of layers. This expression just subtracts the position value of the Master layer from the center of the comp. This does not, however, solve your rotation problem because the anchor point is constantly changing.

                   

                  As Mylenium said one solution to your rotation problem would be to add a Null as a parent. Another, possibly simpler solution, would be to modify the expression so that it would control position instead of anchor point. The modification is fairly easy

                   

                  Remove your expression from the Slave layer's Anchor Point and add this to the layer's Position property:

                   

                  i = [thisComp.width/2, thisComp.height/2];
                  mp = thisComp.layer("Master").position;
                  (i) - mp + i
                  

                   

                  In this case I'm subtracting the initial position, the variable "i" in the brackets from the current position of the Master Layer, the variable "mp", then adding back in the default position of the Slave layer. This expression works in 2D or 3D space. You cannot add a value + statement to the last line but you could define an offset value or set keyframes for position by using Expression Point Control as a third variable.

                   

                  Setting up these kinds of relationships is nothing more than basic middle school math translated into expression language.

                   

                  I hope this helps.

                  1 person found this helpful
                  • 6. Re: Opposing symmetry, or Parent-child opposition, possible?
                    345712473471 Level 1

                    Thanks for the explaination, i guess i should learn the syntax first. Im having a problem with the last set of expressions though, here's my setup:

                     

                    I have a composition from ai that i imported (as a comp), opened it, then added it again for the other view, and parented each set to a global null so i can resize and place them. When i add the script to the position of an object, renaming "master" to the objects name (is it a problem that both slave and master have the same name?), the slave object disappears. Ive soloed the layer to see if it just got misplaced, but its gone. If i delete the null objects so its not parented anymore and apply the expression, the object gets moved down few pixels, which isnt a big deal, except that i dont know if there is something else going on that might cause problems later.

                     

                    Also, is there any way to program "reset" to go to the current position, so if i something strange happens and i dont notice i can just hit it instead of undoing all my work?

                    • 7. Re: Opposing symmetry, or Parent-child opposition, possible?
                      Rick Gerard Adobe Community Professional & MVP

                      I'm not sure that I understand your composition. The reason your layer seemed to disappear when you applied the expression was because of the parenting. Let me explain.

                       

                      When you start parenting layers the child takes on the parent's position. For example if you parent layer one to null one, and all layers are at their default positions then you'll see that the new position reported for layer one is 0,0,0 (assuming 3D layers). To make an expression like this work with parented layers you need to use Layer Space Transformations.

                       

                      So if you have a comp set up this way here's one solution.

                       

                      Layer 1 = Null 1, parent: None

                      Layer 2 = Slave, parent: Null 1

                      Layer 3 = Master, parent None

                       

                      The position expression for Layer 2 (Slave) position is as follows:

                       

                      L = thisLayer;
                      p = L.toWorld(anchorPoint);
                      
                      m = thisComp.layer("Master");
                      p - m.position
                      

                       

                      Here's how this works.

                      1. L defines the variable as the layer we're working on (Slave)
                      2. p defines the variable p as the value in the world space of the position of the anchor point of the L or Slave layer
                      3. m defines the variable as the Master layer in this composition
                      4. Here's where we do the math - the position of Master layer (m) is subtracted from the position in world space of the Slave (p) layer

                      This works because the slave layer's position when parented to the Null layer is returned as 0,0,0

                       

                      The expression will not work if you turn off the parent.

                       

                      If you have both Layer 3 and Layer 2 parented to the Null 1 layer then this expression will also no longer work because the position of the Master is tied to Null 1 and is now  reported as 0,0,0. In order to make it work with both layers parented to the Null you need to add in another Layer Space Transformation. You should be able to figure that out, or at least figure out how the expression works.

                       

                      L = thisLayer;
                      p = L.toWorld(anchorPoint);
                      m = thisComp.layer("Master");
                      mp = m.toWorld(anchorPoint);
                      p - mp
                      

                       

                      Again this is expression is only for use if the both the Slave and Master are tied to a parent.

                       

                      To answer your other questions, yes the layer names matter because the expression is pointing to them, and Reset only works if you turn off parenting. Resetting layer position will always bring layers back to the exact center of the composition world. If you have imported a Photoshop file or an Illustrator file as a composition with cropped layers Reset Will Not reposition them to their original positions in the file. There is no easy way to re-set the original positions unless you have set a keyframe for each layer before anything else was done and then copied that information somewhere where you can find it. My usual procedure is to simply duplicate the imported AI or PSD file composition then work on the duplicate.

                       

                      I hope this helps.

                       

                      One more note. A screenshot of your comp or a copy of the comp, even without footage would help me figure out what you're trying to do and why it's not working.