|
|
#declare maxNum = 1500; //1 500 000 is requested... *sigh* :)
#declare maxX = 10; //how many units from 0 in X ?
#declare maxZ = 10; //how many units from 0 in Z ?
#declare maxY = 2; //length... "height" of the cylinders, max Y value.
#declare inS = seed(15); //Random seed
#declare radii = 0.1; //Radius.
#declare N = maxNum;
union {
#while(N>0)
cylinder {
#declare X = rand(inS)*maxX;
#declare Z = rand(inS)*maxZ;
#declare Y = rand(inS)*maxY;
<X,0,Z>, //Bottom
<X,Y,Z>, //Top
radii
}
#declare N = N - 1;
#end
pigment {
colour rgb <0,1,0>
}
}
This will place maxN cylinders in the area 0..maxX,0,0..maxZ
To rotate theese, we need to move the "top" of theese cylinders a
random distance in X..Z from the bottom (Note, I don't intend to use rotate, but
instead move the top. to use a rotate would only require a random movement in
one direction, but also a rotate after that. the same results.. almost.)
Change to this:
#declare maxNum = 1500; //1 500 000 is requested... *sigh* :)
#declare maxX = 10; //how many units from 0 in X ?
#declare maxZ = 10; //how many units from 0 in Z ?
#declare maxY = 2; //length... "height" of the cylinders, max Y value.
#declare maxTop = 0.5; //Max movement of the top from the center.
#declare inS = seed(15); //Random seed
#declare radii = 0.1; //Radius.
#declare N = maxNum;
union {
#while(N>0)
cylinder {
#declare X = rand(inS)*maxX;
#declare Z = rand(inS)*maxZ;
#declare Y = rand(inS)*maxY;
/*from X, rand returns from 0..1, -0.5 will give between -0.5 to 0.5. multiply
with max distance.*/
#declare tX = X + (rand(inS)-0.5)*maxTop;
#declare tZ = Z + (rand(inS)-0.5)*maxTop;
<X,0,Z>, //Bottom
<tX,Y,tZ>, //Top
radii
}
#declare N = N - 1;
#end
pigment {
colour rgb <0,1,0>
}
}
Well. I don't use any #macro to get the rand(inS)-0.5 number, although it would
be an excellent candidate. Why? A _big_ speed issue in POV code. If you have
anything that will be repeated more than a few times, try to get rid of all
#macro calls from inside it.
other speed issues.
tX and tZ should be placed within the <> instead of #declared.
same for Y
well, all code from memory/experience.
should work, or at least should give you an idea of how to make it work :)
General POV desing musings.
Start with the code (simple)
#declare N = 10;
#while(N>0)
sphere { <N,N,N>,0.3 pigment{colour rgb N/10}
#declare N = N - 1;
#end
well, the 10 is needed in more than 1 place, throw it into a variable.
maxN is my standard.
when there is something needed more than once, throw it in a variable or a
#macro.
don't care for speed until the desired result is done.
Then, optimize all macros. get rid of unnecessary #declares (not max values or
so, but things as:
#declare T = 10*N*115;
#declare Y = T * N*N;
#undef T
This would then become :
#declare Y = 1150*N*N*N
and so on.
if you are using anything as maxX/maxN several times, or 10/N several times
inside a loop, evaluate this once and place in a variable.
#declare _10N = 10/N; or something like that.
Hmm, Why am I writing this? Badly written, unstructured, poor examples, no code
to show with. Sheesh. I'm a bad boy.. Very bad.
If I get the time I might throw a tutorial together and post it.. but then, I'm
moveing, gettting a job and beeing disconnected, so I'm not so sure...
over and out.
Nobot wrote:
>
> where can i get a tutorial on macros my reader don't let me search the
> group for "macro" i'd like one that will let me make 1,500,000 cylinders
> at random points on the X and Z axis and rotated at a random on the
> y.... kinda like grass
--
//Spider -- [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
And the meek'll inherit what they damn well please
Get ahead, go figure, go ahead and pull the trigger
Everything under the gun
--"Sisters Of Mercy" -- "Under The Gun"
Post a reply to this message
|
|