POV-Ray : Newsgroups : povray.advanced-users : Random starfield? Server Time
26 Jun 2024 08:34:58 EDT (-0400)
  Random starfield? (Message 1 to 10 of 10)  
From: W0RLDBUILDER
Subject: Random starfield?
Date: 29 Sep 2010 15:05:00
Message: <web.4ca38dbd84f9b3eeb8f6b920@news.povray.org>
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?


Post a reply to this message

From: Warp
Subject: Re: Random starfield?
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

From: W0RLDBUILDER
Subject: Re: Random starfield?
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

From: Alain
Subject: Re: Random starfield?
Date: 30 Sep 2010 23:46:26
Message: <4ca55992$1@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?
>
>
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

From: Warp
Subject: Re: Random starfield?
Date: 1 Oct 2010 06:12:31
Message: <4ca5b40f@news.povray.org>
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


Post a reply to this message

From: W0RLDBUILDER
Subject: Re: Random starfield?
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

From: Alain
Subject: Re: Random starfield?
Date: 1 Oct 2010 12:19:25
Message: <4ca60a0d$1@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
>
>

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


Post a reply to this message

From: W0RLDBUILDER
Subject: Re: Random starfield?
Date: 1 Oct 2010 13:10:01
Message: <web.4ca614e146c817e0b8f6b920@news.povray.org>
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

From: Jim Holsenback
Subject: Re: Random starfield?
Date: 2 Oct 2010 08:51:42
Message: <4ca72ade$1@news.povray.org>
On 10/01/2010 01:19 PM, Alain wrote:
> 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)

... or as of v3.7beta38 (if using radiosity) finish { emission 1 diffuse
0 }


Post a reply to this message

From: Warp
Subject: Re: Random starfield?
Date: 3 Oct 2010 03:48:13
Message: <4ca8353d@news.povray.org>
W0RLDBUILDER <nomail@nomail> wrote:
> > #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

  Obviously you have to #declare Star1, Star2 and Star3 to be your desired
star objects because the CreateStar() lines.

-- 
                                                          - Warp


Post a reply to this message

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