POV-Ray : Newsgroups : povray.advanced-users : macro..... maby Server Time
27 Nov 2024 00:39:06 EST (-0500)
  macro..... maby (Message 1 to 7 of 7)  
From: Nobot
Subject: macro..... maby
Date: 30 May 1999 18:44:38
Message: <3751B117.EB9194DE@powersurfr.com>
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


Post a reply to this message

From: Jason Dinger
Subject: Re: macro..... maby
Date: 31 May 1999 01:07:03
Message: <37520B1D.E7FE6496@hotmail.com>
I don't know of any tutorials on #macros, but the idea you have definately
sounds feasable. Give me a day or so and I'll see if I can come up with a
macro and tutorial with it to create your cylinders.

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


Post a reply to this message

From: Jason Dinger
Subject: Re: macro..... maby
Date: 31 May 1999 01:07:24
Message: <37520B31.1CB91659@hotmail.com>
I don't know of any tutorials on #macros, but the idea you have definately
sounds feasable. Give me a day or so and I'll see if I can come up with a
macro and tutorial with it to create your cylinders.

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


Post a reply to this message

From: Jason Dinger
Subject: Re: macro..... maby
Date: 31 May 1999 01:26:20
Message: <37520FA2.B324D7C2@hotmail.com>
my server was giving me a headache and I wasn't sure if it went through the
first time or not....


Post a reply to this message

From: Nobot
Subject: Re: macro..... maby
Date: 31 May 1999 01:42:52
Message: <37521319.AB97CC8A@powersurfr.com>
no problem. it shouldn't be cylender only so ppl can use it with any object
even a mesh or somthing

Jason Dinger wrote:

> my server was giving me a headache and I wasn't sure if it went through the
> first time or not....


Post a reply to this message

From: Nieminen Mika
Subject: Re: macro..... maby
Date: 31 May 1999 12:36:36
Message: <3752ac84.0@news.povray.org>
Nobot <vip### [at] powersurfrcom> 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

  You don't need macros for this. A single #while loop will do it.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Spider
Subject: Re: macro..... maby
Date: 31 May 1999 18:11:36
Message: <3752EE9D.6CC16FF9@bahnhof.se>
#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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.