-
Expression to make PreComps reposition within confines of a Master Comp?
Hello folks!
I’ve been trying to set up a sort of contact sheet full of various precomps, all of which will be the same size – and rather than creating a huge comp that ends up being 30,000 x wide, I decided to bring all my Precomps in and have them scaled down, allowing me to move the camera around this comp, still being able to close in and use continual rasterisation for quality. (This is possibly redundant info but I thought it might help).
I have decided to use an expression to make the comps line up one after another within the confines of this Master Comp.
I have also used a Slider Control which controls the scale of all comps. The way I did this was to add a “value/” expression and link to the Slider Control.
Currently for test purposes this slider is set to 5, which means I can fit 5 precomps across the comp’s width and of course, 5 in height, totalling 25 comps.
What I want however is to be able to adapt this quickly if necessary to maybe 6×6 or 10×0 and the comps to realign themselves within this Master Comp.
Oh and all comps within this Master Comp have had their anchor points set to 0,0. The first Precomp has no expression and is simply positioned at 0,0 as well so top left in the comp. Fans of the X-Files will appreciate my naming shortcuts.
So here’s my expression so far (remember the Slider controller is set to 5):Mulder=thisComp.layer(“Scale of Comps Controller”).effect(“Scale Slider”)(“Slider”); // This as I say scales the precomps, currently set to 5
Scully=thisComp.height/thisComp.layer(“Scale of Comps Controller”).effect(“Scale Slider”)(“Slider”); // This used to make the second row.
Skinner=thisComp.layer(index-1).transform.position[0]+thisComp.width/Mulder; // This used to make each following comp move horizontally 1 precomps width to the right.
Krycek=thisComp.layer(index-1).transform.position[1]; // And finally the Height shortcut, simply pointing to the above layers height to find it’s value.[Skinner,Krycek]; // so up to here I have the comps moving out across the comp, by 1 precomp width each time. However they do not constrain to the Master Comp size. So I used this if/else expression.
if
(Skinner > thisComp.width-1){
[0,1+Scully];}else{[Skinner,Krycek];};
// Simply put, if the X position of the precomp is greater than the width of the Master Comp (minus 1 as otherwise it will position a precomp at 1920), reset the xPosition to 0 and adjust the Yposition to The Height of the Comp / Scale value (in this case 5)Here is the expression without my annotations:
Mulder=thisComp.layer(“Scale of Comps Controller”).effect(“Scale Slider”)(“Slider”);
Scully=thisComp.height/thisComp.layer(“Scale of Comps Controller”).effect(“Scale Slider”)(“Slider”);
Skinner=thisComp.layer(index-1).transform.position[0]+thisComp.width/Mulder;
Krycek=thisComp.layer(index-1).transform.position[1];[Skinner,Krycek];
if
(Skinner > thisComp.width-1){
[0,1+Scully];}else{[Skinner,Krycek];};
So far this expression gives me a comp that allows ten precomps along two rows to reposition accordingly. However the 11th precomp resets to the start of the second row, as I haven’t been able to give it a new yPosition value.
I thought of finding an expression to add to the “if / else” that told it to see if any other layers held the same position, and if so, to move down by the height division + the previous layers height (in my shortcut speak, Scully + the Y Position of Index-1).
This I think would solve the problem as, given the first calculation (dictating width), the only time a comp could possibly be in the same position as another would be if it had reached the end of it’s row, and via the width position constraint had gone back to square one.
Therefore making it jump down one row in this circumstance, I could ensure its following Precomps would look to their predecessors for their relative Height (using the Krycek shortcut).
I am however now at my limits of expressions and lost.
I’m also wondering if I am missing a bloody obvious trick here by trying to be too clever by half!
Any thoughts or suggestions would be hugely appreciated folks.
Thanks in advance!
Dave Byrne
Animo Motion Graphics.