GetNormalAtVTX MEL

From scripting
Jump to: navigation, search
global proc vector getNormalAtVTX(int $InputCVNum, string $ObjName) {
// Nick Pisca 2011, 0001d
// NOTE:  this isn't really accurate, but works for quick solutions.
    //int $InputCVNum = 1259; string $ObjName = "pCone1";
    float $PL[] = `polyNormalPerVertex -q -xyz ($ObjName + ".vtx[" + $InputCVNum + "]")`;
    vector $SumVec = <<0,0,0>>;
    int $PtCt = size($PL)/3;
    
    for ($x=0;$x<$PtCt;$x++) {
        vector $Cvec = <<$PL[((3*$x) + 0)], $PL[((3*$x) + 1)], $PL[((3*$x) + 2)]>>;
        $SumVec = $SumVec + $Cvec;
    }
    
    $SumVec = $SumVec / $PtCt;
    return $SumVec;
}



More information on polygon vertex manipulation, read pages 113-116 in YSYT.