Question regarding Forests::GrassLayer::setXXXMap


05-11-2008 00:15:12


While working on integrating PagedGeometry in my engine, a question came to my mind: how does PagedGeometry calculate color during Forests::GrassLayer::setXXXMap calls? Does it require color/density maps the same dimensions as the world map, or are they calculated using floating point values of 0...1 ?

Essentially this would enable me to use lower resolution density/color maps throughout the game, if the maps are calculated using the latter.

- Peter


05-11-2008 18:21:18

The GrassLayer::setMapBounds() function sets where the map takes effect. This gives you full control of where and how the map is "mapped" to your terrain/world. For example if you have a density map and only want it to effect a certain region of your world, you simply call setMapBounds() to map it to that region.

The color values are calculated fairly simply - for setColorMap(), it either takes the full RGB color value from the map and colors the grass appropriately, or if you set it to a certain RGBA channel, it will use that channel's value as a greyscale color value to use.

For setDensityMap(), it takes whatever you tell it to (a single color channel, or if you tell it to use all with CHANNEL_COLOR, it converts a color density map to greyscale and uses that value). Density values range from "0" (full black) to "1" (full white), where 0 is no grass at all and 1 is the full density value set by GrassLayer::setDensity().

I hope this answers your question. Let me know if you need any clarification.

(Sorry about the late response)