I've recently begun implementing a more flexible terrain system for my game, one that will use an array of tiles in such a way that I can keep a high level of detail in the texture. I want to avoid scaling textures if at all possible.
So far everything has been going pretty well except for when I apply a texture to a tile the bottom and left of the texture are being trimmed, by about 15 pixels. The same is true of the height map, and thus is preventing each time for meeting up accurately.
I've done a small test with a screen shot and example textures to illustrate this.
Example Texture
Runtime
The code that is producing my tiled terrain is
Code: Select all
// Map Loader ///////////////////////////////////////////////////////////////////////////////////////
int x = 0;
int y = 0;
int i = 0;
#define _W 2
#define _H 2
scene::ITerrainSceneNode *terrain[_W*_H];
for (y = 0; y < _H; y++) {
for (x = 0; x < _W; x++) {
char mapTile[256];
char tex[256];
sprintf(mapTile, "Game.app/Contents/Resources/map%d%d.png", y, x);
sprintf(tex, "Game.app/Contents/Resources/tex%d%d.png", y, x);
printf("%d %d\n", x, y);
terrain[i] = smgr->addTerrainSceneNode(mapTile, 0, -1,
core::vector3df(x*256, -200, y*256),
core::vector3df(0, 0, 0),
core::vector3df(1, 1, 1),
video::SColor(255, 255, 255, 255),
5,
scene::ETPS_17,
4, true);
terrain[i]->setMaterialFlag(video::EMF_LIGHTING, false);
terrain[i]->setMaterialTexture(0, driver->getTexture(tex));
terrain[i]->setMaterialType(video::EMT_DETAIL_MAP);
i++;
}
}
Cheers, Tom[/code]