POV-Ray : Newsgroups : povray.newusers : Grass on heightfields : Re: Grass on heightfields Server Time
29 Jul 2024 14:22:41 EDT (-0400)
  Re: Grass on heightfields  
From: tom
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

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