OBJ Model Texturing Problems
Posted by
Peter on
Nov 16, 2011; 5:53pm
URL: https://forum.jogamp.org/OBJ-Model-Texturing-Problems-tp3513440.html
I am trying to add a model loader to my jogl program. I have tried a number of implementations and the only one that seems to work is found here:
https://github.com/demoscenepassivist/SocialCoding/blob/master/code_demos_jogamp/src/framework/util/WavefrontObjectLoader_DisplayList.javaHowever I am having a problem getting textures to map on the loaded models correctly. The code that I'm using to load the texture is posted below, as well as the code that I use to texture.
private Texture loadTexture(String fileName) {
Texture tex = null;
try {
tex = TextureIO.newTexture(new File(fileName), true);
tex.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
tex.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
} catch (Exception e) {
System.out.println("Error loading texture " + fileName);
}
return tex;
}
palmTex.enable();
palmTex.bind();
gl.glPushMatrix();
gl.glTranslatef(150, 100, 800);
gl.glScalef(5f, 5f, 5f);
palm.callDisplayList(gl);
gl.glPopMatrix();
palmTex.disable();
And here are is the texture I'm trying to map:
http://imageshack.us/photo/my-images/257/palmt1.png/Finally, this is the resulting model:
http://imageshack.us/photo/my-images/827/badtex.png/Any insight on why this is happening would be greatly appreciated!