Jeanbono
18-04-2009 20:07:23
Create heightmap from a an another bigger heightmap with ETM ?
I try to make a kind of paging solution from drawing only part I need.
On my terrain example, the heightmap data are loaded on with the player position in the little case .
I reload the map when I push direction key.
I use the ETM v2.3.1 sample for testing by adding some few lines:
With this concept, each etTerrain.png can be a big world like world1.png etc...
I don't put any objects at this time on the map, I prefer waiting some reply before
I try to make a kind of paging solution from drawing only part I need.
On my terrain example, the heightmap data are loaded on with the player position in the little case .
I reload the map when I push direction key.
I use the ETM v2.3.1 sample for testing by adding some few lines:
Ogre::Image cropImage(const Ogre::Image& source, size_t offsetX, size_t offsetY, size_t width, size_t height)
{
if(offsetX + width > source.getWidth())
return source;
else if(offsetY + height > source.getHeight())
return source;
size_t bpp = Ogre::PixelUtil::getNumElemBytes(source.getFormat());
const unsigned char *srcData = source.getData();
unsigned char *dstData = new unsigned char[width * height * bpp];
size_t srcPitch = source.getRowSpan();
size_t dstPitch = width * bpp;
for(size_t row = 0; row < height; row++)
{
for(size_t col = 0; col < width * bpp; col++)
{
dstData[(row * dstPitch) + col] = srcData[((row + offsetY) * srcPitch) + (offsetX * bpp) + col];
}
}
Ogre::Image croppedImage;
croppedImage.loadDynamicImage(dstData, width, height, 1, source.getFormat(), true);
return croppedImage;
}
void loadTerrain()
{
// reload terrain...
mTerrainMgr->destroyTerrain();
Image image;
image.load("ETterrain.png", "ET");
Image img;
img=cropImage(image,pPos.x,pPos.z,129,129);
ET::TerrainInfo info;
ET::loadHeightmapFromImage(info, img);
info.setExtents(AxisAlignedBox(0, 0, 0, 1000, 800 , 1000));
mTerrainMgr->createTerrain(info);
mTerrainInfo = & mTerrainMgr->getTerrainInfo();
// now reload the splatting maps
Image cov;
Image tt;
for (uint i = 0; i < mSplatMgr->getNumMaps(); ++i)
{
cov.load("ETcoverage."+StringConverter::toString(i)+".png", "ET");
tt=cropImage(cov,pPos.x,pPos.z,128,128);
mSplatMgr->loadMapFromImage(i, tt);
}
}
With this concept, each etTerrain.png can be a big world like world1.png etc...
I don't put any objects at this time on the map, I prefer waiting some reply before