Forum Replies Created

Page 2 of 2
  • Sébastien Périer

    March 9, 2008 at 1:00 pm in reply to: Problem with layer position

    Hum, this is looking really nice. i’ll give it a try on monday when i get back to work and i’ll tell you if it works nicely.

    Thanks again Dan,

    Seb

  • Sébastien Périer

    March 8, 2008 at 9:31 am in reply to: Problem with layer position

    Nice to hear something like that Dan.

    So let’s get deeper into my code.

    First of all, my 8 solid layers are named “L01”, “L02”, … , “L08”

    The expression linking their opacity to my Expresion control looks like that:

    For “L01”:

    ———————————————–
    Switch =thisComp.layer(“Ctrl_Lxx”).effect(“Lxx Global Switch”)(“Point”)[0];

    // “Ctrl_Lxx” is the name of my null layer with expresion control
    // “Lxx Global Switch” is the name of my Point expression control

    if (Switch >= 10000000) Switch = Switch-10000000;
    if (Switch >= 1000000) Switch = Switch-1000000;
    if (Switch >= 100000) Switch = Switch-100000;
    if (Switch >= 10000) Switch = Switch-10000;
    if (Switch >= 1000) Switch = Switch-1000;
    if (Switch >= 100) Switch = Switch-100;
    if (Switch >= 10) Switch = Switch-10;

    if (Switch < 1) transform.opacity = 10; else transform.opacity = 100; ----------------------------------------------- For "L02": ----------------------------------------------- Switch =thisComp.layer("Ctrl_Lxx").effect("Lxx Global Switch")("Point")[0]; if (Switch >= 10000000) Switch = Switch-10000000;
    if (Switch >= 1000000) Switch = Switch-1000000;
    if (Switch >= 100000) Switch = Switch-100000;
    if (Switch >= 10000) Switch = Switch-10000;
    if (Switch >= 1000) Switch = Switch-1000;
    if (Switch >= 100) Switch = Switch-100;

    if (Switch < 10) transform.opacity = 10; if (Switch >= 10) transform.opacity = 100;
    ———————————————–

    and so on, for the 6 other layers.

    The main expression if of course on the effect(“Lxx Global Switch”)(“Point”).

    It Looks like:

    ———————————————–
    Target = effect(“Lxx Switch Target”)(“Curseur”);
    //(“Curseur”) is the french name of “Slider”; This is the slider control where i choose how many layers shall be seen.

    Actual = effect(“Lxx Global Switch”)(“Point”)[0];
    //This is where i was supposed to get the actual information of shown layers.

    ActualTable = [0,0,0,0,0,0,0,0];
    // This is the Array where i was supposed to store the shown information in a more conviniant way than in a large number for programation purposes, based on the “Actual” value.

    FinalTable = [0,0,0,0,0,0,0,0];
    //This is the array where i’ll store the new shown/hidden layers.

    ActualNum = 0;
    // This is where I was supposed to put the calculated information on how many layers are actually lit based on the “Actual” value.

    Final = Actual;
    //Final is where i’ll store the final result.

    //Below is the part where i transformed the “Actual” value into the “ActualTable” Array, and where i counted how many layers where lit in order to update the “ActualNum” value.
    //It is in comment because right now it was useless as i tried to figure out how to get that “Actual” value right first.

    /*
    if (Actual >= 10000000)
    {
    ActualTable[0] = 1;
    ActualNum++;
    Actual = Actual – 10000000;
    }
    else ActualTable[0] = 0;

    if (Actual >= 1000000)
    {
    ActualTable[1] = 1;
    ActualNum++;
    Actual = Actual – 1000000;
    }
    else ActualTable[1] = 0;

    if (Actual >= 100000)
    {
    ActualTable[2] = 1;
    ActualNum++;
    Actual = Actual – 100000;
    }
    else ActualTable[2] = 0;

    if (Actual >= 10000)
    {
    ActualTable[3] = 1;
    ActualNum++;
    Actual = Actual – 10000;
    }
    else ActualTable[3] = 0;

    if (Actual >= 1000)
    {
    ActualTable[4] = 1;
    ActualNum++;
    Actual = Actual – 1000;
    }
    else ActualTable[4] = 0;

    if (Actual >= 100)
    {
    ActualTable[5] = 1;
    ActualNum++;
    Actual = Actual – 100;
    }
    else ActualTable[5] = 0;

    if (Actual >= 10)
    {
    ActualTable[6] = 1;
    ActualNum++;
    Actual = Actual – 10;
    }
    else ActualTable[6] = 0;

    if (Actual >= 1)
    {
    ActualTable[7] = 1;
    ActualNum++;
    Actual = Actual – 1;
    }
    else ActualTable[7] = 0;
    */

    // This is where I’m supposed to update and calculate my “ActualTable” taking into account the new “target” value of shown layers.
    // Right now, as my ActualNum is always at “0”, it always goes only thru the first “if”.

    if (Target > ActualNum)
    {
    while (Target > ActualNum)
    {
    temp = Math.round(random(7));
    if (ActualTable[temp] == 0)
    {
    ActualTable[temp] = 1;
    ActualNum++;
    }
    }
    }
    if (ActualNum > Target)
    {
    while (ActualNum > Target)
    {
    temp = Math.round(random(7));
    if (ActualTable[temp] == 1)
    {
    ActualTable[temp] = 0;
    ActualNum–;
    }
    }
    }
    FinalTable = ActualTable;

    //Finally, i convert back my array into a simple large value to update my (“point”)[0] value.

    Final = (FinalTable[0]*10000000) + (FinalTable[1]*1000000) + (FinalTable[2]*100000) + (FinalTable[3]*10000) + (FinalTable[4]*1000) + (FinalTable[5]*100) + (FinalTable[6]*10) + FinalTable[7];

    //In here, only the [0] value matters, i used the [1] value to show my intermediate values to help me debbugging the script.
    [Final, ActualNum]
    ———————————————–

    And that’s about it. it may not be the smartest way to achieve such an effect, but i haven’t used my programming skills for mre tha 3 years now, and it’s kinda difficult to get back in touch with Javascript and such.

    Thank you Dan.

  • Sébastien Périer

    March 8, 2008 at 12:08 am in reply to: Problem with layer position

    It’s a bit difficult to explain.

    in fact i have 8 solids, and i do control their opacity with my controller layer. Until here it sounds easy.

    Thoses 8 layers opacity value is an expression linking to my Point[0] value. This value looks like this: 10010110. Each 1 or 0 stands for one of the layer, 1 saying it should be visible, 0 it should not be visible.

    This number is generated by an expression. I have a slider control in which i keyframe the value from 0 to 8, depending on how many of theses solids i want to be visible. Lets say i want 4 solids visible, I will put a 4 in my slider control, and it will update the point[0] value with four 1, and the chosen solids will show up. I used a Point controller as the slider control does not allow such large numbers.

    My problem is that i don’t want my 4 visible to change every frame, but right now it’s what it does., because i’m not able to get that value back at the begining of my expression to compare the number of layers actually showing, with the number requested by my slider control. And, if i wanted to add 1 more layer visible, it would also choose 5 new random solids.

    That is my problem.

Page 2 of 2

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