/************************************************************ Esporta i file di Maya in Visual Basic, creando direttamente i comandi MakeVertex. Include solamente le normali. Funziona solo anche sulla Personal Learning Edition, ma e' meno preciso. ************************************************************/ global proc VBDXexport() { window -title "Export to Visual Basic" -w 400 -h 500; columnLayout -adjustableColumn true; button -l "Convert" -command "exportVertexToVBinField()"; scrollField -editable true -w 400 -h 300 outputExport; showWindow; } global proc exportVertexToVBinField() { float $x, $y, $z, $fidelity, $coords[], $normal[]; int $triNum[], $i, $totalNumF, $totalNumV, $j, $k, $l, $totalObjects, $oldNum, $newNum, $nextIdx; int $vertexNum[], $mode, $RealVertexPerFace[], $NextRealVertex; int $found, $nDiffN, $totDiffV; float $nX[], $nY[], $nZ[]; int $nV[]; string $object, $strs[], $selection[], $str, $loc, $selToDel, $fIdx[], $tmp1[], $tmp2[]; vector $n0, $n1, $n2; vector $vt[], $nrm[]; $fidelity = 0.001; $selection = `ls -sl -fl`; $totalObjects = size($selection); textField -e -tx "" outputExport; for($j = 0; $j < $totalObjects; $j ++) { // process edges $object = $selection[$j]; polyTriangulate $object; select $object; $vertexNum = `polyEvaluate -v`; $totalNumV = $vertexNum[0]; $triNum = `polyEvaluate -f`; $totalNumF = $triNum[0]; $totDiffV = 0; for($i = 0; $i < $totalNumV; $i++) { $str = $object+".vtx["+$i+"]"; select $str; $coords = `pointPosition`; ConvertSelectionToVertexFaces; $fIdx = `ls -sl -fl`; $nDiffN = 0; for($k = 0; $k < size($fIdx); $k++) { $str = $fIdx[$k]; select $str; $normal = `polyNormalPerVertex -q -xyz`; tokenize($fIdx[$k], "[", $tmp1); tokenize($tmp1[2], "]", $tmp2); ConvertSelectionToUVs; $PUV = `polyEditUV -q`; $found = false; for($l = 0; $l < $nDiffN; $l++) { if(($normal[0]==$nX[$l]) && ($normal[1]==$nY[$l]) && ($normal[2]==$nZ[$l])) { $found = true; break; } } if($found) { $RealVertexPerFace[int($tmp2[0]) * $totalNumV + $i] = $nV[$l]; } else { $nX[$nDiffN] = $normal[0]; $nY[$nDiffN] = $normal[1]; $nZ[$nDiffN] = $normal[2]; $nV[$nDiffN] = $totDiffV; $RealVertexPerFace[int($tmp2[0]) * $totalNumV + $i] = $totDiffV; $nDiffN++; $totDiffV++; } } for($k = 0; $k < $nDiffN; $k++) { textField -e -ip 0 -it ("V("+$nV[$k]+")=MakeVertex("+$coords[0]+","+ $coords[1]+","+$coords[2]+ "," + $nX[$k] + "," + $nY[$k] + "," + $nZ[$k]+")\n") outputExport; $vt[size($vt)] = <<$coords[0], $coords[1], $coords[2]>>; $nrm[size($nrm)] = <<$nX[$k], $nY[$k], $nZ[$k]>>; } } $nextIdx = 0; for($i = 0; $i < $totalNumF; $i++) { $str = $object+".f["+$i+"]"; select $str; ConvertSelectionToVertices; $strs = `ls -sl -fl`; for($k = 0; $k < size($strs); $k++) { tokenize($strs[$k], "[", $tmp1); tokenize($tmp1[1], "]", $tmp2); $fIdx[$k] = $tmp2[0]; } { vector $v1, $v2, $cps; float $Direct; string $tmpSi; $v1 = $vt[$RealVertexPerFace[$i * $totalNumV + int($fIdx[0])]] - $vt[$RealVertexPerFace[$i * $totalNumV + int($fIdx[1])]]; $v2 = $vt[$RealVertexPerFace[$i * $totalNumV + int($fIdx[1])]] - $vt[$RealVertexPerFace[$i * $totalNumV + int($fIdx[2])]]; $cps = $v1 ^ $v2; $Direct = sign($cps * ($nrm[$RealVertexPerFace[$i * $totalNumV + int($fIdx[0])]] + $nrm[$RealVertexPerFace[$i * $totalNumV + int($fIdx[1])]] + $nrm[$RealVertexPerFace[$i * $totalNumV + int($fIdx[2])]])); if($Direct<0) { $tmpSi=$fIdx[0]; $fIdx[0]=$fIdx[2]; $fIdx[2]=$tmpSi; } ///print($cps + " " + $nrm[$RealVertexPerFace[$i * $totalNumV + int($fIdx[1])]] + " " + $Direct); } textField -e -ip 0 -it ("I("+$nextIdx+")="+$RealVertexPerFace[$i * $totalNumV + int($fIdx[0])]+ ": I("+string($nextIdx+1)+")="+$RealVertexPerFace[$i * $totalNumV + int($fIdx[1])]+ ": I("+string($nextIdx+2)+")="+$RealVertexPerFace[$i * $totalNumV + int($fIdx[2])]+"\n") outputExport; $nextIdx+=3; } select $object; textField -e -ip 1 -it ("ReDim V("+$totDiffV+"), I("+$nextIdx+")\n") outputExport; } }