load a mesh from file then convert to terrain scene node??

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

load a mesh from file then convert to terrain scene node??

Post by devsh »

Hey I'm currently doing it for ROFH....

I was wondering can I getMesh("landmesh.obj");

and then somehow create an empty TerrainSceneNode and swap the contents and lengths of index and vertex buffers???
mtbal
Posts: 9
Joined: Wed Aug 26, 2009 8:41 pm

Why?

Post by mtbal »

first things first, WHY??
next, I don't think it can be done. the mesh that TerrainSceneNode uses is created from a height map, and you can't really convert a mesh to a height map. Theoretically you could go vise-versa.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

The best way would be to cast rays against a triangle selector, use this to build the heightmap, then write it back out to disk. Once you've done this slow process once, you'll be able to load it back up again quickly next time round.

A terrain is a very restricted sort of mesh, so it will only work with very specific types of obj files. You'll lose UV mapping, vertices will be evenly spaced, everything will be welded together, you'll lose smoothing groups, multiple materials, it will only have one side and so on.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

well first of all i'd like to convert to terrain scene node because of LoD

and is it the only way??? cant i just load the mesh as a normal mesh and swap its mesh buffers... or even vertex/index ones?
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

you can use oct tree scene node

Code: Select all

irr::scene::ISceneManager::addOctTreeSceneNode  ( IAnimatedMesh *  mesh,  
  ISceneNode *  parent = 0,  
  s32  id = -1,  
  s32  minimalPolysPerNode = 512,  
  bool  alsoAddIfMeshPointerZero = false   
 ) 
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

devsh wrote:and is it the only way??? cant i just load the mesh as a normal mesh and swap its mesh buffers... or even vertex/index ones?
The terrain mesh is organized in a very specific way. The LoD algorithm (geomipmapping) relies on a specific width, height, plus the number of, position of and order of the vertices. It also only supports one mesh buffer. I'm not saying it's impossible, but it will be a pain to do with a mesh loaded from a mesh loader. You'd have to write the OBJ exporter so that the mesh is exactly what the terrain node expects, or rewrite it.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

But I am looking for very detailed terrain and octtree still renders at highest lod :(
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The solution is simple. Either write code to do what you want, find code to do what you want, or live with the restrictions of the Irrlicht terrain scene node.

Travis
Post Reply