Dynamic light problem! [SOLVED]

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Dynamic light problem! [SOLVED]

Post by Lovehina »

Iv already asked about this in the beginner forum, but as time passes I'm beginning to believe that this might be a bug! :(
Old topic

What it comes down to is that the dynamic lighting doesn't get updated with imported animations.
To understand this better, just imagine a scene with a dynamic light node and a cube. The light and the cube aren't moving, but the cube has an imported animation the makes it rotate. Logically, as the cube rotates, the side that faces the light is brighter than the other sides of the cube. Up to this point everything is as it should be.

But in my case, as the cube rotates, only one side of it is bright and the rest are dark no mater which direction the light is coming from. Its almost as if I'm using a lightmap, but I'm not! :(
The weird thing is that if I use a built in animation or manually rotate the cube (cube->setRotation(core::vector3df(0,speed,0));) the lightning is correctly updated.
This issue happens both in OpenGL and DirectX, and with .X or .MS3D meshes.

Any help on this matter is highly apreciated... :wink:
Last edited by Lovehina on Fri Jun 02, 2006 12:05 pm, edited 1 time in total.
mandrav
Posts: 117
Joined: Sat Aug 27, 2005 8:29 pm
Contact:

Post by mandrav »

This sounds like the model's normals are not rotated with the animation.
In other words, yes, it sounds like a bug.

Yiannis.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

For .ms3d files this bug can be easily traced down to somewhere around line 600 where the position vector is transformed, but not the normal vector. The .x animation player has some normals updating if you apply the animxnormals.patch from my webpage (not tested, though).
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post by Lovehina »

Finally an answer that makes sense...! I look into it, but I just want to say, thanks a 1 000 000! :D
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post by Lovehina »

This patching thing is a bit complicated, but I'm more concerned with compiling the engine... :( Iv read somewhere that I might need DirectX SDK + some other files. I'm just so afraid that I might include some bad files or exclude some important ones, and then maybe the engine will crash or wont run as well... :cry:
By the way, this is my first time doing this and I feel really scared, so I'm wondering if there is a tutorial on how to correctly apply a patch and then correctly rebuild the engine...?

PS: I'm using Visual Studio 2003
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

A short introduction to patches is found on my webpage (see 'What's a patch'). It's basically as follows: Change into the source/Irrlicht directory, call 'patch --binary -p1 </path/to/patchfile.patch' and recompile (unless there's an error). Recompiling should work by just opening the project file and pressing the compile button. You do need the DirectX SDK (even not the most recent one), but you'll find lots of information on this in the forums.
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post by Lovehina »

OMG!!! It works perfectly...! :D Thank you so much Hybrid, this thing has been bugging me for some time now.
Anyways I managed to patch and compile it without any problems...!

By the way, here is a screenshot. In this scene I have a rotating 5000+ poly model and 3 dynamic lights, and all the lights are updating correctly! :P
Image
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

hey hybrid, I opened irrlicht 1.0 source and I find this commented out

Code: Select all

	// transform vertices and normals
	/*core::matrix4 mat = frame->LocalMatrix;
	mat.makeInverse();

	vcnt = buf->Vertices.size();
	for (s32 u=0; u<vcnt; ++u)
	{
		mat.transformVect(buf->Vertices[u].Pos);
		mat.inverseRotateVect(buf->Vertices[u].Normal);
	}*/
might it be why irrlicht 1.0 still mess up X files animations normals? I heard you implemented your patch with new 1.0 version, maybe you forgot to uncoment them and we got it compiled like this :D


by the way, I can't compile with DX sdk because I use VS6.0 (the company I work for has originals, but I have been working there for 2 days only)
what is this thing...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, this is something different. Unfortunately, the .x loader is still quite messy with lots of dead code in it. I did not touch this loader very much, yet. But the normals are transformed somewhere else, and I think that this code does not make sense anyways.
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

Sorry to go offtopic, but WOW does that model look smooth! nice job with the lighting, too!
Post Reply