BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Friday, May 21, 2010

Flood uncolored vertexes with white

If you working in games, baking occlusion, or just messing with vertex coloring in general a problem occurs when you try to combine two meshes when not all the vertexes have a color assigned to them. It will scramble all your colors so this little code snippet will change any of them that don't have color (or black ones I knooowww, it's a quick fix) with white, then allowing you to combine objects with no coloring with ones that have it.

PolySelectConvert 3;
$s = `ls -fl -sl`;

for ($i=0;$i<size($s);$i++) {
float $colorR[] = `polyColorPerVertex -q -colorR $s[$i]`;
float $colorG[] = `polyColorPerVertex -q -colorG $s[$i]`;
float $colorB[] = `polyColorPerVertex -q -colorB $s[$i]`;

if ($colorR[0] == 0 && $colorG[0] == 0 && $colorB[0] == 0) {
polyColorPerVertex -colorR 1 $s[$i];
polyColorPerVertex -colorG 1 $s[$i];
polyColorPerVertex -colorB 1 $s[$i];
}
int $num = size($s) - $i;
print ($num+" left\n");
}
print "DONE!";

0 comments: