POV-Ray : Newsgroups : povray.advanced-users : Random starfield? : Re: Random starfield? Server Time
29 Jun 2024 02:18:39 EDT (-0400)
  Re: Random starfield?  
From: W0RLDBUILDER
Date: 1 Oct 2010 11:05:01
Message: <web.4ca5f87d46c817e0b8f6b920@news.povray.org>
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


Post a reply to this message

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