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

Post by arras »

I used this code to draw normals:

Code: Select all

if (DebugDataVisible == scene::EDS_NORMALS || DebugDataVisible == scene::EDS_FULL)
	{
        video::SMaterial m;
		m.Lighting = false;
		driver->setMaterial(m);
		
        for(s32 j=0; j<Sector.height(); j++)
            for(s32 i=0; i<Sector.width(); i++)
            {
                video::S3DVertex2TCoords* v = &Sector(i,j).Vertex[0];
                video::SColor c ( 255, 128 ,0, 0 );
                    for (u32 n = 0; n<Sector(i,j).Vertex.size(); ++n )
                    {
                        core::vector3df h = v[n].Normal * (TileSize/2);
		        driver->draw3DLine ( v[n].Pos, v[n].Pos + h, c );
                    }
            }
	}
No DX or OGL specific stuff...
But you are right, there is quit big difference between them when debuging normals are enabled.
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Yeah I think it has to do with calling beginScene(), I don't know, I will check Irrlicht's source code for drawing lines. This is the reason I like state machines better though. :lol:

EDIT:
Nope it doesn't seem to be doing anything out of the oridinary. Just a line list with DrawPrimitiveUP().
TheQuestion = 2B || !2B
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

hi
i have a problem with textures.

i made a terrain, and want to use loadcolormap()
Image

Code: Select all

   ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(Game.smgr, 255, 255, 1, 100);
   terrain->drop();
   
   // load height data from texture
   terrain->loadHeightMap("data\\World\\terrain-heightmap.bmp", 10);
   
	vector3df terrainPos(0.0f, 0.0f, 0.0f);
	terrain->setPosition(terrainPos);

	// load color map
   terrain->loadColorMap("data\\World\\terrain-texture.jpg");
   
   // set detail texture
	video::ITexture *txt = Game.driver->getTexture("data\\World\\detailmap3.jpg");
	terrain->getMaterial(0).TextureLayer[0].Texture = txt;
   
   // smooth normals
   terrain->smoothNormals();
   
   terrain->setMaterialFlag(video::EMF_LIGHTING, false); 

i tried with both 256*256 and 1024*1024 picture (it's the irrlicht's sample terrain texture)
as you see, i'm using your code, but it isn't work at all..
it put something out , but it isn't that what is in the texture :D
what am i doing wrong?

EDIT:
i tried to make a squared texture (so there are many colored squares, so i can see it in the game), and it worked, but the colors are horrible!
a dark blue square was black!
pink was red.. :D
i think this is my problem.. how could i solve it?
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Post by Darktib »

If your color changed, maybe its because of the lights.

I have a texture problem with Irrlicht 1.4, when I compile and run the demo I obtain a render with colormap and without detail map on OGL, and on DX I have only a texture like a heightmap...
And when I swap the textures number, I obtain:

(DirectX 9.0, with the changes for materials):
Image

(OpenGL, same changes):
Image


Could anybody help me? Thanks in advance
Edit1: I have outcommented the randomizeUV function in the main.

Edit2: I have tested with this code:

Code: Select all

Material[0].TextureLayer[1].Texture = CTexture; 
Material[0].TextureLayer[1].TextureWrap = video::ETC_CLAMP_TO_EDGE;
But the result is the same...
merl
Posts: 1
Joined: Sat Apr 05, 2008 7:15 pm

Post by merl »

hi the demo looks very good.

But when i try the source code i get this problems.
can anybody help me?
Compiling...
ShTlTerrainSceneNode.cpp
Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.
i:\cx\shtlterrainscenenode.cpp(43) : error C2374: 'j' : redefinition; multiple initialization
i:\cx\shtlterrainscenenode.cpp(31) : see declaration of 'j'
i:\cx\shtlterrainscenenode.cpp(46) : error C2228: left of '.Vertex' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(47) : error C2228: left of '.Vertex' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(48) : error C2228: left of '.Vertex' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(49) : error C2228: left of '.Vertex' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(68) : error C2374: 'j' : redefinition; multiple initialization
i:\cx\shtlterrainscenenode.cpp(31) : see declaration of 'j'
i:\cx\shtlterrainscenenode.cpp(70) : error C2228: left of '.Size' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(83) : error C2374: 'j' : redefinition; multiple initialization
i:\cx\shtlterrainscenenode.cpp(31) : see declaration of 'j'
i:\cx\shtlterrainscenenode.cpp(86) : error C2228: left of '.Offset' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(86) : error C2228: left of '.X' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(86) : error C2228: left of '.Offset' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(86) : error C2228: left of '.X' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(86) : error C2228: left of '.Size' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(86) : error C2228: left of '.Width' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(87) : error C2228: left of '.Offset' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(87) : error C2228: left of '.X' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(88) : error C2228: left of '.Offset' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(88) : error C2228: left of '.Y' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(89) : error C2228: left of '.Offset' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(89) : error C2228: left of '.Y' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(93) : error C2374: 'j' : redefinition; multiple initialization
i:\cx\shtlterrainscenenode.cpp(31) : see declaration of 'j'
i:\cx\shtlterrainscenenode.cpp(96) : error C2228: left of '.Vertex' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(96) : error C2228: left of '.set_used' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(96) : error C2228: left of '.Size' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(96) : error C2228: left of '.Width' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(96) : error C2228: left of '.Size' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(96) : error C2228: left of '.Height' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(97) : error C2228: left of '.Index' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(97) : error C2228: left of '.set_used' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(97) : error C2228: left of '.Size' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(97) : error C2228: left of '.Width' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(97) : error C2228: left of '.Size' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(97) : error C2228: left of '.Height' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(101) : error C2228: left of '.Index' must have class/struct/union type
i:\cx\shtlterrainscenenode.cpp(101) : error C2228: left of '.size' must have class/struct/union type
[/code]
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I was not recompiling code under 1.4 yet. I also have to search for some earlier version since changes which were done by elvman introduced some code which he probably used for some physic engine or triangle selector and it slows things down. I have to go through code, then trough whole this post and clean everything up.

