How to correctly edit subject "on fly"?
I use DensityMap::getPixelBox(), then I edit pixelBox.data, and reloadGeometry(), but my app is crushed.
I need a working code sample...
This seems to work for me, although its early days so it may contain some errors.
// Create a new temp texture that will initialize the density map to the correct size
// Unfortunately there doesn't seem to be a way to initialize it without doing this
Ogre::TextureManager &textureManager = Ogre::TextureManager::getSingleton();
// Forums seem to suggest that the density size should be n^2+1 although I can't see a reason for it
// at least it keeps it the same size as the height map
Ogre::TexturePtr densityTexture = textureManager.createManual(
"PSMDensityMap", "General", Ogre::TEX_TYPE_2D,
landscapeSquaresWidth * 128 + 1, landscapeSquaresHeight * 128 + 1, 1, Ogre::PF_L8);
textureManager.remove("PSMDensityMap"); // Clean up texture, texture data is copied by PSM
Forests::DensityMap *densityMap = layer->getDensityMap();
grassDensityBox_ = densityMap->getPixelBox();
OgreSystem::OGRE_WORLD_SIZE * landscapeSquaresWidth,
OgreSystem::OGRE_WORLD_SIZE * landscapeSquaresHeight));
and then later
grassDensityBox_.setColourAt(Ogre::ColourValue(grassDensity, grassDensity, grassDensity, grassDensity), hx, hy, 0);