Lighting problem using getXJointNode addon by Electron

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.
jyon

Lighting problem using getXJointNode addon by Electron

Post by jyon »

greetings :)

first of all thanks for the great engine !! It really helps me a lot .

I have been playing with Electron's getXJointNode and finally got my model attached hair. but the lighting is not working the way it should work.

I have two .x files , one for model and one for hair. and created one lighting . but like the screenshots below my hair gets lighting from behind.

Image

Image

Image

I looked my .x file and found out the joint I am using to attach hair part of model is facing opposit way of model.. would it be the problem of this lighting ?

thanks and sorry for my english :)

jyon[/img]
jyon

hmm

Post by jyon »

it seems like above screenshots doesn't work so I upload 'em again -0-


Image

Image

Image


jyon
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Just a guess: maybe its because the matrices of the X-mesh are Z-flipped. How did you create the X-files?
It is like it is. And because it is like it is, things are like they are.
jyon

Post by jyon »

hmmm

We made both of them using lightwave. and export it using D-Storm's x-file exporter. settings were exactly same

dunno if this was what you wanted to know
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Does lightwave uses a right or left handed coordinate system? Irrlicht (and the DirectX format also) uses a left handed system.

I'm the author of the DirectX Exporter Mod for Blender. Blender uses a right handed system. The original exporter by Ben Omari would just flip the Z axis of the root matrix to convert the system. This works in most cases, but in some others it leads to problems. This is why I did a real conversion of all matrices in the modded exporter.

I dont know how the D-Storm exporter work. Maybe it uses the same "cheap" conversion.

I think getXJointNode returns a matrix, doesn't it? So it might be coordinate system problem that you have. But maybe it's a totaly different problem. Like I said I was just guessing...

Hm, could you post some (any) D-Storm exported X mesh file content?
It is like it is. And because it is like it is, things are like they are.
jyon

Post by jyon »

first of all thanks for your replies, jox

I think lightwave uses left handed coordinate system. the positive part of the Z-axis goes away from the screen , right ?

these are the two .x files used in above examlpe (without textures tho')
http://www.triongames.com/jyon/xfiles.zip

and getXJointNode returns a node afa I know.

hmm my question is .. there is only one light available on the scenemanager , why does head get light from behind and while body gets light from front ? could it be the coordinate system's fault ?

jyon
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

If also Y goes up and X to the right then its left-handed..

The X files look ok.

What happens if you place the hair mesh in the scene without attaching it with getXJointNode? Still wrong lighting?

Oh right, getXJointNode should return a node, should have figured it by the name. :) You make the hair a child of that node I guess.
It is like it is. And because it is like it is, things are like they are.
jyon

Post by jyon »

ok below is the screenshot without attaching it with body.

Image

if the hair goes where it should be (above head of course) the lighting is right I think.

but when I attach it with the body using getXJointNode then the lighting is the other way round ...

any suggestion ?

jyon
jyon

lighting doesn't seem right after model got animated

Post by jyon »

hmm maybe I think I know why.
I has nothing to do with getJointXNode at all .

I think light is applied before mesh gets animated thus false lighting after animated.

when I added one more light in front of model and slightly lower than the model itself , it lights bottom part of the face but not the bottom of the fist which gets animated.

I dunno if I made myself clear ..

any help with this problem ?
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Re: lighting doesn't seem right after model got animated

Post by jox »

jyon wrote: if the hair goes where it should be (above head of course) the lighting is right I think.
No, I don't think so. The (not attached) hair should be lit from the left (from the perspective of the screenshot) at that position. Try to position the hair approx to the head with setPosition and setRotation and then look how it's lighted.
jyon wrote:when I added one more light in front of model and slightly lower than the model itself , it lights bottom part of the face but not the bottom of the fist which gets animated.

I dunno if I made myself clear ..
yes you did :). I now that problem. It's a different problem (I think). It's because only the vertices get animated but not the vertex normals. And the vertex normals affect the lighting.
It is like it is. And because it is like it is, things are like they are.
jyon

Post by jyon »

hmm I think that is the exact problem. Vertex normals do not change after animation.
since the hair part is loaded to the scene facing oposite way of lighting,
when I get the hair part attached model (which is facing to the light) the hair part only gets lighting from behind. That is because the vertex normals of the hair part didn't change.

So, the problem is now , how do I get the vertex normals right after the animation ?

I looked thru the engine code. and void CXAnimationPlayer::modifySkin() does transfromation for the vertex. If I add a routine for the transformation of normals , would it fix the problem ?

or is there already such fix exist ?

jyon
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

jyon wrote:hmm I think that is the exact problem. Vertex normals do not change after animation.
since the hair part is loaded to the scene facing oposite way of lighting,
when I get the hair part attached model (which is facing to the light) the hair part only gets lighting from behind. That is because the vertex normals of the hair part didn't change.
Yea, but your hair is not animated, or is it? So the lighting should be ok when loaded and not attached. Which it is not... strange
jyon wrote: So, the problem is now , how do I get the vertex normals right after the animation ?

I looked thru the engine code. and void CXAnimationPlayer::modifySkin() does transfromation for the vertex. If I add a routine for the transformation of normals , would it fix the problem ?
Yes, this would fix the non-animated vetex problem. I did that too in my engine. But I doubt this will fix the other problem, but I might be wrong.
It is like it is. And because it is like it is, things are like they are.
jyon

solved :)

Post by jyon »

ok .. so it was the vertex normal problem after all . I patched the engine to compute vertex normal , and the light shows off fine :)

here are the screenshots
Image

Image

thanks a million jox! you helped me out a lot ^^

jyon
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Hey great. You're welcome. Oh well, then it was indeed the normals. :)
It is like it is. And because it is like it is, things are like they are.
ttom
Posts: 43
Joined: Tue Aug 26, 2003 3:43 am
Location: Taiwan

Post by ttom »

Dear jyon:
Do u do the animation on your model? when i do this the hair and body
move is strange? do u have this problem?
sorry for my poor english.
ttom
Post Reply