Importing OBJ and Clones

So I have gotten jME to import my OBJ files successfully, along with the corresponding UV map.  However when I clone the spatial into 3 other nodes the UV map image is lost and the clones only show up as non-textured objects.  Am I missing something, I am only setting the converter property so that is probably where I am going wrong.


        ObjToJme converter=new ObjToJme();

        URL modelUrl= getClass().getResource( "/className/models/outerTable.obj");
        ByteArrayOutputStream BO=new ByteArrayOutputStream();
        Spatial model=null;
        try {
            long time = System.currentTimeMillis();
            converter.convert( modelUrl.openStream(), BO );
        } catch (IOException e) {
  "damn exceptions:" + e.getMessage());
        try {
            long time=System.currentTimeMillis();
            ByteArrayInputStream stream = new ByteArrayInputStream(BO.toByteArray());
            model = (Spatial) BinaryImporter.getInstance().load( stream );
  "Time to convert from .jme to SceneGraph:"+ ( System.currentTimeMillis()-time));
        } catch (IOException e) {
  "damn exceptions:" + e.getMessage());
        CloneImportExport cloner = new CloneImportExport();
        cloner.saveClone( model );
        Node copy1 = (Node) cloner.loadClone();
        Node copy2 = (Node) cloner.loadClone();
        Node copy3 = (Node) cloner.loadClone();
        copy1.setLocalScale( new Vector3f( -1f, 1f, 1f ) );
        copy2.setLocalScale( new Vector3f( 1f, 1f, -1f ) );
        copy3.setLocalScale( new Vector3f( -1f, 1f, -1f ) );


Also, the vertices of my model seem to triple (actually it's like 2.3) when opening with jME, no other model loader seems to do this  :|
Model: 478 vertices
jME reports: 1129

Can you post a sample model with the tripling?

Mind if I email it too you?  I would rather not post it…

Hmm, here is my junk email account (edited out), I will just edit this post later.

If you send me an email I will respond with the model.

So, I figured out the texture thing.  Yes, I just needed to texture the node  :P, guess I should have tried that.

Also, I did send you the model.

Cool, so you are all set?  I got the email but have been entertaining guests this weekend so haven't had time to do much.  ://

Well, I am still seeing the vertices increased by a factor of 2.3, however it is not an issue I am going to loose a lot of sleep over right now.  So, yup I guess I am all set for now…

Have a good weekend :slight_smile:

You might try running com.jme.util.geom.GeometryTool.minimizeVerts(…) on the model.

It's possible that the obj file shares vertexes between faces, and those vertexes are replicated in order to be used in the other faces. If you're using indexed geometry then shared vertexes can be handled by hardware, not sure about how the obj loaders works in that case, though.

GeometryTool.minimizeVerts() did the trick, thank you renanse  :).  Although I am still having a problem getting my normals to flip after scaling by a -1 in order to mirror the object.  Any hints there would be awesome.

You might be able to use rotatePoints/Normals on the batch.