New Tiled Terrain Scene Node [works with Irr 1.5]

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post by FlyingIsFun1217 »

FlyingIsFun1217 wrote:
arras wrote:You need pointer only if you going to work with it. Irrlicht keep track of texture internaly, probably by video driver.

This is code hybrid probably had in mind:

Code: Select all

terrain->getMaterial(0).Textures[0] = driver->getTexture("Media/dirt_x_43.bmp");
I'll try this and see what I get :)

FlyingIsFun1217
Still gives me the same error :(

FlyingIsFun1217
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

If you have Windows and some compiler:

Try compile under Windows and OpenGl.
Try compile under Windows and DirectX.
Try compile with Irrlicht 1.3.
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post by FlyingIsFun1217 »

arras wrote:If you have Windows and some compiler:

Try compile under Windows and OpenGl.
Try compile under Windows and DirectX.
Try compile with Irrlicht 1.3.
Alright.

Thanks again!
FlyingIsFun1217
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Mine just takes a billion years when it tries to Randomize Terrain when using the code you gave have for source. Terrain Height and Width and Mesh size dont seem to affect load time.

using VS2005 Express and Irrlicht 1.3.1 I had to make one change to just compile:

Code: Select all

//f32 distance = core::vector2d<s32>(i-radius, j-radius).getLength();
				f32 distance = core::vector2df(i-radius, j-radius).getLength();
But except for this change, the original code is the same. Any clue why my computer just dies when trying to randomize the terrain?

(The demo you provided runs very fast however. So I am not sure whats happening. )
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Please, can you try if this will compile?:

Code: Select all

f32 distance = (f32) core::vector2d<s32>(i-radius, j-radius).getLength();
Regarding to speed, I have no idea. If demo runs fast, its not problem of your hardware. What video driver do you use to compile, DirectX or OpenGL? Does it make any diference to svitch between them?

Can you also try these things and refere what happen?:

1. try compiling with Irrlicht 1.3

2. try to comment out these lines in main.cpp to find which function cause such slow loading time:

at line 184 makeRandomHills(terrain, 20000, 20);
at line 185 makeRandomHills(terrain, 100000, 5);

at line 196 terrain->smoothNormals();

at line 207 randomizeColor(terrain);

at line 218 randomizeUV(terrain);

comment it one by one and compile.

3. try to compile example code which you can find at the bottom of page 5 of this post. I would wonder if it also take so long to load.
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Hmm so going down the list:
f32 distance = (f32) core::vector2d<s32>(i-radius, j-radius).getLength();
Doesnt compile. getLength() only returns long double, float, and double.
1. try compiling with Irrlicht 1.3
Doesnt change the load time.
2. try to comment out these lines in main.cpp to find which function cause such slow loading time:
at line 184 makeRandomHills(terrain, 20000, 20);
Changes load time to much less than before.
at line 185 makeRandomHills(terrain, 100000, 5);
Changes load time to much less than before.
at line 196 terrain->smoothNormals();
Changes load time to a little less than before.
at line 207 randomizeColor(terrain);
Some but Not much change in load time.
at line 218 randomizeUV(terrain);
Some but Not much change in load time.
3. try to compile example code which you can find at the bottom of page 5 of this post. I would wonder if it also take so long to load
Compiles and works fine. Though the detail map can be clearly seen to tile, it works fine.

=====
One thing I neglected to mention. The program runs very choppily when I compile it myself. However, running the demo it looks great and works fine.

So now what do you think?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe try to compile a release version. Debug versions are very slow.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Debug version of what? ...terrain demo?
fmx

Post by fmx »

hybrid was talking to krama757
he should use a stable release version of Irrlicht (1.2, 1.3), not a debug version (v1.3.1)
krama757 wrote:using VS2005 Express and Irrlicht 1.3.1
-----

edit:
i should read more before posting.
sorry arras, my bad
:oops:
Last edited by fmx on Fri Aug 31, 2007 8:36 pm, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Thats not what he meant FMX, he meant the project settings. Although I'm not quite sure why he thinks Krama is compiling in debug...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Because it's the default setting when you open the msvc project and it kills framerate. Som a simple check for the setting might help.
Oh and 1.3.1 is not a development version, it should have removed the most annoying bugs without introducing to many features and changes such that apps should still compile without major problems. Development is performed in the SVN, there are no binary development versions.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

No problem fmx.

Thanks hybrid/BlindSide.
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Hybrid hit it on the head! Runs fine right now :) Thanks guys.