I'll do it in few days, tomorrow perhaps and post corrected code. I will see also how it behaves under 1.4. I'll address your problems then.

Thanks for patience...
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Post by Darktib »

Thanks !
For the moment, this terrain engine is the best I have ever seen
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

Darktib wrote:If your color changed, maybe its because of the lights.
nope it isn't the lights.
arras, do you have any idea?
thank you
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Please download updated version on first page. It supports Irrlicht 1.4 now. I did some changes too. Bit more info also on first page along new screenshot and demo (just recompiled with Irr 1.4).

This should solve your problems. Just few notes:

Use terrain->getMaterial(0).FogEnable = true to enable fog. Setting material flag does not seems to work.
Also use terrain->getMaterial(0).setTexture(1, driver->getTexture("texture")) since setMaterialTexture also does not seems to work for reason unknown to me.
I do not know if this is bug of Irrlicht 1.4 yet. Its quit probable since there were some changes to SMaterial.
I recommend you to change all material properties directly not through ISceneNode interface.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you derive from an interface you have to adapt to API changes. This means that you have to add const qualifiers where necessary and adjust for s32/u32 changes. Otherwise the overridden methods won't be chosen, which can lead to wrong material numbers and other effects. Note, that these changes must match for the actually used Irrlicht version, hence you cannot make a version for all Irrlicht versions (at least not without ifdef's in the method signatures).
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Thanks hybrid I'll check through methods and see if it solves it.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

arras wrote:Please download updated version on first page. It supports Irrlicht 1.4 now. I did some changes too. Bit more info also on first page along new screenshot and demo (just recompiled with Irr 1.4).

This should solve your problems. Just few notes:

Use terrain->getMaterial(0).FogEnable = true to enable fog. Setting material flag does not seems to work.
Also use terrain->getMaterial(0).setTexture(1, driver->getTexture("texture")) since setMaterialTexture also does not seems to work for reason unknown to me.
I do not know if this is bug of Irrlicht 1.4 yet. Its quit probable since there were some changes to SMaterial.
I recommend you to change all material properties directly not through ISceneNode interface.
hi!
thank you i got it!

Code: Select all

    terrain = new ShTlTerrainSceneNode(Game.smgr, terrainWidth, terrainHeight, tileSize, meshSize);
	terrain->drop();
	terrain->getMaterial(0).FogEnable = true;
	terrain->getMaterial(0).Lighting = true;

....

	video::ITexture *txt = Game.driver->getTexture("data\\World\\detailmap3.jpg");
	terrain->getMaterial(0).TextureLayer[0].Texture = txt;
	terrain->getMaterial(0).Lighting = false;
and it's working!
but downloading the update :D

EDIT:
a problem with the update:
if i run the program, it's all right, but when i close it, this error pops out:
Debug Assertion Failed!
File: dbgedl.cpp
Line: 52

Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

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

Post by arras »

if i run the program, it's all right, but when i close it, this error pops out:
You mean when you run demo or when you compile it?
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

compile is all right, but when i launch the program and exit from that, this error pops up
radubolovan
Posts: 60
Joined: Tue Nov 13, 2007 7:03 pm
Location: Bucharest - Romania
Contact:

Post by radubolovan »

The same "error" happens to me too; but I've run it with debug and this is the code whitch produced that:

Code: Select all

virtual ~array2d()
   {
      if(w && h)
      {
         for(int i=0; i<w; i++) delete data[i];//here is the problem ... I will dig deeper :D
         delete [] data;
      }
   }
EDIT:
it seams that i is 0, w is 5 and h is 5 when the app is crashing :( ... so the data maybe it's been erased from elsewhere ... I will dig deeper :D
Last edited by radubolovan on Tue Apr 08, 2008 6:18 pm, edited 1 time in total.
Post Reply