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
Post Reply
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Ahh..
Now I just wish there was an editor for painting textures onto it.

So basically I have to get the tile that is supposed to have the rock detail map, apply that detail map to it..

would there be a way to just apply that detail map to all tiles above a certain height?
varholl
Posts: 22
Joined: Thu Jul 12, 2007 6:59 pm
Location: Argentina
Contact:

Post by varholl »

Arras.... you are a great man... lol

This works now!! i didn't tested very much because i'm in job.. but this noght i will start to play with this baby... it seems that its only a matter of calculate wich size i want for my terrain...

Thank you very much arras!!!


PS: I've tested your Blender yesterday... no words... it's AWESOME!

EDIT:

One issue left... i don't know if you know something about this.. but when i close the irlicht window i got a windows error like this..
Debug Assertation Failed!
Program: d:\MISC\Nokturna.exe
Expression: _BLOCK_TYPE_IS_VALID (pHead->nBlockUse)
If you know what it is.. great.. if not.. nevermind!
A caos world where only the strongest lives, weak is not an option... you must fight.. Nokturna!!

http://nokturna.varholl.com.ar
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

monkeycracks >> Yes, but you have to code it. I did it in my old TlTerrainSceneNode demo. There were two materials, fresh grass and dry grass. Dry grass was applied if slope exceded certain walue, with some randomization. Look in to source code, there is function which does it automaticly.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

varholl >> thanks, I hope you find my node usefull :) You can allways ask here if you need something.
As for that error message ...sorry, but I have no idea ...something with debug code? ...I dont know.
varholl
Posts: 22
Joined: Thu Jul 12, 2007 6:59 pm
Location: Argentina
Contact:

Post by varholl »

well nevermind... the only thing left is that the terrain is not getting the right color from the colorMap.. my code is this

Code: Select all

ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, terrainWidth, terrainHeight, tileSize, meshSize);
	terrain->drop();
	
	terrain->loadHeightMap("terrain/mapafinal2.bmp", 400,0,0);
	terrain->loadColorMap("terrain/nokturnafinal_TX.jpg"); 
	
	terrain->setMaterialTexture(0, driver->getTexture("terrain/detailmap3.jpg"));
	
	terrain->smoothNormals(); 
	terrain->stretchTexture(vector2d<f32>(60.0f, 60.0f));
Any idea???

From the other error... nevermind... i will fix it surelly..

EDIT:

One questions..

LoadColorMap.. works like LoadHeightMap?? so i can load different color maps setting the right parameters of position??


Thanks!
A caos world where only the strongest lives, weak is not an option... you must fight.. Nokturna!!

http://nokturna.varholl.com.ar
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Well I've modified the function from the old node to work with the new one and everything works alright (tested using your Terrain.bmp). But I'm not really sure how I'll go about making my own texture like htat. I have TxtBlend and used it on my textures, but how should I cut my bmp up.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

varholl >> yes, loadColorMap() works the same way as loadHeightMap(). With exception of scale. There is none of course. Look inside ShTlTerrainSceneNode.h each function, its return value and parameters are described there.

What is working wrong when zou load color map? Your code seems to be OK.

monkeycracks >> you have to use some bitmap editing program like Phothoshop or Gimp. Create large new file, then copy textures in to it one by one. You have to decide order in which you put them in since their position inside (UV coordinates) are used to put right texture tile on right tile on terrain. You dont have use them in the same order as I did of course.
varholl
Posts: 22
Joined: Thu Jul 12, 2007 6:59 pm
Location: Argentina
Contact:

Post by varholl »

Well the problem is that is not loading the color... the map is coolr, the texture is greate.. but the color is not loaded.. only a gray from textures...

But i will check on it at night... maybe is a lighting issue or another small thing..

Thanks for everything... i'll post my results of this night..
A caos world where only the strongest lives, weak is not an option... you must fight.. Nokturna!!

http://nokturna.varholl.com.ar
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

varholl >> try example code from page 5. Use textures from Irrlichr examples as is described in my post. It should work.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I'm not sure what effect changing the order will have, or how to order them :P

Sorry I'm sure I've become annoying by now xD
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

monkeycracks >> dont worry, you are not :)
If you want to use my setMaterial() function from old demo, you have to keep textures in the same order since function works with them based on their position.

If you make your own function or set tileUV coordinates manualy, you may choose your own order.

In principle my setMaterial function works like this:

firsth it assign each terrain spot (place where tiles meets each other) material: fresh grass or dry grass. Note that material is not assigned to tiles but rather to its corners ...spots. It can be done in cusstom made array. 0 means one material, 1 means other.

Then it goes through each tile and test what materials are at its 4 corners. Depending on material combination it choose appropirate texture (or better its UV coordinates) and assign it to tile.

You can see this test in setMaterial function:

Code: Select all

for(u16 j=0; j<node->getSize().Height; j++)
        for(u16 i=0; i<node->getSize().Width; i++)
        {
            if(mat[i][j+1] == 0   && mat[i+1][j+1] == 0 && 
               mat[i][j]   == 0   && mat[i+1][j]   == 0   ) 
                asignUVset(node, core::vector2d<s32>(i,j), &set[0]);
            
            if(mat[i][j+1] == 1   && mat[i+1][j+1] == 1 && 
               mat[i][j]   == 1   && mat[i+1][j]   == 1   ) 
                asignUVset(node, core::vector2d<s32>(i,j), &set[1]);
            
            if(mat[i][j+1] == 1   && mat[i+1][j+1] == 0 && 
               mat[i][j]   == 1   && mat[i+1][j]   == 0   ) 
                asignUVset(node, core::vector2d<s32>(i,j), &set[5]);
            
            if(mat[i][j+1] == 0   && mat[i+1][j+1] == 1 && 
               mat[i][j]   == 0   && mat[i+1][j]   == 1   ) 
                asignUVset(node, core::vector2d<s32>(i,j), &set[6]);
            
            if(mat[i][j+1] == 1   && mat[i+1][j+1] == 1 && 
               mat[i][j]   == 0   && mat[i+1][j]   == 0   ) 
                asignUVset(node, core::vector2d<s32>(i,j), &set[3]);
            
            ...and so on....
        }
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Well I just made a texture in the same order as yours and used the old function. Blends perfectly and on the slopes. Would making it blend on the slopes and above a certain height be difficult?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

No, just test if height is above certain walue and if yes, assign material you want. Should be fairly easy. You can even modify my function to do that.
varholl
Posts: 22
Joined: Thu Jul 12, 2007 6:59 pm
Location: Argentina
Contact:

Post by varholl »

EDITED:

It WORKS.. NOT GOOD... NOT FINE... IT WORKS INCREDIBLY GOOD AND FAST!!!!!!!

Arras... you are God...
A caos world where only the strongest lives, weak is not an option... you must fight.. Nokturna!!

http://nokturna.varholl.com.ar
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Thanks varholl I am glad it works and you like it. :)
Post Reply