|
![](/i/fill.gif) |
> Warp<war### [at] tag povray org> 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?
>
>
Yes, just don't copy this statement, or change the value:
#declare Seed = seed(0);
If you copy it, you'll reinitialise the random stream and all new
objects will land in exactly the same locations as the previous ones.
Alain
Post a reply to this message
|
![](/i/fill.gif) |