POV-Ray : Newsgroups : povray.binaries.images : Seascape ... Help! Server Time
16 Nov 2024 02:29:07 EST (-0500)
  Seascape ... Help! (Message 1 to 7 of 7)  
From: Aaron Gillies
Subject: Seascape ... Help!
Date: 23 Aug 2003 01:12:35
Message: <3f46f7c3@news.povray.org>
Inspired by fiddling around with height fields tonight.

My question is ...

Can someone help me figure out how to use trace and the normal
vector that is set by the function to place my trees only in those
places that are at a certain level of flatness?

Is such a thing possible?

Thanks ...

Aaron


Post a reply to this message


Attachments:
Download 'seascape.jpg' (113 KB)

Preview of image 'seascape.jpg'
seascape.jpg


 

From: Rohan Bernett
Subject: Re: Seascape ... Help!
Date: 23 Aug 2003 04:05:03
Message: <web.3f471f5be8c60535aa7c54710@news.povray.org>
>Can someone help me figure out how to use trace and the normal
>vector that is set by the function to place my trees only in those
>places that are at a certain level of flatness?
>
>Is such a thing possible?

I can't help you with that, but I wouldn't mind knowing that same answer
myself.

I think it looks pretty damn good as it is right now. Maybe you don't need
to bother with adding trees at all?

Rohan _e_ii


Post a reply to this message

From: DT - The Renaissance
Subject: Re: Seascape ... Help!
Date: 23 Aug 2003 04:24:27
Message: <3f4724bb$1@news.povray.org>
> Inspired by fiddling around with height fields tonight.
>
> My question is ...
>
> Can someone help me figure out how to use trace and the normal
> vector that is set by the function to place my trees only in those
> places that are at a certain level of flatness?
>
> Is such a thing possible?
>
> Thanks ...

First of all, nice pic.

Concerning trace, try this:

You should declare your heightfield
#delcare HF_Object=
heightfield......

and your tree
#declare Tree=
...........

and then you can declare your tree-array
#declare Tree_Array=
 union{
  #declare A=0;
   #while (A<=20) //change this set the amount of trees in this direction
   #declare B=0;
    #while (B<=20) //change this set the amount of trees in the other
direction
     #declare Normal=<0,0,0>;
     // when you want to change the distance between the trees change
     // this < 1+2*B , 0 , 1+2*A > maybe to this < 1+4*B , 0 , 1+4*A >
     // whatever you want
     #declare Pos=trace(HF_Object, < 1+2*B , 0 , 1+2*A > + y*20, <0,-1,0>,
Normal);
     #if (vlength(Normal))
     // I declare the materials often in extra files, when the scene becomes
too big.
      object {Tree material{Tree_Material} translate Pos}
     #end
     #declare B=B+1;
    #end
    #declare A=A+1;
   #end
 }

object{HF_Object}
object{Tree_Array}

You can also randomize the placing of the trees a bit, by adding a random
value to the translation string.

Regards,
flo

--

DigitalTwilight
#homepage: http://www.digitaltwilight.de
#email: kin### [at] gmxnet


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 19.08.2003


Post a reply to this message

From: Mick Hazelgrove
Subject: Re: Seascape ... Help!
Date: 23 Aug 2003 04:34:44
Message: <3f472724@news.povray.org>
Try in your trace loop

#if(vdot(y,vnormalize(Norm))>0.9725)

where 0>.9725 is the flatness of the angle of flatness you want.

or

#if (VAngleD(Norm, y) < 20)  from math.inc which you need to include


This will place trees only on the flatter parts of your height field.

Thanks to Tor OLav Kristensen

Mick


Post a reply to this message

From: Mike Williams
Subject: Re: Seascape ... Help!
Date: 23 Aug 2003 05:12:09
Message: <CEuM$BAD+yR$Ewtt@econym.demon.co.uk>
Wasn't it Aaron Gillies who wrote:
>Inspired by fiddling around with height fields tonight.
>
>My question is ...
>
>Can someone help me figure out how to use trace and the normal
>vector that is set by the function to place my trees only in those
>places that are at a certain level of flatness?
>
>Is such a thing possible?

The normal is a unit vector. A perfectly flat place would have a normal
of <0,1,0>. The steeper the slope is at a given point, the lower is its
y component. So you can just test to see if Normal.y is greater than
some value. [I reckon Normal.y is the cosine of the angle at which the
ground is tilted, but you're probably going to want to try various
values to see what looks good, rather than pre-calculate what angle of
tilt is acceptable for a tree.]

#declare Mountain = height_field { . . . }

object {Mountain}

#declare Tree = . . . 

#declare Number_of_trees = 2000;
#declare Flatness = 0.95;
#declare RR=seed(1234);
#declare Normal=<0,0,0>;                // force Normal to be a vector

#declare N=0;
#while (N < Number_of_trees)
  #declare X=rand(RR)-0.5;              // or whatever gives a random
  #declare Z=rand(RR)-0.5;              // cover of your Mountain object
  #declare Position = trace(Mountain,<X,1000,Z>,-y,Normal);
  #if (Normal.y > Flatness)
    object {Tree translate Position}
    #declare N=N+1;
  #end
#end

[I've not bothered to explicitly test for the normal being <0,0,0>
(which means that the trace missed the object completely) since such a
point would be rejected by the flatness test.]


Post a reply to this message

From: Chris Johnson
Subject: Re: Seascape ... Help!
Date: 23 Aug 2003 07:39:52
Message: <3f475288@news.povray.org>
The normal.y = cosine(angle) method seems the best way. A couple of other
things I have found useful in tree placement are:

Store in an array where all the trees are and check when creating a new one
that you're not creating any that are too close to other trees.

Shrink the trees by an amount dependant on the slope of the ground (+- a
random factor to keep things looking natural). Also possibly instead of
banning trees from being on steep slopes, make the probability increasingly
less as the gradient of the slope gets greater. These stop forests having
such a clearly defined outline.

-Chris


Post a reply to this message

From: Aaron Gillies
Subject: Re: Seascape ... Help!
Date: 26 Aug 2003 00:04:19
Message: <3f4adc43@news.povray.org>
Thanks for all the help folks ...

I realize now what my error was in handling the normal
vector. :)

I will give your ideas a try and then see what happens.

Aaron


Post a reply to this message

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