POV-Ray : Newsgroups : povray.newusers : Access to height field data Server Time
1 Nov 2024 12:23:35 EDT (-0400)
  Access to height field data (Message 1 to 10 of 20)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Phil
Subject: Access to height field data
Date: 1 Sep 2008 11:30:00
Message: <web.48bc09b478381f518abea67c0@news.povray.org>
Heya!

I'm trying to create some scenes automatically. My goal is to have an island
with hills, lakes and trees. The Island shape is defined by an height field
created by another application. Now I want to add trees and other objects on
this height field surface. The Question is:

Is it possible to define the z-position (if z is pointing up) of the trees
automatically by accessing the height field data, and if yes, how, if no, what
else could be done :)


Thanks a lot,
  Phil


Post a reply to this message

From: Warp
Subject: Re: Access to height field data
Date: 1 Sep 2008 11:40:38
Message: <48bc0cf5@news.povray.org>
Phil <nomail@nomail> wrote:
> Is it possible to define the z-position (if z is pointing up) of the trees
> automatically by accessing the height field data, and if yes, how, if no, what
> else could be done :)

  See the trace() function at
http://povray.org/documentation/view/3.6.1/229/#s02_02_01_04_05

-- 
                                                          - Warp


Post a reply to this message

From: Phil
Subject: Re: Access to height field data
Date: 1 Sep 2008 14:30:00
Message: <web.48bc338bcd5c21438abea67c0@news.povray.org>
>   See the trace() function at
> http://povray.org/documentation/view/3.6.1/229/#s02_02_01_04_05

Thanks for this tip, but what, if the surface is not hit by a ray at the
location, I want to plant a tree?


Post a reply to this message

From: Warp
Subject: Re: Access to height field data
Date: 1 Sep 2008 14:36:19
Message: <48bc3623@news.povray.org>
Phil <nomail@nomail> wrote:
> Thanks for this tip, but what, if the surface is not hit by a ray at the
> location, I want to plant a tree?

  You want to plant a tree at a place where there's no terrain?

-- 
                                                          - Warp


Post a reply to this message

From: Reactor
Subject: Re: Access to height field data
Date: 1 Sep 2008 14:50:00
Message: <web.48bc386dcd5c2143e69c67470@news.povray.org>
"Phil" <nomail@nomail> wrote:
> Heya!
>
> I'm trying to create some scenes automatically. My goal is to have an island
> with hills, lakes and trees. The Island shape is defined by an height field
> created by another application. Now I want to add trees and other objects on
> this height field surface. The Question is:
>
> Is it possible to define the z-position (if z is pointing up) of the trees
> automatically by accessing the height field data, and if yes, how, if no, what
> else could be done :)
>
>
> Thanks a lot,
>   Phil


As Warp mentioned, the trace() macro is perfect for this.  In addition to giving
you a location to place your objects at, it can also provide the normal, which
lets you determine the slope at that position.  This can allow you to, for
instance, place trees only on the flatter parts of the heightfield, or maybe
only on the flatter parts below a certain elevation, or maybe only on the
flatter parts above a certain elevation but below another and only on
"southward" facing parts of the heightfield.

While the documentation does an adequate job of explaining how trace works, I
think I will write a wiki article about how it can be used for this.  Please
let us know if you need more help or how things went.


-Reactor


Post a reply to this message

From: m a r c
Subject: Re: Access to height field data
Date: 1 Sep 2008 15:30:05
Message: <48bc42bd$1@news.povray.org>

web.48bc338bcd5c21438abea67c0@news.povray.org...
>>   See the trace() function at
>> http://povray.org/documentation/view/3.6.1/229/#s02_02_01_04_05
>
> Thanks for this tip, but what, if the surface is not hit by a ray at the
> location, I want to plant a tree?
>
If the surface is not hit by a ray with a -z direction, there is no terrain 
at this location.

It is a good idea to test the length of the returned normal vector : it is 
null if the trace vector does not intersect the surface.

Marc


Post a reply to this message

From: Phil
Subject: Re: Access to height field data
Date: 1 Sep 2008 16:10:00
Message: <web.48bc4b32cd5c21438abea67c0@news.povray.org>
"m_a_r_c" <jac### [at] wanadoofr> wrote:

> web.48bc338bcd5c21438abea67c0@news.povray.org...
> >>   See the trace() function at
> >> http://povray.org/documentation/view/3.6.1/229/#s02_02_01_04_05
> >
> > Thanks for this tip, but what, if the surface is not hit by a ray at the
> > location, I want to plant a tree?
> >
> If the surface is not hit by a ray with a -z direction, there is no terrain
> at this location.
>
> It is a good idea to test the length of the returned normal vector : it is
> null if the trace vector does not intersect the surface.
>
> Marc

Heya!

I've understood! Thanks a lot. I will try this tomorrow and tell you my results.

Phil


Post a reply to this message

From: Phil
Subject: Re: Access to height field data
Date: 2 Sep 2008 20:40:00
Message: <web.48bddbcdcd5c21439ef408df0@news.povray.org>
As promised here are my results:

The trace-Makro is really perfect for my needs, and I wonna thanks you all a lot
for the quick and high-quality answers.

My planting now like this:

#declare map = object {
  height_field {
  ...
  }
}

map

#define norm = <0,0,0>;

#while (IN A REGION WE WANT TO PLANT)
  #declare h = trace(map, <x,y,2>, <x,y,0>, norm);
  #if ((vlength(norm) != 0) & (vlength(h) < 0.5))
    object {
      tree
      translate h
    }
  #end
#end


This is working pretty good. Thanks again.

Phil


Post a reply to this message

From: m a r c
Subject: Re: Access to height field data
Date: 3 Sep 2008 05:00:32
Message: <48be5230@news.povray.org>

web.48bddbcdcd5c21439ef408df0@news.povray.org...
>
> #while (IN A REGION WE WANT TO PLANT)
>  #declare h = trace(map, <x,y,2>, <x,y,0>, norm);

// beware trace() waits for a coordinates  vector then a DIRECTION vector, 
not a destination one.
// I'd  write instead  trace(map, <x,y,2>, -z , norm);

Marc


Post a reply to this message

From: Phil
Subject: Re: Access to height field data
Date: 3 Sep 2008 06:20:01
Message: <web.48be63a3cd5c214363a46a3b0@news.povray.org>
"m_a_r_c" <jac### [at] wanadoofr> wrote:

> web.48bddbcdcd5c21439ef408df0@news.povray.org...
> >
> > #while (IN A REGION WE WANT TO PLANT)
> >  #declare h = trace(map, <x,y,2>, <x,y,0>, norm);
>
> // beware trace() waits for a coordinates  vector then a DIRECTION vector,
> not a destination one.
> // I'd  write instead  trace(map, <x,y,2>, -z , norm);
>
> Marc

Yup, you're totally right.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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