POV-Ray : Newsgroups : povray.advanced-users : Random starfield? : Re: Random starfield? Server Time
29 Jun 2024 02:01:09 EDT (-0400)
  Re: Random starfield?  
From: W0RLDBUILDER
Date: 30 Sep 2010 15:40:01
Message: <web.4ca4e77c46c817e0b8f6b920@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> W0RLDBUILDER <nomail@nomail> wrote:
> > I have an idea for a random starfield but I have no idea how I'm going to pull
> > it off. My idea is to start out with a sphere filled with emissive media, then
> > scatter hundreds of them around the scene out to a certain distance. The only
> > problem is, how am I supposed to place 500 sphere objects randomly using
> > rand.inc?
>
>   You don't need rand.inc for that. You can do something like:
>
> #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?


Post a reply to this message

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