More news from the bug tracking front: It seems there's a bug in the method updateWorldData(float) of SimpleLightNode. The method currently uses some Quaternion called lightRotate to compute the direction for DirectionalLights and SpotLights:
public void updateWorldData(float time) {
super.updateWorldData(time);
if(light == null) {
return;
}
lightRotate = worldRotation.mult(localRotation, lightRotate);
switch (light.getType()) {
case Light.LT_DIRECTIONAL:
{
DirectionalLight dLight = (DirectionalLight) light;
dLight.setDirection(lightRotate.getRotationColumn(2,
dLight.getDirection()));
break;
}
case Light.LT_POINT:
{
PointLight pLight = (PointLight) light;
pLight.setLocation(worldTranslation);
break;
}
case Light.LT_SPOT:
{
SpotLight sLight = (SpotLight) light;
sLight.setLocation(worldTranslation);
sLight.setDirection(lightRotate.getRotationColumn(2, sLight
.getDirection()));
break;
}
default:
break;
}
}
I had some strange results when using SimpleLightNode to point DirectionalLights and SpotLights in some direction. The direction calculated by SimpleLightNode seemed quite random, so I did some debugging again and noticed some completely weird values in the lights' direction vectors at the end of the method.
The method's intention seems to be to use the Z-Vector of the quaternion's rotation matrix as the direction, and as the node's world rotation is already being updated at the beginning of the method, I figured that simply using the worldRotation Quaternion instead of lightRotate and completely ignoring the latter might work. And... Tadaaah, it worked! :D
If I'm not completely wrong and have misunderstood the idea behind SimpleLightNode this is a bug...
Oh, and by the way, I think the call [pre]dLight.setDirection(lightRotate.getRotationColumn(2, dLight.getDirection()));[/pre] could be trimmed down to [pre]lightRotate.getRotationColumn(2, dLight.getDirection());[/pre] :wink:
One more side note: As I tested positioning lights, I also tried using DirectionalLight, but this one seemed completely screwed up. For some directions it worked fine, for other directions the light pointed in a different direction than the one I specified and in some cases it almost completely disappeared. WTF? :|
I haven't figured out why that is yet, but as I currently don't need any DirectionalLights for the application I'm developing, I'll leave it to someone who knows more about that stuff than me to find out :wink:
EDIT: In this topic this problem (about the SimpleLightNode) has already been mentioned, and according to the replies, it should already have been fixed...?
EDIT 2: The problem with DirectionalLight does definitely NOT result from the problem with SimpleLightNode. I tested the directionalLight separately and the results were... different, but still wrong. ^^
Anyway, the issue with DirectionalLight might still result from something that I've misunderstood or implemented the wrong way, so any confirmation on this would be appreciated
EDIT 3: Changed the title, as I'm quite sure now that the bug is not in SimpleLightNode, but in BumpMapColorController (see second page).