Loading smooth model obj

Hi, this is my first message. I started learning jmonkeyengine from the exemples and tutorials. And know I have a situation: I created a model in Blender (starting from the default cube), putted a texture (basically changed the color), set it to be smooth, and then exported it as a OBJ file. When I load it from my code it is not smoothed. How to smooth it? Below is the code I use to load the OBJ.



package jmeteste;

import com.jme.scene.Node;
import com.jme.scene.TriMesh;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.ObjToJme;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;

/**
 *
 * @author leomcabral
 */
public class PernaObj extends Node {
    public PernaObj() {
        URL url = PernaObj.class.getClassLoader().getResource("jmeteste/perna.obj");
        ObjToJme converter = new ObjToJme();
        converter.setProperty("mtllib", url);
        ByteArrayOutputStream bo = new ByteArrayOutputStream();
       
        try {
            converter.convert(url.openStream(), bo);
            TriMesh model = (TriMesh) BinaryImporter.getInstance().load(new ByteArrayInputStream(bo.toByteArray()));
           
            this.attachChild(model);
        } catch(IOException ex) {
            System.out.println("Falhou!!!");
        }
    }
}





P.S.: Why I can not load my OBJ file as a Node like the examples? I have to load it as a TriMesh.

Most likely you have issues with blender exporter settings. Try different options when exporting your model and make sure to export normals.

what version of blender are u using?

mud2005 said:

what version of blender are u using?


I'm using 2.44 from the ubuntu 7.10 repository.

did you click 'normals' button when exporting? by default 'high quality normals' is checked but 'normals isnt. you dont need high quality normals selected just normals. I just did the same, exported a simple cube and it was smoothed in jme. Im using blender 2.45.


Why I can not load my OBJ file as a Node like the examples? I have to load it as a TriMesh.


I think your model must contain multiple meshes to load as a node.

Your objects probably use materials from coloring.  You are actually turning on and off lighting calculations by using the L key.  The hard thing to grasp is that when using materials no lighting calcs will turn your objects bright white because the materials are ignored. 

mud2005 said:

did you click 'normals' button when exporting? by default 'high quality normals' is checked but 'normals isnt. you dont need high quality normals selected just normals. I just did the same, exported a simple cube and it was smoothed in jme. Im using blender 2.45.


I unchecked 'high quality normals' and checked 'normals' and the OBJ was loaded as I want, thanks for your answers. Other thing I want to know is, I'm loading the OBJ file in a SimpleGame class and when I run the project and press 'L' key the OBJ turn itself white (and it is not white), it seams it lost it's texture. It's only a curiosity, because I did not put a lamp in the scene.