General Category > ASL Scripts
flat planes : generate in rows and column
BOB_I_Ts:
Hello Anim8ors been long while since i have been involved with code or 3d modeling ,*shakes fist at MMO's for making me forget every thing
any way i thought i try refresh my mind on a8s
i want to create a simple flat plane with division attributes
just example of 3 x 3 grid and vertice # order
current script which attempted to do above failed in console
--- Code: ---#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;
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;
$grid.Open();
$index[$k] = $grid.AddPoint($p);
for $i = 1 to ($xd + 1) do {
$index[$k] = $grid.AddPoint($p);
for $j = 1 to $zd do {
$p.z = $p.z + $stepz;
$index[$k] = $grid.AddPoint($p);
$i = 1;
}
$p.x = $l * $stepx;
$l = + 1;
$p.z = 0;
}
/* temp code faces should fill first cell */
$grid.OpenFace(0, 4);
$grid.VertexN($index[0]);
$grid.VertexN($index[1]);
$grid.VertexN($index[5]);
$grid.VertexN($index[4]);
$grid.CloseFace();
$grid.Close();
--- End code ---
edit : fixed typos in code
How would we go about fixing this code !?.
BOB_I_Ts:
obvious i was thinking of the sequence in reverse
--- Code: ---#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();
--- End code ---
my next problem solving the mystery of the normals
seems that the faces break on the last row hmmm.....
headwax:
hmm sorry, can't help
just wanted to say it's good to see a legend returning ;)
BOB_I_Ts:
wow never be refereed as a legend thank you for the complement headwax your awesome
current code change in face generation code is as follows
--- Code: ---/* temp code faces should fill first cell */
int $face,$cut,$total;
$cut = 1;
$face = 1;
$total = $xd * $zd ;
if ($face < ($total + 1) ) {
for $face = 1 to ($total + 1) do {
$grid.OpenFace(0,0);
if ($face == (($cut * $xd) + $cut)) {
$cut = $cut + 1;
} else {
$grid.VertexN($face);
$grid.VertexN($face + 1);
$grid.VertexN($xd + ($face + 2));
$grid.VertexN($xd + ($face + 1));
$grid.CloseFace();
$face = $face + 1;
}
}
}
$grid.Close();
--- End code ---
Issue is even though if cut command removes the diagonal lines the face cells don't equal the total ! im missing something yet again meh
hihosilver:
Well if it helps I believe the same. Too bad I can't help you with coding either ;)
Good to see you back mate!
Navigation
[0] Message Index
[#] Next page
Go to full version