Friday 10 April 2009

If expression for multiple objects

Nick,

Hope the Easter holidays are going well.

We are having problems with connecting the If statements to multiple object output. An example (in the long run) we are trying to achieve is that if sensor A < X then translateX, if sensor A >X but < Y then translate Z, and if sensorA >Y then translate Y. Though we are having trouble connecting just even one statement. Here is the script we have complied together:

int $num = 30;
float $multi = 10;
float $zFactor = 2;

for($j=1; $j<=$num; $j++) {float $xMove = sin($j); float $yMove = ($j*.5); string $name = ("plane_"+$j); string $expressM = ($name+".translateZ=sensorInput.sensor1*" + ($j*10)); string $expressR = ($name+".rotateZ=sensorInput.sensor2*" + (sin($j)*5)); string $expressIf = (if (sensorInput.sensor3 >0.6)\r\n{$name+".translateX =sensorInput.sensor3*" + ($j*2)});
polyCube -n $name -ch on -o on -w $j -h $j -d 0.3;
move -a ($xMove*$multi) ($yMove*$multi) ($j*$zFactor) $name;

expression -s $expressM -o plane_1 -ae 1 -uc all;
expression -s $expressR -o plane_1 -ae 1 -uc all;
expression -e -s $expressIf -o plane_1 -ae 1 -uc all;
}

We have tried other ways of putting "if" statements into the seperate expressions that are created but again it doesnt work. I think this might be the closest way following the script editor and placing certain texts in the expression edittor. But I am thinking the problem is in this part of the code -string $expressIf = (if (sensorInput.sensor3 >0.6)\r\n{$name+".translateX =sensorInput.sensor3*" + ($j*2)}); - but I just don't know where.

Any help from anyone would be great fun! :)

Enjoy the rest of the "holidays"
OONAGH
spoons2101@hotmail.com

1 comment:

  1. you had it pretty close,
    just missing a few quotation marks
    you need to make the plane first.
    Also, this does it so its in 1 expression--have a look.

    int $num = 30;
    float $multi = 10;
    float $zFactor = 2;


    for($j=1; $j<=$num; $j++)
    {
    float $xMove = sin($j);
    float $yMove = ($j*.5);
    string $name = ("plane_"+$j);
    polyCube -n $name -ch on -o on -w $j -h $j -d 0.3;

    string $expressM = ($name+".translateZ=sensorInput.sensor1*" + ($j*10)+";\n");
    $expressM += ($name+".rotateZ=sensorInput.sensor2*" + (sin($j)*5)+";\n");
    $expressM += ("if (sensorInput.sensor3 >0.6)\n{"+$name+".translateX =sensorInput.sensor3*" + ($j*2)+";}");



    move -a ($xMove*$multi) ($yMove*$multi) ($j*$zFactor) $name;
    expression -s $expressM -ae true;
    }

    ReplyDelete