Tiled terrain scene node
Tiled terrain scene node
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
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
Last edited by arras on Thu Dec 28, 2006 7:30 pm, edited 1 time in total.
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
keithwei >> try downloading from my web page. It should work: http://members.lycos.co.uk/arras1
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.
"I got a present for you" -Commando
"May the way of the Hero Lead to the Triforce" -If you have to ask, I'll beat you with a herring
"May the way of the Hero Lead to the Triforce" -If you have to ask, I'll beat you with a herring
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact: