POV-Ray : Newsgroups : povray.newusers : Repetition of an object Server Time
27 Nov 2024 23:38:15 EST (-0500)
  Repetition of an object (Message 1 to 3 of 3)  
From: Parasonic
Subject: Repetition of an object
Date: 9 Mar 2002 21:18:42
Message: <3c8ac282@news.povray.org>
I'm making a wall of boxes (yes, boxes). I have made a set that I could tile
(like bricks). What do I need to do to repeat this group of objects sevreal
times?

Also, how does the sky sphere work? Someone told me how to get a two-color
sky sphere:

sky_sphere {
  pigment {
    gradient y
    frequency 1
        color_map {
      [0 color rgb <0,0,0> ]
      [1 color rgb <0,0,2> ]
    }
    scale 2
    translate y
  }
}

Why is the scale 2? Why is the sphere *translated* on y (not rotated, etc)?

Thanks for your helpfulness!


Post a reply to this message

From: Peter Popov
Subject: Re: Repetition of an object
Date: 10 Mar 2002 05:55:38
Message: <ieem8u0t8idha84hopud7dounirvola9kr@4ax.com>
On Sat, 9 Mar 2002 21:19:30 -0500, "Parasonic"
<par### [at] parasonicpar> wrote:

>I'm making a wall of boxes (yes, boxes). I have made a set that I could tile
>(like bricks). What do I need to do to repeat this group of objects sevreal
>times?

Use a #while loop. For example, here's your box 5 times along the x
axis.

#declare Brick = box { -1, 1 }

#declare i=0;
#while (i<5)
  object { Box translate 2.1*i*x }
  #declare i=i+1;
#end

If you want to repeat along two axes, for example along a plane, use
nested loops.

>Also, how does the sky sphere work? Someone told me how to get a two-color
>sky sphere:

A sky sphere is nothing but a pigmented background. If there's nothing
else to see, POV will show the sky sphere, if any. If there is no sky
sphere, the background color will be what fills in.

The sky sphere is not an object, so it won't cast shadows and such. It
is also infinitely distant, so nothing will fall behind it.

>Why is the scale 2? Why is the sphere *translated* on y (not rotated, etc)?

Look carefully at the code you posted. You're scaling and translating
the pigment, not the sky sphere itself, and it's perfectly legal to do
so.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: bob h
Subject: Re: Repetition of an object
Date: 10 Mar 2002 18:30:03
Message: <3c8bec7b@news.povray.org>
"Peter Popov" <pet### [at] vipbg> wrote in message
news:ieem8u0t8idha84hopud7dounirvola9kr@4ax.com...
> On Sat, 9 Mar 2002 21:19:30 -0500, "Parasonic"
> <par### [at] parasonicpar> wrote:
>
> >I'm making a wall of boxes (yes, boxes). I have made a set that I could
tile
> >(like bricks). What do I need to do to repeat this group of objects
sevreal
> >times?
>
> Use a #while loop. For example, here's your box 5 times along the x
> axis.
>
> #declare Brick = box { -1, 1 }
>
> #declare i=0;
> #while (i<5)
>   object { Box translate 2.1*i*x }
>   #declare i=i+1;
> #end
>
> If you want to repeat along two axes, for example along a plane, use
> nested loops.

I'll expand on that point with:

#declare Brick = box { -1, 1 pigment {rgb 1}}

#declare i=0;
#while (i<9)
#declare j=0;
#while (j<6)
 #if (mod(j,2)=0) #declare k=1; #else #declare k=0; #end
  object { Brick translate <2.1*i+k, 2.1*j,0> }
  #declare j=j+1;
#end
  #declare i=i+1;
#end

This is the nesting, j gets reset to 0 every time i is reiterated until i is
finished looping.  So in this way you also get a height instead of just a
line.
From what it seems you're doing I guess the intended wall is to be staggered
for each successive box lined along top of the last line so you also need to
shift every other line half a box width.  That's the mod(j,2) part; it will
either divide into even numbers leaving a 0 result or odd numbers leaving 1
remainder, thus tested against for whether or not to add a half box width.

> >Also, how does the sky sphere work? Someone told me how to get a
two-color
> >sky sphere:
>
> >Why is the scale 2? Why is the sphere *translated* on y (not rotated,
etc)?
>
> Look carefully at the code you posted. You're scaling and translating
> the pigment, not the sky sphere itself, and it's perfectly legal to do
> so.

Again, I'll expand on what Peter has said.  The usual blend map type of the
gradient pattern causes a doubling of that pattern over the diameter of a
unit sphere centered at the y*0 plane, sky_sphere is essentially a infinite
sphere which is based on the sphere primitive as far as patterns are
concerned.
So, to get only the two colors without using them more than once you must
scale 2 and move that pattern up or down a unit distance in the case of y
direction.  That covers a sphere just once (1 radius = 2 units diameter).
In many cases having the (gradient) sky showing only above a plane {y,0} for
example doesn't require you do such scaling and translating since you don't
see below the ground.

bob h


Post a reply to this message

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