Placing Terrain Scene Nodes
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
Placing Terrain Scene Nodes
I created two identical ITerrainSceneNodes using a 306x306 heightmap (17*18=306, so there is even patch size). I placed one at 0,0,0 and the other at 306,0,0. When rendering there is a gap between the two of them which is simply confusing as I would think that the terrain node would be the size of the heightmap. I have found the actual size is 304x304 but I would still like an explanation . Only thing I can think of is the edges of the image aren't used.
The answer is simple:
When you create the terrainscenenode, you set the the patch size. If its 65, then your terrain can only be the multiplicative of 64. So if you have a terrain of 306x306 it will be 256x256 in real. If you use patchsize 33, the multiplicative of 32 will be created. 306/32=9,5632 , so 9*32=288 , 288x288 will be created. So there will be a gap. To solve this problem, Im loading the image first, then I calculate the size from width and height. When you know the size, resize it when you create the node.
When you create the terrainscenenode, you set the the patch size. If its 65, then your terrain can only be the multiplicative of 64. So if you have a terrain of 306x306 it will be 256x256 in real. If you use patchsize 33, the multiplicative of 32 will be created. 306/32=9,5632 , so 9*32=288 , 288x288 will be created. So there will be a gap. To solve this problem, Im loading the image first, then I calculate the size from width and height. When you know the size, resize it when you create the node.
Tomi
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
306 is a multiple of 17 which is my patch size so it should work properly should it not? and being an actual size of 304 seems regardless of the 17 which is the reason of my confusion on how this isn't adding up properly. (would make my map editor quite difficult once I add differing sizes to it). I attempted your solution of having proper size for a 32/33 patch size with a 288x288 heightmap and this resulted in large gaps again. I am fine with manually finding the new size of the terrain node or making an automatic system to do it I just want to know the reason it is doing this as it could potentially be a bug.
further testing:
image size 305x305 patch size of 17, distance is 304 again, I went down to 304x304 image size and there was a large gap. 304 is a multiple of 16 so why would an image 1 pixel larger make a correct 304x304 square than an actual 304x304 image?
(kind of mind boggling)
further testing:
image size 305x305 patch size of 17, distance is 304 again, I went down to 304x304 image size and there was a large gap. 304 is a multiple of 16 so why would an image 1 pixel larger make a correct 304x304 square than an actual 304x304 image?
(kind of mind boggling)
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
Re: Placing Terrain Scene Nodes
the heightmap must be in dimensions of 2^n+1 !!!Insomniacp wrote:I created two identical ITerrainSceneNodes using a 306x306 heightmap
and it should not be larger than 129x129 (IIRC) !!!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact:
ok, thanks, is there a reason that it shouldn't be larger than 129x129? I haven't had any issues with larger ones and still get good fps.
In the documentation there wasn't anything stating the size of the heightmap which lead to the confusion on if it should be 2^n or 2^n+1. The only mention of size was the patch sizes and I thought that simply refered to the enumeration of patch sizes being 2^n+1 and didn't know how to correlate it properly to the heightmap size.
Would it be possible to add a sentence stating the heightmap should be K*( patchsize-1 )+1, where K is a positive integer of your choice?
In the documentation there wasn't anything stating the size of the heightmap which lead to the confusion on if it should be 2^n or 2^n+1. The only mention of size was the patch sizes and I thought that simply refered to the enumeration of patch sizes being 2^n+1 and didn't know how to correlate it properly to the heightmap size.
Would it be possible to add a sentence stating the heightmap should be K*( patchsize-1 )+1, where K is a positive integer of your choice?
-
- Posts: 208
- Joined: Sun Apr 02, 2006 9:20 pm
Yes IIRC the missing strip is due to the edges of your terrain object being one LOD unit shorter than the the size of the bitmap, another issue you will probably encounter is the normals at the edge of your terrains when you do line them up.
Worse than these is the difference in LOD on the patches at the end of your terrains where they join as you move the camera towards them, this will cause cracks to appear in your terrain and then disappear making it look very ugly.
There is a module CTerrainTileSceneNode.cpp in my irrlichtwrapper source that solves these two problems. It is the same as a regular terrain node only you have a function attachTile that allows you to stitch them together, it was designed for massive/infinite landscapes, it works well but there might still be a bug or two in it though as I really haven't used it in anger.
you can just pull that file and its .h out and add it to your project.
Worse than these is the difference in LOD on the patches at the end of your terrains where they join as you move the camera towards them, this will cause cracks to appear in your terrain and then disappear making it look very ugly.
There is a module CTerrainTileSceneNode.cpp in my irrlichtwrapper source that solves these two problems. It is the same as a regular terrain node only you have a function attachTile that allows you to stitch them together, it was designed for massive/infinite landscapes, it works well but there might still be a bug or two in it though as I really haven't used it in anger.
you can just pull that file and its .h out and add it to your project.
yes, but not bc of LOD...Insomniacp wrote:ok, thanks, is there a reason that it shouldn't be larger than 129x129?
everything already answered: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=33886
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Since Irrlicht 1.5 (or 1.6?) the limit to 129x129 is not anymore. If your computer supports 32bit indices (all hw drivers should, but dx8 seems to have some problems with it), you can have almost arbitrary sizes. However, more than 1025x1025 usually won't render anymore with any non-zero frame rate. You should use (2^n)+1 dimensions to get a proper tiling of the terrain under LOD.
-
- Posts: 288
- Joined: Wed Apr 16, 2008 1:45 am
- Contact: