Texture Imported Model

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.


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) {

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));

      //Texture the box
      Texture boxTex = TextureManager.loadTexture(
      TextureState boxTS = display.getRenderer().createTextureState();


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().

Sounds like the model does not have texture coordinates assigned.

Might be. How do i assign them then? In the blender exporter, i do export the texture coordinates. Ive tried it with and without textures there. Is there any way to assign them manually in the program? Or should I use a different modeler? What should i do? Nothing ive tried in the past few days helps.

Thank you for your patience!

Email me your blend and xml files, and I'll have a look. How do you generate your texture coords in blender? Blender has two kinds of texture coords, one of them is rarely used, and not supported by the exporter.

I sent it. Sorry It took so long. Thanks.

:-)The helpfullness of this forum and all its members still amazes me. Nothing compared to most other forums! :slight_smile:

I think I found your problem. Apparently, Blender doesn't give python scripts access to the texture coordinates if there is no image assigned to the faces of a mesh. So, to have your texture coordinates exported, just select your model in Blender, press "F" (face edit mode), and pick an image in an UV/Image window to assign it to the faces.

Hope that helps


I’ve been trying to get that to work for some time now. Ill keep trying, but I have one question which might help: Do i need to assign each face an image?

NOTE: I might be doing something wrong (in blender), I’m not too good at that yet, so here’s a screenshot:

It doesnt work. Sorry. Any other ideas? If not, what other modeler that can do bone animation is supported by jme?

Thanks for all your help!

I believe it does work, I have tried it with the very files you sent me. In the screenshot you posted, click the image file select button in the Image Window at the right screen area. It  is the one with the up/down arrows on it, the rightmost one in your screenshot. Then, select any image file you have previously loaded, or load a new one. Only after you have done that, the exporter will recognise the texture coordinates for your model, and thus be able to export them.

Youre Right! Stupid me…

I think part of the problem was that i had a LightState and a MaterialState on that node. When i removed them, I could see the texture. Without, it was black.  XD Feeling jubilant  :lol:

Thanks for your help, hevee! Your script works great now!