29 January 2011

Mechanical Threads

[EN]
This is a little demonstration of mechanical thread rigs for two jobs in VetorZero - Lobo - Animatorio. It uses expressions in order to run the thread without slip. The main concept for this process is:
  • create a cv circle curve to be your path;
  • calculate the number of thread pieces, taking the cvCircle lenght divided by the piece size
    (it will be your $nThread variable);
  • create some attributes to control your expression like in dpWeel to automatic rotation by translation.
  • attache your pieces to the cvCircle as motionPath;
  • break the uValue from motionPath to connect the expression controling the offset of them.
Bellow the resume of the expression... I hope you enjoy :) Thanks.

[PT]
Essa é uma pequena demonstração de rigs de esteiras mecanicas de dois trabalhos da VetorZero - Lobo - Animatorio. Ele usa expressões para rodar a esteira sem derrapar. O pensamento principal do processo é:
  • crie uma curva de circulo para se seu path;
  • calcule o numero de peças, pegando o comprimento do circulo dividido pelo tamanho da peça (essa sera sua variavel $nThread);
  • crie alguns atributos para controlar sua expressao como em dpWeel para automatizar a rotação pela translação;
  • anexe suas peças no circulo como motionPath;
  • quebre o uValue do motionPath para conectar a expressão controlando os offsets deles.
Abaixo um resumo da expressão... espero que gostem :) Obrigado.

// declare variables:
float $l_autoRot, $l_startFrame, $l_scaling, $l_cFWhel, $l_cFVelo, $l_wRadius, $l_dist, $l_Pi, $l_displacement, $l_direction, $l_treadDisplacement, $l_treadDist;
float $l_nTread = 0.01639344262;
vector $l_lastPosition;

// reset rotations when in frame 1 or startFrame:
$l_startFrame = moveALL_ctrl.startFrame;
if ( frame == 1 || frame <= $l_startFrame )
{
    moveALL_ctrl.lLastPositionX = moveALL_ctrl.translateX;
    moveALL_ctrl.lLastPositionY = moveALL_ctrl.translateY;
    moveALL_ctrl.lLastPositionZ = moveALL_ctrl.translateZ;
    $l_lastPosition = << 0, 0, 0 >>;
   
    l_tread_motPath0.uValue = 0*$l_nTread;
    l_tread_motPath1.uValue = 1*$l_nTread;
    l_tread_motPath2.uValue = 2*$l_nTread;
    //...
    //l_tread_motPath60.uValue = 60*$l_nTread;
};

// verify if the control was moved in order to get its relative distance:
$l_lastPosition = << moveALL_ctrl.lLastPositionX, moveALL_ctrl.lLastPositionY, moveALL_ctrl.lLastPositionZ >>;
vector $l_position = << moveALL_ctrl.translateX, moveALL_ctrl.translateY, moveALL_ctrl.translateZ >>;
float $l_distance;
if( $l_lastPosition != $l_position ) {
    $l_distance = mag( $l_position - $l_lastPosition );
    moveALL_ctrl.lLastPositionX = moveALL_ctrl.translateX;
    moveALL_ctrl.lLastPositionY = moveALL_ctrl.translateY;
    moveALL_ctrl.lLastPositionZ = moveALL_ctrl.translateZ;
    $l_lastPosition = << moveALL_ctrl.translateX, moveALL_ctrl.translateY, moveALL_ctrl.translateZ >>;
} else {
    $l_distance = 0;
};

// get attributes for calculus:
$l_wRadius = moveALL_ctrl.whelRadius;
$l_Pi = 3.1415926536;
$l_displacement = - (($l_distance/(2 * $l_Pi * $l_wRadius)) * 360);
$l_treadDisplacement = - (($l_distance/(2.45 * $l_Pi * $l_wRadius)) * 360);

// get attributes from control:
$l_autoRot = moveALL_ctrl.autoRotateWhels;
$l_cFWhel = moveALL_ctrl.constantFront;
$l_cFVelo = moveALL_ctrl.constFrontVelocity;
$l_scaling = moveALL_ctrl.scaling;
$l_treadDist = (($l_cFVelo * $l_cFWhel) - ($l_treadDisplacement/$l_scaling))/($l_Pi * 360);

// apply rotation by expression:
if ($l_autoRot == 1)
{
    $l_direction = moveALL_ctrl.direction;
    if ($l_direction == 0)
    {
        l_tread_motPath0.uValue += $l_treadDist;
        if( l_tread_motPath0.uValue > 1 ) l_tread_motPath0.uValue -= 1;
        l_tread_motPath1.uValue += $l_treadDist;
        if( l_tread_motPath1.uValue > 1 ) l_tread_motPath1.uValue -= 1;
        l_tread_motPath2.uValue += $l_treadDist;
        if( l_tread_motPath2.uValue > 1 ) l_tread_motPath2.uValue -= 1;
        //...
        //l_tread_motPath60.uValue += $l_treadDist;
        //if( l_tread_motPath60.uValue > 1 ) l_tread_motPath60.uValue -= 1;
    }
    else
    {
        l_tread_motPath0.uValue -= $l_treadDist;
        if( l_tread_motPath0.uValue < 0 ) l_tread_motPath0.uValue += 1;
        l_tread_motPath1.uValue -= $l_treadDist;
        if( l_tread_motPath1.uValue < 0 ) l_tread_motPath1.uValue += 1;
        l_tread_motPath2.uValue -= $l_treadDist;
        if( l_tread_motPath2.uValue < 0 ) l_tread_motPath2.uValue += 1;
        //...
        //l_tread_motPath60.uValue -= $l_treadDist;
        //if( l_tread_motPath60.uValue < 0 ) l_tread_motPath60.uValue += 1;
    };
};


Mechanical Threads from Danilo Pinheiro on Vimeo.

0 comments: