Texture Problem

Hi everybody!



I'm loading my OBJ object and it's texture into my application via the OBJtoJME-Converter. I also use the ResourceLocatorTool, to get valid URLs of the .obj and the .mtl file. The object is shown correctly and it also has it's texture. My problem occurs, when I'm rotating the camera to a special direction. At this moment the application crashes and I get the following error-message:




java.lang.NullPointerException
   at com.jme.scene.state.TextureState.getTexture(TextureState.java:271)
   at com.jme.scene.state.lwjgl.LWJGLTextureState.apply(LWJGLTextureState.java:845)
   at com.jme.renderer.lwjgl.LWJGLRenderer.applyStates(LWJGLRenderer.java:1743)
   at com.jme.renderer.lwjgl.LWJGLRenderer.draw(LWJGLRenderer.java:979)
   at com.jme.scene.TriMesh.draw(TriMesh.java:240)
   at com.jme.scene.Spatial.onDraw(Spatial.java:475)
   at com.jme.scene.Node.draw(Node.java:521)
   at com.jme.scene.Spatial.onDraw(Spatial.java:475)
   at com.jme.scene.Node.draw(Node.java:521)
   at com.jme.scene.Spatial.onDraw(Spatial.java:475)
   at com.jme.scene.Node.draw(Node.java:521)
   at com.jme.scene.Spatial.onDraw(Spatial.java:475)
   at com.jme.renderer.lwjgl.LWJGLRenderer.draw(LWJGLRenderer.java:1220)
   at com.jme.renderer.pass.RenderPass.doRender(RenderPass.java:52)
   at com.jme.renderer.pass.Pass.renderPass(Pass.java:96)
   at com.jme.renderer.pass.BasicPassManager.renderPasses(BasicPassManager.java:90)
   at com.jme.app.SimplePassGame.render(SimplePassGame.java:83)
   at com.jme.app.BaseGame.start(BaseGame.java:87)
   at controller.FunctionController.main(FunctionController.java:1408)



Can anyone give me a hint, where this problem actually comes from? Why is texture null and only at this specific position of my object? Do I have to refresh or update something after loading? I'm really stuck and I can't imagine where exactly this problem comes from.

Best regards,

ALEX

This is the point where the error is thrown, because texture is null:



    public Texture getTexture(int textureUnit) {
        if (textureUnit < texture.size() && textureUnit >= 0) {
            return texture.get(textureUnit);
        }

        return null;
    }



I found this post here (http://www.jmonkeyengine.com/forum/index.php?topic=13732.msg99582#msg99582), where dhdd seems to have fixed exactly this problem. Why is this fix not included in the repository?

Best regards,

ALEX

Sorry for my last post, of course the changes from dhdd are part of the repository. Nevertheless I get the NullPointerException always when I'm rotating the camera to a specific position  :frowning:

Damn, I just found out where this problem came from. It was just because the obj-file was loaded and attached to the scene graph twice. Now I removed one and it works.  :smiley:

It's cool to see that you're making progress :smiley: It actually is really nice that you sort of 'document' your progress like this though (even if it's partially by accident), especially the part about replying to say the problem is solved and how you did it.

I thought (and I hope not) maybe someone else will have a similiar problem someday and I hope this will help him, then  :wink: