Importing models made in blender

Hi.  I am new to JME, and I am trying to figure out how I can import a .obj model from blender, and I seem to be having a problem.



I believe I am doing something wrong in blender.

I followed this tutorial to make my model: http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/UV_Map_Basics

(i did not add the star effect or render it in blender)

and exported it as an .obj file with the settings

context: selection only

extra data: edges, normals, high quality normals, UVs, materials

grouping: objects

object prefereces: apply modifiers, rotate x90

and I put the .obj file and the .mtl file in the directory I wanted to load them from : jmetest/data/model/



My model doesn't load.  I get a null pointer exception at the line

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



but I can load the maggie.obj file that is in the same folder.



I believe that I do not have the correct export settings.

Is it necessary to UV map an object, and assign a texture as a material in blender in order for jme to display it?  (i did this for this case)

or can I save the grey box that appears when you first open blender as a .obj file and load that into JME?



and also, if my object is made of only one mesh, is it okay to load it as a node?

i believe that if it is made of multiple meshes, I will not be able to load it as a trimesh, and have to load it as a node.

(I have tried loading it both ways)



Any help would be greatly appreciated.

-Eric













My object loading code:









public class TestLoadModel extends SimpleGame {



public static void main(String[] args) {

TestLoadModel app = new TestLoadModel();

app

.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG);

app.start();

}



protected void simpleInitGame() {





ObjToJme converter = new ObjToJme();

try {

URL objFile = TestLoadModel.class.getClassLoader().getResource(

"jmetest/data/model/theearth.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);

                        //load as a Trimesh if single object

Node model = (Node) BinaryImporter.getInstance().load(

new ByteArrayInputStream(BO.toByteArray()));

                        //load as a node if multiple objects

                        //Node model=(Node)BinaryImporter.getInstance().load(

                        //                new ByteArrayInputStream(BO.toByteArray()));

model.setModelBound(new BoundingSphere());

model.updateModelBound();

rootNode.attachChild(model);



} catch (IOException e) {

e.printStackTrace();

}







}

}

Might be outdated, by check: http://www.jmonkeyengine.com/wiki/doku.php?id=exporting_.obj_models_from_blender



Also, if you’re interested in animated model from Blender, many of us use MD5: http://www.jmonkeyengine.com/wiki/doku.php?id=exporting_animated_.md5_models_from_blender

Thanks



I think that one is for doing the uvmapping with gimp, but i think i still should be able to do it from blender if I want to.

I haven't tried any animations yet.  But I will try it soon.  Thanks.

or u can try the xml stuff, I see potential for this making blender into very nice level editor 

Hey, thanks.  I will definitely try it.

Single mesh models are imported into jME as a TriMesh, while a model with multiple meshes comes in as a Node.

Try using Spatial; both TriMesh and Node extend Spatial so your safe either way.



Also, you don't need the MTL file (unless there are custom materials that is); and it is a place for a possible error.

(UV verts come with the model, so you can just texture the model once in jME)



And you don't need to have the UV mesh applied to import into jME.

Thank you.

I tried loading the grey cube that is the blender startup model as a spatial, but couldn't get it to work.

Thanks for letting me know about the UV though.

whats the file size?



also, make sure the little lock (next to the layer buttons) in object mode is clicked when exporting



Maybe try re-importing the exported model back into blender.

hmm. It doesn't import back to blender.



and the file is 50.6 kb.