When I try to texture an imported model, the texture doesnt show up. The model is there, but it just has its material color, and no texture. The model is from the blender (jme xml). How do i make the texture show up? Sorry, this might seem like i want the code to be spoon fed.
Code:
Import model:
String XMLFileName = "Box.xml";
URL modelURL = this.getClass().getClassLoader().getResource(XMLFileName);
XMLtoBinary converter = new XMLtoBinary();
JmeBinaryReader jbr = new JmeBinaryReader();
jbr.setProperty("bound", "box");
ByteArrayOutputStream BO = new ByteArrayOutputStream();
try {
converter.sendXMLtoBinary(modelURL.openStream(), BO);
boxNode = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
} catch (Exception ex) {
ex.printStackTrace();
}
boxNode.updateModelBound();
boxNode.setLocalScale(4.6f);
Texturing, adding material, lighting:
//create boxNode renderStates
LightState ls = display.getRenderer().createLightState();
MaterialState ms = display.getRenderer().createMaterialState();
PointLight pl = new PointLight();
Vector3f loc = camera.getLocation();
pl.setLocation(new Vector3f(loc.x -10,loc.y +10, loc.z - 20));
ls.attach(pl);
ls.setEnabled(true);
ms.setColorMaterial(MaterialState.CM_DIFFUSE);
ms.setEnabled(true);
//Texture the box
Texture boxTex = TextureManager.loadTexture(
TiltBall.class.getClassLoader().getResource(
"BoxTex.jpg"),
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR);
TextureState boxTS = display.getRenderer().createTextureState();
boxTS.setTexture(boxTex);
boxTS.setEnabled(true);
boxNode.setRenderState(ls);
boxNode.setRenderState(ms);
boxNode.setRenderState(boxTS);
It seems to me that im missing some one little method call that will make it all work. How do i fix this?
NOTE: Yes, I do call rootNode.updateRenderState().