monkeycracks >> yes, thats exactly what this node was made for. You have to put all your textures in to one bitmap. In your case rocks and grass. This will result in to detail texture made of subtiles (texture tiles, not terrain tiles). Then you can use seweral functions which manipulate texture UV coordinates to display correct texture tile on tiles you want. Grass on flat tiles, rocks on angled tiles for example. Function which lets you do it is setTileUV().
Of course in case of 2 diferent detail textures (rocks, grass) you want to create transitional textures (texture tiles) so on tiles where rocks and grass meets, they blend smoothly. My TXTBlend tool does make such set of textures out of two diferent ones automaticly: helps.
http://irrlicht.sourceforge.net/phpBB2/ ... highlight= You just have to put them together.
In my demo, detail texture is also made of tiles. In this case 4 diferent tiles. They did not represent 4 diferent materials however, rather 4 variants of the same material which are randomly applied ower tiles in order to get some wariability. You may look at randomizeUV() function in someFunctions.h to get idea of howe to cut texture in to tiles and howe to apply them ower individual tiles.
This method of texture blending is quit old and is not without flaws, but it works. (I was trying diferent aproaches but due to some bugs in Irrilicht I kept with this one). In future I plan to change it and make easier.
varholl >> size and shape of your terrain seems to be result of wrong arguments passed in to constructor.
You construct terrain like:
Code: Select all
ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, width, height, tilesize, visiblemeshsize);
smgr is pointer to scene manager
width and
height are dimension of your whole terrain
tilesize is size of single tile, terrain is made of. Tile is square, means its width and height are equal, thats why only one argument.
visiblemeshsize is dimension of part of terrain which will be actualy rendered. Its also square.
So lets consider example:
Code: Select all
ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, 255, 127, 10, 50);
In this case terrain will be255 x 127 tiles large, but only its portion 50 x 50 tiles will be wisible at any one time. Since tile is 10 x 10 units large, total dimension of whole terrain will be 2550 x 1270 units but only 500 x 500 units large square will be rendered.
Now you want your height map to be loaded:
Code: Select all
terrain->loadHeightMap("heightmap.bmp", 10, 0, 0);
heightmap.bmp is picture 256 x 128 pixels large. Note that we created terrain 255 x 127 tiles large. This means that terrain is exactly the size of height map. As you see size of terrain is one tile less than number of pixels. Thats because height is not applied to tiles itself but rather to its corners. I call those places where tilles meet, spots. And if you would draw simple image of such terrain made of tiles you can see that number of spots on each axis is always one biger than number of tiles.
Second argument is 10. This is scale and controls howe height data from heightmap will be applied on to terrain. Since height is loaded from color value of pixels in heightmap, it can be something between 0-255. 0 represents black, while 255 represent white. Scale 10 means that color 0 will be loaded as height 0 and color 255 will be loaded as height 10. Color 127 would translate in to height 5.
If for example scale would be 1, this would results in to fairly flat terrain since maximum height (black color) will be 1. As we have tiles 10x10 large, this is not a lot.
Size of terrain does not have to be the same as size of heightmap. My node lets you create large terrain and then load its height data from seweral heightmaps. Thats for what loadHeightMap() have those two last arguments. In example above these are 0, 0 and those are coordinates of spot, where you want your heightmap to be loaded.
For example you have 4 heightmaps: heightmap1.bmp, heightmap2.bmp,heightmap3.bmp,heightmap4.bmp. Each is 128x128 pixels large. Now you want terrain 255x255 tiles large to be created out of them:
Code: Select all
ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, 255, 255, 10, 50);
terrain->loadHeightMap("heightmap1.bmp", 10, 0, 0);
terrain->loadHeightMap("heightmap2.bmp", 10, 128, 0);
terrain->loadHeightMap("heightmap3.bmp", 10, 0, 128);
terrain->loadHeightMap("heightmap4.bmp", 10, 128, 128);
Hope this helps.
BTW: there is example code on page 5 of this post, which shows howe to create terrain from heightmap.