Blocky textures on .OBJ files

Hi all,



I’ve been searching the boards, but am at a loss as to how you can have anti-aliased (mipmapped?) textures on .OBJ files (specifically OBJ files exported from Google SketchUp).  From what I have found, there are ways to do it if you are specifying a separate Texture (e.g. “TextureManager.loadTexture”), but my textures are being read from a .MTL file automatically by the ObjToJme converter.



To better illustrate my problem, here is a screenshot of how the object looks in SketchUp.  The textures are smoothed/filtered (not sure on the term):



Click here for Full screenshot



Here is how the exported .OBJ currently looks in jME:



Click here for Full screenshot



The code I am using is basically the “TestObjJmeWrite” sample:

public class TestObjJmeWrite extends SimpleGame{

    public static void main(String[] args) {

        TestObjJmeWrite app=new TestObjJmeWrite();

        app.setDialogBehaviour(AbstractGame.FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG);

        app.start();

    }

    protected void simpleInitGame() {

        ObjToJme converter=new ObjToJme();

        try {

            URL objFile= TestObjJmeWrite.class.getClassLoader().getResource(“data/Test.obj”);

            converter.setProperty(“mtllib”,objFile);

            converter.setProperty(“texdir”,objFile);

           

            ByteArrayOutputStream BO=new ByteArrayOutputStream();

            System.out.println(“Starting to convert .obj to .jme”);

            converter.convert(objFile.openStream(),BO);

            System.out.println(“Done converting, now watch how fast it loads!”);

            long time=System.currentTimeMillis();

            Node r=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));

            System.out.println("Finished loading time is "+(System.currentTimeMillis()-time));

            r.setLocalScale(.1f);

            rootNode.attachChild(r);

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

}





There must be something simple I’m missing :?.  Any help would be much appreciated!  :slight_smile:

Looks like the default texture settings (LINEAR/LINEAR with tex compression) for OBJ loading are not ideal for your model.  I don't recall, but I doubt the old OBJ loader had a way to modify the texture settings during load.

I had this problem a while back, for me it was the compression. I clear the texture state of my .obj models and apply again with

Image.GUESS_FORMAT_NO_S3TC

option and the blocky goes away.  :slight_smile:

Hi mud2005/renanse,



Thanks for your suggestions.  Sorry to be a complete noobie, but I've tried playing around with setting "GUESS_FORMAT_NO_S3TC", but I can't seem to get it looking any better, but I'm probably doing it wrong.



Would you be able to give me a code sample of how to set this GUESS_FORMAT_NO_S3TC flag in my code (as listed in the first post)?  Do I really have to reload each individual texture (bearing in mind that some .OBJ files could have lots of Textures each)



Many thanks for your help.

TextureManager.loadTexture(url,
               Texture.MM_LINEAR, Texture.FM_LINEAR,
               Image.GUESS_FORMAT_NO_S3TC, 1.0f, false);

Thanks mud2005,



I'm still not managing to get it to work, but I'll keep playing at it.



renanse: You say "old OBJ loader"… is there are newer way of doing this?  I just pulled the code from the latest example (test) code.  As I have multiple textures per .OBJ file, I really dont want to be re-applying every texture manually.



Thanks all again for your assistance.

I just mean, it was made a long time ago and aside from tweaks to decrease processing time and so forth, has not been looked at for feature support in quite a while.