POV-Ray : Newsgroups : povray.advanced-users : Need a script to randomly scatter objects vertically Server Time
29 Mar 2024 11:51:48 EDT (-0400)
  Need a script to randomly scatter objects vertically (Message 5 to 14 of 30)  
<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Thomas de Groot
Subject: Re: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 02:48:02
Message: <607e7922$1@news.povray.org>
Oops! no attachment!

-- 
Thomas


Post a reply to this message


Attachments:
Download 'temp.zip' (11 KB)

From: Mike Horvath
Subject: Re: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 03:24:57
Message: <607e81c9$1@news.povray.org>
Awesome, thanks!

A couple of questions:

1. I cannot render either of the scripts you created. Seems the floor 
and landscape objects are missing. What format do they take?

2. What does the proximity function do? I don't know what a proximity 
function is.

Mike





On 4/20/2021 2:46 AM, Thomas de Groot wrote:
> That "later today" was sooner than expected.
> 
> In the attached zip file are three POV-Ray codes:
> 
> 1) the original code by Kirk Andrews which you can use as reference 
> (KA_LandscapeTutorial.pov)
> 
> 2) my own code based on (1) where I have added and/or changed a couple 
> of things. This code I use currently for any landscape, whether they are 
> trees or rocks or whatever (My objects poser.pov)
> 
> 3) My own code for trees, with probability added for different types of 
> trees (My tree poser.pov)
> 
> They do not answer /all/ your conditions maybe, but come very close 
> indeed. I think you can improve where necessary :-)
> 
> If in doubt, please yell.
>


Post a reply to this message

From: Thomas de Groot
Subject: Re: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 04:29:38
Message: <607e90f2$1@news.povray.org>
Op 20-4-2021 om 09:24 schreef Mike Horvath:
> Awesome, thanks!
> 
> A couple of questions:
> 
> 1. I cannot render either of the scripts you created. Seems the floor 
> and landscape objects are missing. What format do they take?
> 
> 2. What does the proximity function do? I don't know what a proximity 
> function is.
> 
> Mike
> 

Good questions.
"floor" is a placeholder name. When you define your target, i.e. the 
mesh or the height_field on which you want to place your trees and which 
you have already declared before, you fill in their name instead of "floor":

#declare my_HF = height_field {etc etc}

#declare Target  = object {my_HF}


The Proximity Function as defined by Kirk Andrews, and as I understand 
it, is an averaged  pigment which uses the target object repeatedly as 
an object pattern. It can then be used for instance to exclude trees on 
sharp edges of the landscape or scale trees vertically following certain 
rules (there are example uses in some of the commented out lines of the 
code; I switch them on or off according to purpose or need).

I confess that I do not always exactly understand how things work in the 
code, but as long as it does what I want...

If you want, I can design a little demo scene to make things more 
visual. Maybe I even have one somewhere... I need to delve in my dungeons.

-- 
Thomas


Post a reply to this message

From: Mike Horvath
Subject: Re: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 13:14:22
Message: <607f0bee$1@news.povray.org>
The code is missing the `IsObjectVisible` macro too. Do you have that in 
your records somewhere? Thanks.


Mike


Post a reply to this message

From: Thomas de Groot
Subject: Re: Need a script to randomly scatter objects vertically
Date: 21 Apr 2021 02:22:58
Message: <607fc4c2@news.povray.org>
Op 20/04/2021 om 19:14 schreef Mike Horvath:
> The code is missing the `IsObjectVisible` macro too. Do you have that in 
> your records somewhere? Thanks.
> 

Aaah... Sorry, over time those things become more complex and added to. 
What is missing is Gilles Tran's Visibility Test indeed (attached).

Very useful when you do not want to drop objects /outside/ of the camera 
view.

I also attached a little test scene to show how it works and how you 
calibrate it for your scene.

-- 
Thomas


Post a reply to this message


Attachments:
Download 'gt_visibilitytest.mcr.txt' (2 KB) Download 'visibilitytest.pov.txt' (5 KB)

From: Norbert Kern
Subject: Re: Need a script to randomly scatter objects vertically
Date: 21 Apr 2021 14:10:00
Message: <web.608069edc2ce34cbfd796d7fb7ae6630@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> I have some mesh based terrain model. I would like to drop trees
> vertically on to it based on some rules:
>
> 1. the trees should not overlap with each other
> 2. the tree density should depend on the (configurable) slope of the ground
> 3. trees are circular so the only important data is the radius of the tree
> 4. the script needs to output the generated coordinates to a text file
>
> Can someone help me write such a script? Thanks!
>
>
> Michael



I know that Thomas made some very nice macros public in this thread, but I want
to point to an old macro made by JRG (Jonathan Rafael Ghiglia) back in 2001 -
his "clutter macro". Since I wasn't able to find the link on this server I
include the macro here.

With some modifications every point of your list is doable - perhaps I'm able to
do it in the next days. Especially interesting is your first point - but I
haven't looked into Thomas macro regarding it - perhaps this problem is already
solved...

Furthermore, if you want to use a very large number of trees, you should use
only visible coordinates. Back in 2005 I published a method
(http://news.povray.org/povray.binaries.scene-files/message/%3C432414bf%40news.povray.org%3E/#%3C432414bf%40news.povray
.org%3E
for macro -
http://news.povray.org/povray.binaries.images/thread/%3Cdg0ifb%242oi%241%40chho.imagico.de%3E/
for the thread).


Stay healthy
Norbert


