Hi, im sure this is a stupid question but dont have any idea of what it could be
im trying to change a material texture trough a method, I first set it in the constructor with no problem, but when i call it from the “Ojo_der” method just throw me a NullPointerException, i dont have any idea of why, any help with this please?
thx
package mygame;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
/**
*
* @author Willer
*/
public class Bicho {
public Spatial modelo;
public Node modeloNode;
private AnimChannel channel;
private AnimControl control;
public Material Ojo_der_mat;
AssetManager assetManager;
Material Ojo_izq_mat;
Bicho(AssetManager assetManager,Node rootNode){
modelo = assetManager.loadModel("Models/Adan.j3o");
modeloNode = new Node();
modeloNode.attachChild(modelo);
rootNode.attachChild(modeloNode);
control = modelo.getControl(AnimControl.class);
channel = control.createChannel();
//channel.setAnim("inicial");
Ojo_der_mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
Ojo_der_mat.setBoolean("UseMaterialColors",true);
Ojo_der_mat.setColor("Ambient", ColorRGBA.White);
Ojo_der_mat.setColor("Diffuse", ColorRGBA.White);
Geometry Ojo_der = (Geometry) modeloNode.getChild("Ojo_der");
Ojo_der.setMaterial(Ojo_der_mat);
Ojo_izq_mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
Ojo_izq_mat.setBoolean("UseMaterialColors",true);
Ojo_izq_mat.setColor("Ambient", ColorRGBA.White);
Ojo_izq_mat.setColor("Diffuse", ColorRGBA.White);
Geometry Ojo_izq = (Geometry) modeloNode.getChild("Ojo_izq");
Ojo_izq.setMaterial(Ojo_izq_mat);
Ojo_der_mat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/abierto.png"));
Ojo_izq_mat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/abierto.png"));
//Animar("inicial");
Ojo_der();
}
void Animar(String animacion){
channel.setAnim(animacion);
}
void Ojo_der(){
Ojo_der_mat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/abierto.png"));
}
void Ojo_izq(String ojo){
//Ojo_izq_mat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/" + ojo + ".png"));
}
}