|
|
Alain <aze### [at] qwertyorg> wrote:
> > Warp<war### [at] tagpovrayorg> wrote:
> >> W0RLDBUILDER<nomail@nomail> wrote:
> >>>> #declare Star = /* your star object here */;
> >>>>
> >>>> #declare Amount = 500;
> >>>> #declare Seed = seed(0); // Try integer values other than 0 for other
> >>>> // distributions
> >>>> #declare MinExtent =<-100, -100, -100>;
> >>>> #declare MaxExtent =<100, 100, 100>; // Modify as desired
> >>>>
> >>>> #declare Index = 0;
> >>>> #while(Index< Amount)
> >>>> object
> >>>> { Star
> >>>> #declare RandVector =<rand(Seed), rand(Seed), rand(Seed)>;
> >>>> translate MinExtent + (MaxExtent - MinExtent) * RandVector
> >>>> }
> >>>> #declare Index = Index + 1;
> >>>> #end
> >>>>
> >>>> --
> >>>> - Warp
> >>
> >>> Thanks. Would that work if I copy/pasted it several times for different types of
> >>> stars?
> >>
> >> Better to use a macro for that, like:
> >>
> >> #macro CreateStars(StarObject, Amount, Seed)
> >> #local MinExtent =<-100, -100, -100>;
> >> #local MaxExtent =<100, 100, 100>; // Modify as desired
> >>
> >> #local Index = 0;
> >> #while(Index< Amount)
> >> object
> >> { StarObject
> >> #declare RandVector =<rand(Seed), rand(Seed), rand(Seed)>;
> >> translate MinExtent + (MaxExtent - MinExtent) * RandVector
> >> }
> >> #local Index = Index + 1;
> >> #end
> >> #end
> >>
> >> #declare Seed = seed(0);
> >> CreateStars(Star1, 100, Seed)
> >> CreateStars(Star2, 100, Seed)
> >> CreateStars(Star3, 100, Seed)
> >>
> >> --
> >> - Warp
> >
> > I can't get that to work. I know I'm doing something wrong here. It's probably
> > not a good idea to drop a macro on top of a semi-n00bish casual user who just
> > wants to place some random stars. :-P
> >
> >
>
> You only need to copy the macro definition and the macro calls into your
> scene. Make sure that the calls are placed after the macro definition.
>
> The only thing missing here, is the definitions for "Star1", "Star2" and
> "Star3".
>
> You can:
> - #declare all star objects before the calls to CreateStars()
> - #declare the star objects before each individual call. In this case,
> you can reuse the same name.
> - Define the star object inside the call itself.
>
> In the lase case, you can use this:
>
> CreateStars(sphere{0,0.1 pigment rgb<1,0.5,0.2>finish{ambient 1 diffuse
> 0}}, 100, Seed)
>
>
>
> Alain
Never mind, I got it to work with the first method in this thread. The stars I'm
using are in an include file, stars.inc. My include file #declares all the star
objects I'm using. I also managed to get a nebula.
Post a reply to this message
|
|