Now the next question is how to use this as a tiled terrain manager like that of irrSpintz.

I have two heightmaps that I want to be rendered joined together as a continuous terrain and with their own individual textures. Here is the code I am using:

Code: Select all

int main() 
{ 
    IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(800, 600), 32, false, false, false, 0); 
    
    video::IVideoDriver *driver = device->getVideoDriver(); 
   scene::ISceneManager* smgr = device->getSceneManager(); 
    
    // create terrain scene node 
    ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, 255, 255, 2, 200); 
   terrain->drop(); 
    
   // load height data from texture 
   terrain->loadHeightMap("media/terrain-heightmap.bmp", 50, 0, 0);
   terrain->loadHeightMap("media/HMAP_0_0.jpg",50,0,1);
    
   // load color map 
   terrain->loadColorMap("media/terrain-texture.jpg",0,0); 
   terrain->loadColorMap("media/TMAP_0_0.bmp",0,1);

   // set detail texture 
   terrain->setMaterialTexture(0, driver->getTexture("media/detailmap3.jpg")); 
    
   // smooth normals 
   terrain->smoothNormals();

	//randomizeUV(terrain);
    
   terrain->setMaterialFlag(video::EMF_LIGHTING, false); 
    
   scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0,100,50); 
    
   // set terrain to follow camera 
   terrain->follow(camera); 
    
   while(device->run()) 
    { 
        driver->beginScene(true, true, video::SColor(255,100,101,140)); 

      smgr->drawAll(); 
       
      driver->endScene(); 
    } 
    device->drop(); 
    
    return 0; 
}
But the results I am getting are bizarre. Here is a screenshot:
Image

I am presuming that the wierd flat thing on the right is my 0,0 tile and the perfectly blue map on the left is my 0,1 tile. The colormap on the 0,1 tile is bizarre because it is supposed to be blue on parts and brown on other parts. However right now the entire tile is blue. Whats going on?

Is the code wrong?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Well I think you do not realy understand howe this node works. You cant compare it to Spintz terrain and use it the same way.

Firsth you seem to handle "tile" wrong. Tile in case of my terrain is simply polygoon made of 4 vertices and 2 triangles. Whole mesh is made of them. To see tiles you can set:

Code: Select all

terrain->setDebugDataVisible(scene::EDS_MESH_WIRE_OVERLAY)
Your terrain is made of 255x255 tiles and 200x200 of them are actualy displayed.

Code: Select all

terrain->loadHeightMap("media/terrain-heightmap.bmp", 50, 0, 0);
terrain->loadHeightMap("media/HMAP_0_0.jpg",50,0,1);
Here you are loading two heightmaps over each other, second overwriting firsth. Firsth one you start loading at tile 0,0 (remember tiles have coordinates 0,0 - 255,255 where 0,0 is at the bottom left of terrain) then you load second starting at tile 0,1. This overwrite firsth with exeption of tiles 0,0 - 0,255. Thats why that jump at the right side of your picture.

Same goes for your colormap.

To understand whats going wrong just change your code to:

Code: Select all

// load height data from texture
terrain->loadHeightMap("media/terrain-heightmap.bmp", 50, 0, 0);
terrain->loadHeightMap("media/HMAP_0_0.jpg",50,0,127);
   
// load color map
terrain->loadColorMap("media/terrain-texture.jpg",0,0);
terrain->loadColorMap("media/TMAP_0_0.bmp",0,127);
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Ah I see. Now I get it :)
Post Reply