POV-Ray : Newsgroups : povray.advanced-users : Need a script to randomly scatter objects vertically Server Time
30 Dec 2024 12:45:33 EST (-0500)
  Need a script to randomly scatter objects vertically (Message 1 to 10 of 30)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Mike Horvath
Subject: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 00:02:49
Message: <607e5269$1@news.povray.org>
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


Post a reply to this message

From: Mike Horvath
Subject: Re: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 00:05:10
Message: <607e52f6$1@news.povray.org>
On 4/20/2021 12:02 AM, Mike Horvath 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


Oops, also this:

5. there are multiple types of trees with varying probability of occuring


Post a reply to this message

From: Thomas de Groot
Subject: Re: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 02:10:04
Message: <607e703c@news.povray.org>
Op 20/04/2021 om 06:05 schreef Mike Horvath:
> On 4/20/2021 12:02 AM, Mike Horvath 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
> 
> 
> Oops, also this:
> 
> 5. there are multiple types of trees with varying probability of occuring


I have such a script!

I shall send you the details later today.

-- 
Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Need a script to randomly scatter objects vertically
Date: 20 Apr 2021 02:47:00
Message: <607e78e4$1@news.povray.org>
Op 20/04/2021 om 08:10 schreef Thomas de Groot:
> Op 20/04/2021 om 06:05 schreef Mike Horvath:
>> On 4/20/2021 12:02 AM, Mike Horvath 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
>>
>>
>> Oops, also this:
>>
>> 5. there are multiple types of trees with varying probability of occuring
> 
> 
> I have such a script!
> 
> I shall send you the details later today.
> 

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.

-- 
Thomas


Post a reply to this message

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)

Goto Latest 10 Messages Next 10 Messages >>>

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