Position of PointLight not updated?

I like to change the position of a point light in a programmatic way:
[java]
myPointLight.getPosition().multLocal(10f);
[/java]
But the new position gets not rendered. But the same code works for spot lights:
[java]
mySpotLight.getPosition().multLocal(10f);
[/java]

What makes the difference? Do I have to use a LightNode just for an initial change of the position?

[java]what is happening with the source java source tag?[/java]

never go object.getXX().setXX(), always use object.setXX()

@normen said: never go object.getXX().setXX(), always use object.setXX()
When you want to change a position vector you first have get it. That is what "multLocal" is good for.

:roll:

I think that was a test, right :troll:

@mathias4u said: I think that was a test, right :troll:
Yes, indeed, I don't know why I conducted it anyway. I told myself its useless seeing if you would listen before. But thanks for reminding you're only trolling.
@mathias4u said: When you want to change a position vector you first have get it. That is what "multLocal" is good for.

Read this very carefully.

This:
someThing.getPosition().multLocal()

Is NOT THE SAME AS:
Vector3f pos = someThing.getPosition();
pos.mult() or pos.multLocal() or whatever
someThing.setPosition(pos)

In the first case, you completely remove the engine’s ability to detect that things have changed and update the 900 other things that it needs to keep track of.

In the second case, you do it properly and everything works.

You can choose which one… I recommend the second. And reading more carefully.

2 Likes

Also, stow the attitude.

Not the best thing in the world as chances are YOU will need a whole lot more help down the road.

In the first case, you completely remove the engine’s ability to detect that things have changed and update the 900 other things that it needs to keep track of.

Then the engine is not able to track it. Have you ever seen an OR mapper? In general there are a lot of chances to track such changes. As I already said , there is no problem with spot lights because “mySpotLight.getPosition().multLocal(10f);” works fine.

I only need to know why it doesn’t work for point lights.

In the second case, you do it properly and everything works.

In the case of point lights both approaches do not work. Updating their position by setPosition(…) or multLocal(…) has no effect.

@mathias4u said: Then the engine is not able to track it. Have you ever seen an OR mapper? In general there are a lot of chances to track such changes. As I already said , there is no problem with spot lights because "mySpotLight.getPosition().multLocal(10f);" works fine.

I only need to know why it doesn’t work for point lights.

In the case of point lights both approaches do not work. Updating their position by setPosition(…) or multLocal(…) has no effect.

An OR mapper doesn’t have to check 60 times a second for a large number of objects.

Good luck with your coding. You may have found a bug in point lights but I no longer care to participate in this thread.

Unlike Spatials Lights are not scenegraph objects. Their position is set in world space, there is no local to world transformation, No update flags are set on the setPosition so the getPosition().set() shouldn’t matter in this particular case.
Though it’s still bad practice, because you can’t assume what the setPosition() does and the getPosition().set() pattern just bypass whatever processing the setPosition would have.

Now about your issue, I’m very surprised. Lights are very similar and SpotLight has been done based on PointLight.
I’d like to know what you are doing exactly, and ideally I’d like you to make a small test case so I can look into it.