Tiled terrain scene node

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Tiled terrain scene node

Post 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
Last edited by arras on Thu Dec 28, 2006 7:30 pm, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post 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.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I just tried the demo and I must say good work! It is very fast. :D
keithwei
Posts: 10
Joined: Fri Sep 09, 2005 6:36 am

Post by keithwei »

The link can't download. :cry:
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post 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?
Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You are correct in your assumption spintz, but I found it quite nice, similar sensation to LightFeather's terrain.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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
C4Cypher
Posts: 10
Joined: Tue Jun 05, 2007 12:17 pm

Post 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.
"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
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post 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.
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Post by kornwaretm »

wow :shock: :shock: :shock: :shock:
Post Reply