Page 1 of 1

Tiled terrain scene node

Posted: Thu Dec 28, 2006 1:39 am
by arras
TlTerrainSceneNode create tile based terrain which can be nearly limitless in size. This is accomplished by storing data about terrain (height, normal, UV coordinates) in data array. Only terrain in specified size around camera (or anything specified) is rendered. Each tile can be textured independently by part of texture. This is accomplished by setting its texture UV coordinates. This class is still work in process and I would welcome any constructive critique, suggestions or bug reports from you. You are allowed to use it freely.
header files: http://members.lycos.co.uk/arras1/downl ... 61228b.zip

most important functions:

TlTerrainSceneNode(scene::ISceneManager* smgr, core::dimension2d<u32> trsize,u32 visibility, f32 tlsize = 1.0f)

-constructor
smgr -pointer to scene manager
trsize -dimensions of whole terrain in tiles
visibility -number of tiles which are visible in X and Z directions
tlsize -size of single tile


virtual void setHeight(core::vector2d<s32> position, f32 newheight)

-set height of data point at given coordinates
position -data point coordinates in tiles
newheight -new height


virtual f32 getHeight(core::vector2d<s32> position)

-return height of data point at given coordinates
position -data point coordinates in tiles


virtual f32 getHeight(core::vector3df pos)

-return height of terrain at any coordinates, used to place scene nodes on terrain
pos -position in 3D space, only X and Z coordinates are used


virtual void setTexture(char* filename)

-loads texture to be used by terrain
filename -texture file


virtual void setTileUVs(core::vector2d<s32> position, core::vector2df uv0, core::vector2df uv1, core::vector2df uv2, core::vector2df uv3)

-set texture coordinates of tile
position -tile coordinates in tiles
uv0 -UV coordinates of lower left corner of tile
uv1 -UV coordinates of upper right corner of tile
uv2 -UV coordinates of upper right corner of tile
uv3 -UV coordinates of lower left corner of tile


virtual void centerVisibleTerrain(core::vector3df pos)

-centers visible part of terrain at given coordinates
pos -position in 3d space, only X and Z coordinates are used


virtual void centerVisibleTerrain(scene::ISceneNode* node)

-centers visible part of terrain around scene node (camera, player)
node -scene node


virtual void follow(scene::ISceneNode* node)

-sets scene node visible terrain should be centered around automatically
node -scene node


virtual void stopFollowing()

-cancel follow order


virtual bool getIntersectionWithLine( core::line3d<f32> line, core::vector3df &outIntersection)

-this function can be used to check line of sight or bulet collision
is slower than getHeight so use it only when appropriate
return true if line collide with mesh, false if not
line -3D line to test collision with terrain
outIntersection -vector were intersection point will be stored


virtual void smoothNormals()

-will recalculate normals of whole terrain in order to look smooth under light


virtual void calculateNormal(u32 x, u32 y)

-will recalculate one normal at given coordinates

for complete list of functions look in to TlTerrainSceneNode.h

Posted: Thu Dec 28, 2006 8:03 am
by BlindSide
Nice work, is this similar to the one IrrSpintz has? Anyway, Tripod doesnt appear to support hotlinking, may you please put a link on your website for the download as I am interested.

Posted: Thu Dec 28, 2006 9:13 am
by arras
Thanks :) you can find it at download section of my site now. Excuse me for ignorance but I was newer triing IrrSpintz so I can not realy say the diference. But from what I was reading in his documentation it is similar in a way texture is displayed.

Posted: Thu Dec 28, 2006 9:25 am
by BlindSide
I just tried the demo and I must say good work! It is very fast. :D

Posted: Fri Jan 05, 2007 7:18 am
by keithwei
The link can't download. :cry:

Posted: Fri Jan 05, 2007 12:34 pm
by Spintz
I haven't tried this out, or looked at it, but this just displays a tile, or a quad with a texture, correct? The one in IrrSpintz will tile multiple ITerrainSceneNode's using LOD.

Maybe I should download and try this before opening my mouth, eh?

Posted: Fri Jan 05, 2007 3:35 pm
by BlindSide
You are correct in your assumption spintz, but I found it quite nice, similar sensation to LightFeather's terrain.

Posted: Tue Jan 09, 2007 10:37 pm
by arras
Spintz >> it makes scene node which is made of several tiles. Each of them have its own UV coordinates, unlike ITerrainSceneNode. If you were ever using Dark Basic than it works similar to "matrix". There is no LOD yet but I already had some code working with LOD based on distance from center (which is most likely camera position). However there is problem hove to texture such terrain since you have to deal with tiles of diferent size. Havent found satisfiing solution yet.

keithwei >> try downloading from my web page. It should work: http://members.lycos.co.uk/arras1

Posted: Wed Jun 06, 2007 8:01 pm
by C4Cypher
This is exactly one of the things I was hoping to eventually render, I probably won't be able to use the code directly, but I'm glad I can look through it. Thank you! If I ever manage to get this to work for IllLicht 1.3 .Net (VB.NET) I'll be sure to post the code I come up with.

Posted: Thu Jun 07, 2007 1:09 am
by BlindSide
Make sure to use the new improved one in the project announcements forum, this one is over 5 months old if you hadnt noticed.

Posted: Tue Jan 01, 2008 8:26 am
by kornwaretm
wow :shock: :shock: :shock: :shock: