POV-Ray : Newsgroups : povray.newusers : Grass on heightfields Server Time
1 Nov 2024 11:16:51 EDT (-0400)
  Grass on heightfields (Message 1 to 5 of 5)  
From: Architect
Subject: Grass on heightfields
Date: 25 Oct 2005 15:40:00
Message: <web.435e89854a326736a040ba090@news.povray.org>
I tried different grass macros (Trans gills etc) and they all grow grass on
planes. I am looking for a tool to grow grass on my heightfield. It seems
there was a tool (lawnmaker) back in 2003 but the reference seems gone.

Any ideas?


Post a reply to this message

From: Kenneth
Subject: Re: Grass on heightfields
Date: 25 Oct 2005 18:10:01
Message: <web.435eac3ec7ab4197546e79e70@news.povray.org>
"Architect" <nomail@nomail> wrote:
> I tried different grass macros (Trans gills etc) and they all grow grass on
> planes. I am looking for a tool to grow grass on my heightfield. It seems
> there was a tool (lawnmaker) back in 2003 but the reference seems gone.
>
> Any ideas?

I assume you mean, "How do I place objects on a heightfield?" Or are you
looking for a grass-creation tool? (Or both?)

Ken


Post a reply to this message

From: tom
Subject: Re: Grass on heightfields
Date: 25 Oct 2005 18:20:01
Message: <web.435eaf26c7ab41978e535580@news.povray.org>
"Architect" <nomail@nomail> wrote:
> I tried different grass macros (Trans gills etc) and they all grow grass on
> planes. I am looking for a tool to grow grass on my heightfield. It seems
> there was a tool (lawnmaker) back in 2003 but the reference seems gone.
>
> Any ideas?

Other questions are how much ram do you have, and how much area do you need
to cover?
If it's a small area (or if you have lots of RAM), you can take a mesh of a
blade or two of grass, run through a while loop that selects random x and z
points, trace along the z-axis for the y-coordinate, "plant" a grass object
there. Go until you reach a specified number of planted grass objects.
Heck, here's one I used recently:

#declare ignore_list = union {
  object { doorsteps }
  object { mid_floor }
  object { floorpanels }
  object { windowframes }
}

#if (have_grass=on)
  #declare plants = 300000;
  #debug concat("planting grass", "n", "n")
  #declare start_x = -80;
  #declare start_z = -40;
  #declare depth_x = 400;
  #declare depth_z = 400;
  #declare planted = 0;
  #declare count_x = 0;
  #declare gs=seed(152);
  #while (planted<plants)
    union {
      #local Norm = <0,0,0>;

        // first grass type - a couple blades of grass
      #local trans_x = start_x+(depth_x*rand(gs));
      #local trans_z = start_z+(depth_z*rand(gs));
      #local hgt = trace( terrain,<trans_x, 500, trans_z>,<0,-1,0> );
      #local ignore = trace( ignore_list,<trans_x, 500, trans_z>,<0,-1,0>,
Norm  );
      #if (hgt.y>sea_level)
        #if (vlength( Norm )=0)
          object { grass rotate y*(-88+rand(gs)*175)
            translate <trans_x,hgt.y,trans_z>
          }
          #declare planted = planted+1;
        #end
      #end

        // second grass type - square clump of short grass
      #local trans_x = start_x+(depth_x*rand(gs));
      #local trans_z = start_z+(depth_z*rand(gs));
      #local hgt = trace( terrain,<trans_x, 500, trans_z>,<0,-1,0> );
      #local ignore = trace( ignore_list,<trans_x, 500, trans_z>,<0,-1,0>,
Norm  );
      #if (hgt.y>sea_level)
        #if (vlength( Norm )=0)
          object { grass_3 rotate y*(-88+rand(gs)*175)
            translate <trans_x,hgt.y,trans_z>
          }
          #declare planted = planted+1;
        #end
      #end
    }
  #end
  #debug concat("grass planted: ", str(planted,3,1), "n", "n")
#end


Post a reply to this message

From: Tim Nikias
Subject: Re: Grass on heightfields
Date: 25 Oct 2005 18:23:04
Message: <435eb048$1@news.povray.org>
> I tried different grass macros (Trans gills etc) and they all grow grass
on
> planes. I am looking for a tool to grow grass on my heightfield. It seems
> there was a tool (lawnmaker) back in 2003 but the reference seems gone.
>
> Any ideas?

Well, I'm not sure how deep you want to go, but you could modify Gilles
Tran's grass stuff to your needs. For example (shameless plug follows) I've
written a set of macros to easily sample objects (which includes
heightfields) and have various macros to remove unwanted samples (like
samples on steep slopes). They're called the "Surcoat-Macros" and you can
find them in the downloads section of my website (url in my sig).
If you can then get Tran's grass to generate just a small patch, you could
place that patch onto the samples.

If that's too much trouble, you could even look if my Surcoat2Hair Macros
would suffice, though I suspect your grass would look more like fur then...

If all that's a little too complicated, just a simple thing: look in the
docs for "trace", which can be used to cast a ray from a position into a
certain direction. You have to supply it with an object (in this case, your
heightfield), and get a position and normal back. Use that data to place a
strand of grass, rinse and repeat until you've got enough grass. :-)

Regards,
Tim

-- 
aka "Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Marc Jacquier
Subject: Re: Grass on heightfields
Date: 26 Oct 2005 03:29:37
Message: <435f3061$1@news.povray.org>

news:web.435e89854a326736a040ba090@news.povray.org...
> I tried different grass macros (Trans gills etc) and they all grow grass
on
> planes. I am looking for a tool to grow grass on my heightfield. It seems
> there was a tool (lawnmaker) back in 2003 but the reference seems gone.
>
> Any ideas?
>
Have a look there
http://www.wozzeck.net/images/hfcomp/gazon-en.html


Marc


Post a reply to this message

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