POV-Ray : Newsgroups : povray.advanced-users : Random starfield? : Re: Random starfield? Server Time
29 Jun 2024 02:02:08 EDT (-0400)
  Re: Random starfield?  
From: Warp
Date: 30 Sep 2010 07:44:26
Message: <4ca4781a@news.povray.org>
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


Post a reply to this message

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