Building structure generator

//capture the current selected object and put it into a variable

string $myobject[] = `ls -sl`;
print ("the quary name is" + $myobject[0]);

//call the mel resource script to caculate average normal

//source "M:/vsfx705/mel/VectorUtils.mel";

//call the mel resource to add renderman curve width
//source "M:/vsfx705/mel/RmanUtils.mel";

int $num[] = `polyEvaluate -v $myobject[0]`;
print("number of vertices is " + $num[0] + "\n");

//create a circle profile for extrusion
circle -n "profile" -r 0.02 -nr 0 1 0 ;

int $n;
for($n = 0; $n < $num[0]; $n++)
{
$item = $myobject[0] + ".vtx[" + $n + "]";
$pnt = `pointPosition -world $item`;

//$pnt = `pointPosition -world $myobject[0].vtx[$n]`;

//$norm = `polyNormalPerVertex -q -xyz $item`;

//$norm = `polyNormalPerVertex -q -xyz $myobject[0].vtx[$n]`;
$x = $pnt[0];
$y = $pnt[1];
$z = $pnt[2];
//vector $v = doAverage($norm);
$cname = `curve -d 1 -p $x $y $z
-p $x 0 $z`;

extrude -ch true -rn false -po 0 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 profile $cname ;

//call riCurve to point to renderman width in RmanUtils.mel
//riCurve($cname, 0.05);

//create a small ball and snap it to the vertext point
sphere -radius 0.05;
move $x $y $z;
}

Roof Pattern generator

//this script will use a poly model (mesh surface) to generate the structure beams. You have to use polygon model. select it first and run the script-------

//select faces

string $myobject[] = `ls -sl`;
print ("the quary name is" + $myobject[0]);


$item = $myobject[0] + ".f[0:9999]";
select -cl;

//poker face to add details. It is a better way than triangulate

//polyPoke -ws 1 -tx 0 -ty 0 -tz 0 -ltx 0 -lty 0 -ltz 0 -ch 1 $myobject[0];


select -r $item;

//extrude by scale

//select -r $myobject[0].f[0:9999] ;
polyExtrudeFacet -ch 1 -kft 0 -lsx 0.9 -lsy 0.9 -lsz 0.9;
doDelete;

//extrude again

select -r $item ;
polyExtrudeFacet -ch 1 -kft 1 -tx 0 -ty 0.01 -tz 0;


Add these two scripts together.

 

Beam generator

//this script will use a poly model (mesh surface) to generate the structure beams. You have to use polygon model. select it first and run the script-------

//select faces

string $myobject[] = `ls -sl`;

print ("the quary name is" + $myobject[0]);

$item = $myobject[0] + ".f[0:9999]";

select -cl;

select -r $item;

//extrude along y to get the height, double faces were made

polyExtrudeFacet -ch 1 -kft 0 -t 0 1 0;

doDelete;

select -r $item ;

//triangulate the beam into a diagonal structure

polyTriangulate -ch 1 $item ;

//can also consider to use poker face to add details. It is a better way than triangulate

//polyPoke -ws 1 -tx 0 -ty 0 -tz 0 -ltx 0 -lty 0 -ltz 0 -ch 1 $myobject[0];

 

//create the hole inside the beams

polyExtrudeFacet -ch 1 -kft 0 -lsx 0.8 -lsy 0.8 -lsz 0.8;

doDelete;

//extrude the beam to create thickness

select -r $item ;

polyExtrudeFacet -ch 1 -kft 0 -ltx 0 -lty 0 -ltz 0.02;

Branch cap generator 1.0

//this is the script allow you create a branch at the bottom of each vertex, sort of tree structure to tranfer the load. combined with other script to generate complex roof structure.

string $myobject[] = `ls -sl`;

print ("the quary name is" + $myobject[0]);

int $num[] = `polyEvaluate -v $myobject[0]`;

print("number of vertices is " + $num[0] + "\n");

$item = $myobject[0] + ".vtx[0:" + $num[0]+"]";

select -cl;

select -r $item;

//extrude vertex to get the pyramid shap

polyExtrudeVertex -ch 1 -w 0.5 -l 0 -d 2;

//use one division can get a simpler cap.

//polyExtrudeVertex -ch 1 -w 0.5 -l 0 -d 1;

//move all the original vertex -1

move -r 0 -1 0;

Branch cap generator V2.0 (umbrella)

//this is the script also create a tree branch at the bottom of each vertex, just have more branches, with an umbrella shape between each. Combined with other script to generate complex roof structure.

string $myobject[] = `ls -sl`;

print ("the quary name is" + $myobject[0]);

int $num[] = `polyEvaluate -v $myobject[0]`;

print("number of vertices is " + $num[0] + "\n");

$item = $myobject[0] + ".vtx[0:" + $num[0]+"]";

select -cl;

//can also consider to use poker face to add details. It is a better way than triangulate

polyPoke -ws 1 -tx 0 -ty 0 -tz 0 -ltx 0 -lty 0 -ltz 0.2 -ch 1 $myobject[0];

select -r $item;

//extrude vertex to get the pyramid shap

//polyExtrudeVertex -ch 1 -w 0.5 -l 0 -d 2;

//use one division can get a simpler cap.

polyExtrudeVertex -ch 1 -w 0.25 -l 0 -d 1;

//move all the original vertex -1

move -r 0 -1 0;

polyTriangulate -ch 1 $myobject[0];

Branch cap generator 3 .0 (binary tree)

//this is the script allow you create a more depth branch at the bottom of each vertex, sort of binary tree structure to transfer the load. combined with other script to generate complex roof structure.

string $myobject[] = `ls -sl`;

print ("the quary name is" + $myobject[0]);

//triangulate will increte the sides of tree

//polyTriangulate -ch 1 $myobject[0] ;

int $num[] = `polyEvaluate -v $myobject[0]`;

print("number of vertices is " + $num[0] + "\n");

$item = $myobject[0] + ".vtx[0:" + $num[0]+"]";

select -cl;

select -r $item;

//extrude vertex to get the pyramid shap

//polyExtrudeVertex -ch 1 -w 0.5 -l 0 -d 2;

//use one division can get a simpler cap.

polyExtrudeVertex -ch 1 -w 0.5 -l 0 -d 1;

//move all the original vertex -1

move -r 0 -1 0;

//polyListComponentConversion -fv -tf;

//polyListComponentConversion -fv –tf $item ;

select -r $item;

$faces =`polyListComponentConversion -fv -tf`;

select -r $faces;

polyPoke -ws 1 -tx 0 -ty 0 -tz 0 -ltx 0 -lty 0 -ltz 0 -ch 1 $faces;

//repeat to create more branches near the bottom, could be a loop

/*

select -r $item;

$faces =`polyListComponentConversion -fv -tf`;

select -r $faces;

polyPoke -ws 1 -tx 0 -ty 0 -tz 0 -ltx 0 -lty 0 -ltz 0 -ch 1 $faces;

*/