//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); } }