obvious i was thinking of the sequence in reverse
#plugin("object", "mesh", "gridtest");
#parameter("x division", int, 3, 1, 10);
#parameter("z division", int, 3, 1, 10);
#parameter("X scale", float, 40, 2, 1000.0,scale,scale_x);
#parameter("z scale", float, 40, 2, 1000.0,scale,scale_z);
#return($grid);
#button(24, 24, 2, 0x0000000000, 0x0000000000, 0x0000000000, 0x0000000000, 0x0000001800,
0x0000001800, 0x0000000000, 0x0000000000, 0x0000001800, 0x0000001800, 0x0000001800,
0x0000001800, 0x0000001800, 0x0000001800, 0x0000001800, 0x0000001800, 0x0000001800,
0x0000001800, 0x0000001800, 0x0000001800, 0x0000001800, 0x0000000000, 0x0000000000,
0x0000000000);
shape $grid;
float $xs,$zs,$stepx,$stepz;
int $xd,$zd,$index[201],$i,$j,$k,$l,$face,$total;
point3 $p;
$xd = parameter("x division");
$zd = parameter("z division");
$xs = parameter("X scale");
$zs = parameter("z scale");
$stepx = $xs/$xd;
$stepz = $zs/$zd;
$l = 1;
$total = $xd * $zd;
$face = 1;
$grid.Open();
$index[$k] = $grid.AddPoint($p);
for $i = 1 to ($zd + 1) do {
$index[$k] = $grid.AddPoint($p);
for $j = 1 to $xd do {
$p.x = $p.x + $stepx;
$index[$k] = $grid.AddPoint($p);
$i = 1;
}
$p.z = $l * $stepz;
$l = $l + 1;
$p.x = 0;
}
/*draw face's start here*/
if ($face < $total) {
for $face = 1 to $total do {
$grid.OpenFace(0,4);
$grid.VertexN($face);
$grid.VertexN($face + 1);
$grid.VertexN($xd + ($face + 2));
$grid.VertexN($xd + ($face + 1));
$grid.CloseFace();
$face = $face + 1;
}
}
$grid.Close();
my next problem solving the mystery of the normals
seems that the faces break on the last row hmmm.....