- Code: Select all
grassLoader->setWindDirection(...);
GrassLayer *grass = grassLoader->addLayer("GrassMaterial");
grass->setMinimumSize(2.0f, 2.0f);
grass->setMaximumSize(3.0f, 3.0f);
grass->setDensity(1.0f);
grass->setMapBounds(terrainBounds);
grass->setDensityMap("GrassMap.png"); // <------
grass->setColorMap("LightMap.png");
grass->setSwayLength(0.5f);
grass->setSwaySpeed(1.0f);
grass->setSwayDistribution(10.0f);
grass->setAnimationEnabled(true);
Higher density map resolutions will give you more precision in grass placement, although even for a very large map a 256x256 grassmap is more than enough.
Remember to call setMapBounds() if you use setDensityMap() or setColorMap(), otherwise the GrassLoader won't know what region of space the map is supposed to affect. Normally you just set the map bounds to the same boundaries as your terrain.
P.S.: Click here and here setDensityMap() example screenshots.
Click here setColorMap() example screenshot.
Edit:
I believe the grassloader is an example, prebuilt PageLoader. You can use it as a guide and write your own to suit your needs.
That's true too, modifying the included page loaders is perfectly normal since a PageLoader is highly application specific. However, this doesn't mean the included ones aren't feature-complete (for the most part







