3 days no respond
i tried PointLights, but i had problem with only one PointLight working…
found this topic:
in my code i prepare “parts” and use them via cloning.
Please note im using PBR materials - but one point light work, as i know more should too.
So i started doing some custom LightNode(because LightNode clone dont work too).
(init method is executed on cloned node)
i tried a lot of implementations, dont know why it dont work. here are some:
no point lights working with below:
import com.jme3.light.PointLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.LightNode;
import com.jme3.scene.Node;
/**
*
* @author oxplay
*/
public class LampContainer extends Node {
public float radius;
public ColorRGBA color;
public LightNode light;
public LampContainer(float radius, ColorRGBA color) {
this.radius = radius;
this.color = color;
}
public void init(){
light = new LightNode("Light", new PointLight(Vector3f.ZERO, color, radius));
App.getRootNode().attachChild(light);
updateLightPos();
}
@Override
public void setLocalTranslation(float x, float y, float z) {
super.setLocalTranslation(x, y, z);
//updateLightPos();
}
@Override
public void setLocalTranslation(Vector3f localTranslation) {
super.setLocalTranslation(localTranslation);
//updateLightPos();
}
@Override
protected void updateWorldTransforms() {
super.updateWorldTransforms();
//updateLightPos();
}
@Override
protected void setParent(Node parent) {
if(parent == null){
App.getRootNode().detachChild(light);
}
super.setParent(parent); //To change body of generated methods, choose Tools | Templates.
}
private void updateLightPos(){
if(light != null){
//light.setLocalTranslation(this.getWorldTranslation());
}
}
}
no light with below too:
import com.jme3.light.PointLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
/**
*
* @author oxplay
*/
public class LampContainer extends Node {
public float radius;
public ColorRGBA color;
public PointLight light;
public LampContainer(float radius, ColorRGBA color) {
this.radius = radius;
this.color = color;
}
public void init(){
light = new PointLight(Vector3f.ZERO, color, radius);
Inversion.app.getRootNode().addLight(light);
updateLightPos();
}
@Override
public void setLocalTranslation(float x, float y, float z) {
super.setLocalTranslation(x, y, z);
updateLightPos();
}
@Override
public void setLocalTranslation(Vector3f localTranslation) {
super.setLocalTranslation(localTranslation);
updateLightPos();
}
@Override
protected void updateWorldTransforms() {
super.updateWorldTransforms();
updateLightPos();
}
@Override
protected void setParent(Node parent) {
if(parent == null){
Inversion.app.getRootNode().removeLight(light);
}
super.setParent(parent); //To change body of generated methods, choose Tools | Templates.
}
private void updateLightPos(){
if(light != null){
light.setPosition(this.getWorldTranslation());
}
}
}
to the last one, when i move
light = new PointLight(Vector3f.ZERO, color, radius);
Inversion.app.getRootNode().addLight(light);
updateLightPos();
to constructor method, i see one point light only. this is certain, because its cloned and clone dont work it seems. Anyway im not quite sure, why it dont work when this 3 lines are in init method that is executed on already cloned node…
i will work on it more, but wanted to share that something wrong is with PointLight.(at least with cloning - still)