Post a reply to this message


Attachments:
Download 'clutter.zip' (73 KB)

From: Tor Olav Kristensen
Subject: Re: Need a script to randomly scatter objects vertically
Date: 21 Apr 2021 21:55:00
Message: <web.6080d64cc2ce34cb6d7cc5a589db30a9@news.povray.org>
"Norbert Kern" <nor### [at] t-onlinede> wrote:
>... I want
> to point to an old macro made by JRG (Jonathan Rafael Ghiglia) back in 2001 -
> his "clutter macro". Since I wasn't able to find the link on this server I
> include the macro here.
>...

Hi Norbert

I suspect that there is an error in JRG's Interpolate macro in the enclosed zip
file.

I would guess that it should return this expression:

    (P1 + (T - T1)/(T2 - T1)*(P2 - P1))

- instead of this one:

    (P1 + (T1 + T/(T2 - T1))*(P2 - P1))

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Thomas de Groot
Subject: Re: Need a script to randomly scatter objects vertically
Date: 22 Apr 2021 02:46:42
Message: <60811bd2$1@news.povray.org>
Op 21/04/2021 om 20:07 schreef Norbert Kern:
> Mike Horvath <mik### [at] gmailcom> wrote:
>> I have some mesh based terrain model. I would like to drop trees
>> vertically on to it based on some rules:
>>
>> 1. the trees should not overlap with each other
>> 2. the tree density should depend on the (configurable) slope of the ground
>> 3. trees are circular so the only important data is the radius of the tree
>> 4. the script needs to output the generated coordinates to a text file
>>
>> Can someone help me write such a script? Thanks!
>>
>>
>> Michael
> 
> 
> 
> I know that Thomas made some very nice macros public in this thread, but I want
> to point to an old macro made by JRG (Jonathan Rafael Ghiglia) back in 2001 -
> his "clutter macro". Since I wasn't able to find the link on this server I
> include the macro here.
> 
I had all but forgotten about this macro! Thanks for the reminder 
indeed. Hight time to try it again.

> With some modifications every point of your list is doable - perhaps I'm able to
> do it in the next days. Especially interesting is your first point - but I
> haven't looked into Thomas macro regarding it - perhaps this problem is already
> solved...
> 
Not really.

> Furthermore, if you want to use a very large number of trees, you should use
> only visible coordinates. Back in 2005 I published a method
>
(http://news.povray.org/povray.binaries.scene-files/message/%3C432414bf%40news.povray.org%3E/#%3C432414bf%40news.povray
> .org%3E
> for macro -
>
http://news.povray.org/povray.binaries.images/thread/%3Cdg0ifb%242oi%241%40chho.imagico.de%3E/
> for the thread).
>
vegmanythings! Of course! Another of those macros I have and then, 
somehow, forget about because I follow my own routine. :-/

> 
> Stay healthy
> 
Thanks. Up to now, successfully...

-- 
Thomas


Post a reply to this message

From: Norbert Kern
Subject: Re: Need a script to randomly scatter objects vertically
Date: 22 Apr 2021 12:50:00
Message: <web.6081a84bc2ce34cbfd796d7fb7ae6630@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:

> Hi Norbert
>
> I suspect that there is an error in JRG's Interpolate macro in the enclosed zip
> file.
>
> I would guess that it should return this expression:
>
>     (P1 + (T - T1)/(T2 - T1)*(P2 - P1))
>
> - instead of this one:
>
>     (P1 + (T1 + T/(T2 - T1))*(P2 - P1))
>
> --
> Tor Olav
> http://subcube.com
> https://github.com/t-o-k


Thanks Tor!

I would never recognize such errors.

Norbert


Post a reply to this message

From: Mike Horvath
Subject: Re: Need a script to randomly scatter objects vertically
Date: 11 May 2021 17:16:34
Message: <609af432$1@news.povray.org>
I finally got around to this. Thanks!

I don't quite understand the code yet. A few questions:

1. How do I make it so that the probability is lower depending on the
    slope of the terrain? This should vary depending on the type of
    object. For instance, the sphere might not like a high slope. The
    spike might not care very much.
2. The spikes seem to point in the direction of the normal. Can I
    disable this? I want them to always be vertical.
3. Is there a way to round the y coordinate to the nearest 8 units and
    the x and z coordinates to the nearest 10 units? I am working with
    virtual LEGO and the precision is very coarse.

Thanks again!


Michael


On 4/21/2021 2:07 PM, Norbert Kern wrote:
> I know that Thomas made some very nice macros public in this thread, but I want
> to point to an old macro made by JRG (Jonathan Rafael Ghiglia) back in 2001 -
> his "clutter macro". Since I wasn't able to find the link on this server I
> include the macro here.
> 
> With some modifications every point of your list is doable - perhaps I'm able to
> do it in the next days. Especially interesting is your first point - but I
> haven't looked into Thomas macro regarding it - perhaps this problem is already
> solved...
> 
> Furthermore, if you want to use a very large number of trees, you should use
> only visible coordinates. Back in 2005 I published a method
>
(http://news.povray.org/povray.binaries.scene-files/message/%3C432414bf%40news.povray.org%3E/#%3C432414bf%40news.povray
> .org%3E
> for macro -
>
http://news.povray.org/povray.binaries.images/thread/%3Cdg0ifb%242oi%241%40chho.imagico.de%3E/
> for the thread).
> 
> 
> Stay healthy
> Norbert
>


Post a reply to this message

<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>

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