recursion splitPoly

 

//global vector[] $all;

global proc splitPoly(vector $tri[], int $depth, int $maxdepth)
{
//global vector $all;

vector $v0 = $tri[0];
vector $v1 = $tri[1];
vector $v2 = $tri[2];

float $aveX = ($v0.x + $v1.x + $v2.x)/3;
float $aveY = ($v0.y + $v1.y + $v2.y)/3;
float $aveZ = ($v0.z + $v1.z + $v2.z)/3;

vector $v3 = <<$aveX, $aveY, $aveZ >>;
vector $out[9] = {$v3, $v0, $v1,
$v3, $v1, $v2,
$v3, $v2, $v0};
vector $t0[] = {$v3, $v0, $v1};
vector $t1[] = {$v3, $v1, $v2};
vector $t2[] = {$v3, $v2, $v0};

if($depth < $maxdepth)
{
splitPoly($t0, $depth + 1, $maxdepth);
splitPoly($t1, $depth + 1, $maxdepth);
splitPoly($t2, $depth + 1, $maxdepth);
}
else
{
polyCreateFacet -ch on -tx 1 -s 1 -p ($v3.x) ($v3.y) ($v3.z) -p ($v0.x) ($v0.y) ($v0.z) -p ($v1.x) ($v1.y) ($v1.z);
polyCreateFacet -ch on -tx 1 -s 1 -p ($v3.x) ($v3.y) ($v3.z) -p ($v1.x) ($v1.y) ($v1.z) -p ($v2.x) ($v2.y) ($v2.z);
polyCreateFacet -ch on -tx 1 -s 1 -p ($v3.x) ($v3.y) ($v3.z) -p ($v2.x) ($v2.y) ($v2.z) -p ($v0.x) ($v0.y) ($v0.z);
}
}

//vector $tt[] = {pPlane1.vtx[4], pPlane1.vtx[0], pPlane1.vtx[1]};
vector $tt[] = {<<0, 0, 0>>, <<1, 0, 0>>, <<0, 0, 1>>};
print $tt;
print pPlane1.vtx[4];
splitPoly($tt, 0, 2)

 

You can use Poker face command to get the same effects

 

 

Image driven geometry layout

 

{
// create the file node and shader
select -all;
delete;

// __________ IMAGE MAPPING _________________________________
string $filenode = `createNode file`;
string $shader = `createNode lambert`;
string $path = "F:/TM/vsfx705/site.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"`;
// __________________________________________________________
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) < 0.3)
{
float $p[] = `pointOnSurface
-u $currU
-v $currV
$object[0]`;
vector $v1 = rand(-0.01, 0.01);
vector $v2 = rand(-0.01, 0.01);
vector $v3 = rand(-0.01, 0.01);
sphere -r 0.02;
move $p[0] $p[1] $p[2];
/* straight lines

curve -d 1 -p $p[0] $p[1] $p[2]
-p $p[0] ($p[1] + 0.1) $p[2]
-p $p[0] ($p[1] + 0.2) $p[2]
-p $p[0] ($p[1] + 0.3) $p[2];


curve -d 3 -p $p[0] $p[1] $p[2]
-p ($p[0] + $v1.x) ($p[1] + 0.02) ($p[2] + $v1.z)
-p ($p[0] + $v2.x) ($p[1] + 0.04) ($p[2] + $v2.z)
//-p ($p[0] + $v3.x) ($p[1] + 0.08) ($p[2] + $v3.z)
-p ($p[0] + $v3.x) ($p[1] + 0.1) ($p[2] + $v3.z);
*/
}
$index += 3;
$currV += $deltaV;
}
}
//defaultDirectionalLight(1, 1,1,1, "0", 0,0,0);
//select "curve*";

//displaySmoothness -pw 3;

}

 

 

 

Digital city, height controled by RGB

{
// create the file node and shader
select -all;
delete;

// __________ IMAGE MAPPING _________________________________
string $filenode = `createNode file`;
string $shader = `createNode lambert`;
string $path = "F:/TM/vsfx705/site4.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"`;
// __________________________________________________________
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) < 0.5)
{
float $p[] = `pointOnSurface
-u $currU
-v $currV
$object[0]`;
vector $v1 = rand(-0.01, 0.01);
vector $v2 = rand(-0.01, 0.01);
vector $v3 = rand(-0.01, 0.01);
//$hei = ($r + $g + $b);
//$hei2 = (0.01 * $hei);
float $hei = 0.3*(0.01 + $r + $g + $b);
polyCube -w 0.01 -h $hei -d 0.01;
move $p[0] $p[1] $p[2];
/* straight lines

curve -d 1 -p $p[0] $p[1] $p[2]
-p $p[0] ($p[1] + 0.1) $p[2]
-p $p[0] ($p[1] + 0.2) $p[2]
-p $p[0] ($p[1] + 0.3) $p[2];

curve -d 3 -p $p[0] $p[1] $p[2]
-p ($p[0] + $v1.x) ($p[1] + 0.02) ($p[2] + $v1.z)
-p ($p[0] + $v2.x) ($p[1] + 0.04) ($p[2] + $v2.z)
//-p ($p[0] + $v3.x) ($p[1] + 0.08) ($p[2] + $v3.z)
-p ($p[0] + $v3.x) ($p[1] + 0.1) ($p[2] + $v3.z);

*/

}
$index += 3;
$currV += $deltaV;
}
}
//defaultDirectionalLight(1, 1,1,1, "0", 0,0,0);
//select "curve*";

//displaySmoothness -pw 3;

}

Some test renderings

 

Extrude pattern

After delete edges and remove floating vertex. Triangulate will generatet interesting patterns.