Material Definition to render an obj like it appears in Blender

Hello JME community!



So I’m new to JME and I’m currently working my way through the tutorials. What I’m trying to do isn’t for a game but actually for an academical purpose. My long term goal is to render a few scenes that test out LOD aspects with various test models. For this I need to focus on the graphics output purely on the model detail and nothing else. So what I’d like to do is render a mesh (exported from Blender, obj format) just like it appears in Blender, without a texture but a default grey shading. From the tutorials I gather that this is a question of writing the right material. With the unshaded material that is used in the first tutorials there is no vertex border visible at all in the mesh, it just becomes a silhouette. With the basic lighting shader it just looks really strange. Can you give me any pointers on how to render the meshes in JME just as they appear in Blender’s workspace?



Thanks in advance.

Make sure you also read the documents linked at the top of this page (and the page itself :)):

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:external:blender

I read that three times now but I’m not seeing what I’m missing.



Let’s start with something very simple. I have a model of a cup of tea with a single mesh imported in Blender. I installed the Ogre3D XML exporter script. The mesh has no textures. The mesh has no animations, normal maps or other kinds of shaders, it’s just a mesh. It has one material that has no fancy options checked except a diffuse and a spectacular color.



I go to export → Ogre3D (scene and mesh). The “Hello Assets” page suggest the following settings:


Activate the following exporter settings:

Copy Textures: YES
Rendering Materials: YES
Flip Axis: YES
Require Materials: YES
Skeleton name follows mesh: YES


I don't even have these settings. For me the export options look like this:
[image]http://puu.sh/1aGay[/image]

I uncheck everything except Export Scene, Export Mesh and Export Materials. I get 3 files, a .scene, a .mesh.xml and a .material. I copy those files into my project's assets/Scenes/ directory.

When I load the .scene via Spatial scene = assetManager.loadModel( "Scenes/cup of tea.scene" ); and attach it to the rootnode it displays a cube but not my cup of tea. I have no idea where that cube is coming from. If I load the mesh.xml the application crashes on startup. I can convert the .scene to a j3o file but it still just displays the cube.

So, what am I doing wrong? Wrong version of the Ogre exporter?

What version of blender are you using?



I use blender 2.63 with nightly SDK and directly import .blend to .j3o using the SDK. That works perfectly.

Blender 2.63 and Beta 3.0 of JME. I’ll try using the .blend file directly, thanks for the suggestion!

If you find your model just comes out black/empty then you need to update to nightly SDK. Blender changed their internal file format for 2.63 and SDK has been updated to cope but you might need nightly.

Perhaps you have the cube selected when you export?

Thank you for the replies. Yesterday was a national holiday so I’m only now getting back on this.



Momoko Fan: I thought so too, but I had deleted the standard cube out of the scene before exporting.



Anyway, I upgraded to the latest nightly build as zarch suggested and that helped a lot! It basically just worked immediately. At least loading and displaying the mesh.



When I converted the .blend file to j3o it displayed the following warning:

“The importer came accross mesh that points to a null material. Default material is used to prevent loader from crashing, but the model might look not the way it should. Sometimes blender does not assign materials properly. Enter the edit mode and assign materials once more to your faces.”



In Blender it does apply the material to the meshes, I’m not sure what I need to change in Blender so it works in JME too. in JME it currently renders the meshes unshaded. Though I’m already very happy I can at least load my scenes now.



Also, is there a way to load the camera (and light) position from the .blend scene too?

@thekaioshinde said:Anyway, I upgraded to the latest nightly build as zarch suggested and that helped a lot! It basically just worked immediately. At least loading and displaying the mesh.

RC2 is out :)

Oh right, that’s actually the version I downloaded too :slight_smile: It was in the nightly builds folder pretty much at the bottom and with a current date, didn’t realize it was out officially too.

@thekaioshinde said:
Oh right, that's actually the version I downloaded too :) It was in the nightly builds folder pretty much at the bottom and with a current date, didn't realize it was out officially too.

Yeah, you can keep the nightly update center off in it, its got all the fixes you need. Nightly mostly just causes trouble. :)

So, what about the camera and light position?



This SDK article on the blender import talkes about features and object conversions:



https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:blender?s[]=blender



So a Blender “Lamp” should become a light in JME. But how do I get at these things? I convert my .blender files to j3o I can display them fine, but it does not import the light and camera position. I don’t know how to get at the “LoadingResults” struct the SDK article talks about.