|
|
"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
|
|
|
|
> 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
|
|