{ // create the file node and shader //select -all; //delete; // __________ IMAGE MAPPING _________________________________ string $filenode = `createNode file`; string $shader = `createNode lambert`; string $path = "F:/TM/vsfx705/texture/city2.jpg"; // connect the nodes connectAttr ($filenode + ".outColor") ($shader + ".color"); // insert the image path in the file node string $cropmap = $path; setAttr -type "string" ($filenode + ".fileTextureName") $cropmap; // assign the shader to an object string $object[] = `nurbsPlane -ax 0 1 0 -name "nurbsPlane1"`; //string $object[] = `sphere -name "nurbsPlane1"`; // __________________________________________________________ select -r $object[0]; hyperShade -assign $shader; //DisplayShadedAndTextured; int $u, $v, $nu = 50, $nv = 50; // steps in u and v float $minU = 0, $minV = 0, // u/v - start and ending $maxU = 1, $maxV = 1; // the surface - slightly less than 0 to 1 // Grab all our texture map samples float $rgb[] = `colorAtPoint -o RGB -su $nu -sv $nv -mu $minU -mv $minV -xu $maxU -xv $maxV $filenode`; float $deltaU = ($maxU - $minU)/($nu - 1); // step size in u float $deltaV = ($maxV - $minV)/($nv - 1); // step size in v float $currU, $currV; int $index = 0; $currU = $minU; //sphere -r 0.05 -n sph; for($n = 0; $n < $nu; $n++) { $currU += $deltaU; $currV = $minV; for($i = 0; $i < $nv; $i++) { float $r = $rgb[$index]; float $g = $rgb[$index + 1]; float $b = $rgb[$index + 2]; print($r + " " + $g + " " + $b + "\n"); if( ($r + $g + $b) < 2) { float $p[] = `pointOnSurface -u $currU -v $currV $object[0]`; string $listB[]={"building01", "building02", "building03"}; string $listA[]={"building04", "building05", "building06"}; string $listC[]={"building01", "building02", "building03", "building04", "building05", "building06"}; //-----------R value. building A--commercial if( $r > 0.8 ) { int $number = rand(0,3); string $building = $listA[$number]; select $building; instance $building; scale -r (rand(1, 2)) (rand(1, 2)) 1; move $p[0] $p[1] $p[2]; int $rottime = rand(0,4); rotate -r 0 (90*$rottime) 0; } //-----------B value. building B--residential if($g > 0.8) { int $number = rand(0,3); string $building = $listB[$number]; select $building; instance $building; scale -r (rand(1, 3)) (rand(1, 2)) (rand(1, 2)); move $p[0] $p[1] $p[2]; int $rottime = rand(0,4); rotate -r 0 (90*$rottime) 0; } //-----------G value. building C--45 degree diagonal if($b > 0.8) { int $number = rand(0,6); string $building = $listC[$number]; select $building; instance $building; scale -r (rand(2, 3)) (rand(1, 2)) 1; move $p[0] $p[1] $p[2]; int $rottime = rand(0,4); rotate -r 0 (45+(90*$rottime)) 0; //rotate -r 0 45 0; } } $index += 3; $currV += $deltaV; } } }