PDA

View Full Version : mel script and math for honeycomb image sal2



ratboy
02-12-2008, 09:37 AM
mel script and math for honeycomb image sal2

Greetings all

I’m trying to adapt this mel script that was given to me to use hexagons so when I deform it all the edges connect like this http://www.youtube.com/watch?v=-nao3-YnsMo I know it’s a problem with my math but I’m not sure how to fix it so all the hexagons are connected when they are created with the mel script.


tia sal2

//==============================================================
proc drawPlane (float $x1,float $z1){
polyPrism -l 0 -w 1 -ns 6 -sh 1 -sc 0 -ax 0 1 0 -cuv 3 -ch 1; //create with one face
move -r $x1 0 $z1; //diamond
rotate -r -os 0 0 0;
}
//====================
proc diagonalPlanes(){
float $x, $z, $len, $max, $diag;
$len = 2 * sind(45.0);
$diag = 4 * sind(45.0);
$max = 4;
//Draw the outer shell
for ($x = 0; $x < $max; $x++ ){
for ($z = 0; $z < $max; $z++ ){
drawPlane($x*$diag, $z*$diag);
}
}
//Draw the inner shell: max = N-1, and offset = .707
//$max--; // draw 1 less row and column
for ($x = 0; $x < ($max); $x++ ){
for ($z = 0; $z < ($max); $z++ ){
drawPlane( ($x*$diag+$len), ($z*$diag+$len));
// with an offset added of: .707 0 .707
}
}
}

diagonalPlanes();

chopsuey
02-12-2008, 12:14 PM
hm...you work with a hexagon, so the main problem in the script is that you can't use sin 45.
Here is modified version with sin 30 / sin 60 >>


//==============================================================
proc drawPlane (float $x1,float $z1){
polyPrism -l 0 -w 1 -ns 6 -sh 1 -sc 0 -ax 0 1 0 -cuv 3 -ch 1; //create with one face
move -r $x1 0 $z1; //diamond
rotate -r -os 0 0 0;
}

//====================
proc diagonalPlanes(){
float $x, $z, $len, $max, $diag;
$lenX = sind(30.0);
$lenZ = sind(60.0);

$max = 4;
//Draw the outer shell
for ($x = 0; $x < ($max*3); $x = $x+3 ){
for ($z = 0; $z < $max; $z++ ){
drawPlane($x*2*$lenX, $z*2*$lenZ);
}
}
select -ado;
duplicate;
move -r (1 + $lenX) 0 $lenZ;
select -cl;
}

diagonalPlanes();

ratboy
02-12-2008, 12:20 PM
Thanks that did it :-)