POV-Ray : Newsgroups : povray.general : stacking formula Server Time
23 Nov 2024 20:18:30 EST (-0500)
  stacking formula (Message 1 to 6 of 6)  
From: David Kraics
Subject: stacking formula
Date: 1 Jan 2023 08:55:00
Message: <web.63b18fb5b28076021c1b6180a57e0@news.povray.org>
Hello. All the decades I been using povray, I usually have no problem with
adding prim after prim to create an object. This time around I am working on a
model of the Millenium Tower from the yakuza games. I have created a slice, if
you care, a single floor of the tower, adding texture for the windows and walls.
when I was younger, I would simply declare it to a label, and then stack lots of
them on top of each other.

Except now the idea of doing so seems exhausting.

Is there some kind of loop I can use to do this for me, and maybe return a value
so I can add new things on top of the stack?


Post a reply to this message

From: Bald Eagle
Subject: Re: stacking formula
Date: 1 Jan 2023 09:15:00
Message: <web.63b1951854dbdfbe1f9dae3025979125@news.povray.org>
"David Kraics" <bar### [at] aolcom> wrote:

> Is there some kind of loop I can use to do this for me, and maybe return a value
> so I can add new things on top of the stack?

Of course.

Your level has a ymin and a ymax.  ymax-ymin equals your height.
do a loop, instantiate your object, and then translate each subsequent object in
the y direction by the incremented height.

#declare Ymin = min_extent (Object).y;
#declare Ymax = max_extent (Object).y;
#declare Height = Ymax-Ymin;

#for (Level, 0, 5)
     object {Object translate y*Level*Height}
#end


(untested code)


- Bill


Post a reply to this message

From: David Kraics
Subject: Re: stacking formula
Date: 1 Jan 2023 09:25:00
Message: <web.63b1978954dbdfbe1c1b6180a57e0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "David Kraics" <bar### [at] aolcom> wrote:
>
> > Is there some kind of loop I can use to do this for me, and maybe return a value
> > so I can add new things on top of the stack?
>
> Of course.
>
> Your level has a ymin and a ymax.  ymax-ymin equals your height.
> do a loop, instantiate your object, and then translate each subsequent object in
> the y direction by the incremented height.
>
> #declare Ymin = min_extent (Object).y;
> #declare Ymax = max_extent (Object).y;
> #declare Height = Ymax-Ymin;
>
> #for (Level, 0, 5)
>      object {Object translate y*Level*Height}
> #end
>
>
> (untested code)
>
>
> - Bill

So lets say the height of the object is .803, The object is called Floor, and I
want to stack 66 of them. Could you reshow the code with the inputs I gave, I'm
trying to understand this


Post a reply to this message

From: Bald Eagle
Subject: Re: stacking formula
Date: 1 Jan 2023 09:40:00
Message: <web.63b19b0254dbdfbe1f9dae3025979125@news.povray.org>
> So lets say the height of the object is .803, The object is called Floor, and I
> want to stack 66 of them. Could you reshow the code with the inputs I gave, I'm
> trying to understand this


#declare Height = 0.803;

> > #for (Level, 0, 65)
> >      object {Floor translate y*Level*Height}
> > #end

Notice that you _could have done the loop from 1 to 66, but 0 to 65 allows you
to leave the first Floor object untranslated, since 0*Height = 0.


Post a reply to this message

From: jr
Subject: Re: stacking formula
Date: 1 Jan 2023 09:50:00
Message: <web.63b19c8a54dbdfbefbdc16836cde94f1@news.povray.org>
hi,

"David Kraics" <bar### [at] aolcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > ...
> > #declare Ymin = min_extent (Object).y;
> > #declare Ymax = max_extent (Object).y;
> > #declare Height = Ymax-Ymin;
> >
> > #for (Level, 0, 5)
> >      object {Object translate y*Level*Height}
> > #end
> >
> > (untested code)
>
> So lets say the height of the object is .803, The object is called Floor, and I
> want to stack 66 of them. Could you reshow the code with the inputs I gave, I'm
> trying to understand this

see the documentatino for the '#for'; essentially, the value of 'Level' (think
"storey") increases, with each iteration of "the body", by one in this case.  so
the 'translate' calculates the cumulative heights at which the "Floor" begins;
simply replace 'Height' wit hyour value, and change the end value in the '#for'
to '65' (ie, from 0 to 65 == 66 values/"Floors")

<https://wiki.povray.org/content/Reference:Conditional_Directives#The_for_Directive>


regards, jr.


Post a reply to this message

From: David Kraics
Subject: Re: stacking formula
Date: 1 Jan 2023 12:25:00
Message: <web.63b1c16a54dbdfbe1c1b6180a57e0@news.povray.org>
Awesome. Thanks everybody. Happy New Year!


Post a reply to this message

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