LOD and jME3

Ok, I arrived to some working procedure.

First export the object from Blender.
Then run OgreCommandTool to generate LOD for the model.
Next import the generated xml file into JME => convert to J3O. DO NOT USE advanced conversion.
Open the J3O to set the various materials… if necessary.

With these steps, the J3O model has up to 10 LOD levels. They can be selected/viewed from the scene composer, but the displayed number of vertices/faces is not impacted by the chosen LOD. Nor the wireframe grid…

Hope that helps.

1 Like

If the advanced converter fails (that is the command line tool created by the inventors of this file format) then I suggest you should blame the model file and its creator first, namely the blender exporter plugin.

Yes you’re probably right. I don’t blame on JME importer. Just wanted to share my finding, since it seems quite desired this late.

I really don’t know why it often fails in JME, while it works with the Ogre commandLine (except when setting the distance… why ?).

Similrarly, why do LODs are not exported by blender, while it says it do it so is a mystery to me.

@yang71 said: Yes you're probably right. I don't blame on JME importer. Just wanted to share my finding, since it seems quite desired this late.

I really don’t know why it often fails in JME, while it works with the Ogre commandLine (except when setting the distance… why ?).

Similrarly, why do LODs are not exported by blender, while it says it do it so is a mystery to me.

Yeah, I don’t want to project the blame actually but your attempts to problem-solve :wink: I am the guy who doesn’t like workarounds but rather waits and works on the actual issues :stuck_out_tongue_winking_eye:

@yang71 I am having exactly the same issue.

First export the object from Blender. Then run OgreCommandTool to generate LOD for the model. Next import the generated xml file into JME => convert to J3O. DO NOT USE advanced conversion. Open the J3O to set the various materials… if necessary.

With these steps, the J3O model has up to 10 LOD levels. They can be selected/viewed from the scene composer, but the displayed number of vertices/faces is not impacted by the chosen LOD. Nor the wireframe grid…

1- export to Ogre? I get a .scene model and a .material (no .xml)
2- How can I run the OgreCommandTool to generate LOD for the model? the only way I know is the avanced binary conversion in JMP. Am I missing another tool?

thanks guys

Well it seems to me that Blender no longer generates the mesh.xml file. Instead it generates the ‘binary’ version : .mesh

OgreCommandTool is downloadable from their site. It contains a text file explaining what to do.
https://sourceforge.net/projects/ogre/files/ogre-tools/1.7.2/OgreCommandLineTools_1.7.2.zip/download

For my part, I’m using :
OgreXMLConverter -l 10 -p 30 object.mesh

It the generates a object.mesh.xml file with 10 Lods levels, each containing 30% less faces.

I don’t use the -p distance, which crashes on my computer…

cool so I did it and generated the xml file, but when I try to import it into JMP I get an error and if I drag and drop and then try to convert to j3o I get Error Converting AssetNotFoundException

Sorry, I can’t help you right now. Maybe you could post more details ?

You do import the XML file, not the scene file, do you ? And no advanced conversion either ?

ok I managed to get it to work here are my steps:

1- export from blender using Ogre (I get 2 files: .mesh.xml and .material).
2- I run the Ogrecommandtool on the mesh.xml in order to create the .mesh file. ( i know weird)
3-Then Rerun the command on the .mesh to create the .mesh.xml that has the LOD files in it now.
4- import into JMP however the object on the preview looks trimmed (half of it is missing)!!!

PROBLEM 1: Whether .j3o or .mesh.xml they both load but the model is missing half of it!!! what am I missing?
PROBLEM 2: The model is loaded as a node, I need it to be loaded as a geometry!!! How can I fix that?

@nightwolf911 said: PROBLEM 2: The model is loaded as a node, I need it to be loaded as a geometry!!!! How can I fix that?

You don’t need it as a geometry. Fix your code to work with nodes instead. You can never count on a loaded model being a Geometry since it may have to be split up to make the final model, multiple materials, etc.

gotcha… I fixed them…

btw when I set say 5 LODs instead of 10 in ur example, does that mean that the % gets readjusted? or the more LODs I have the more reduction?

thanks and sorry in advance if it’s a silly question

No, it is not. You simply read too fast and skipped words…

The percentage is PER LEVEL.
So if your model has 64K faces, with p=50%,

  • LOD 1 would be +/- 32K faces
  • LOD 2 would be +/- 16K faces
  • LOD 3 would be +/- 8K faces
  • LOD 4 would be +/- 4K faces

More LODs just implies more distance steps.

3 Likes

Great thanks for the explanation @yang71

one more question and i’m out :slight_smile: I noticed when I convert to Ogre I get a deformed object. At the beginning I thought it was a clipping issue but then it turned out that I am getting the whole object but more like squeezed in. Any idea why this would happen? It looks perfect in Blender but this happens when I import it to JMP.

Example: say I have a shelf with a certain height, in JMP I get the same shelf but the height is reduced

That’s because, as most newcomers to JME, you didn’t read the manual… not precisely at least.

You have to apply scale and rotation before exporting your object. If you use armature, it must have the same origin as the object. To be sure of that, I simply apply translation to both the object and its armature.

When you check the properties of your object in blender, it must show no rotation nor scale.

I always imported the blender directly into jMonkey and it got converted to j3o which in return I just used it and it worked fine… I am not sure what properties are you talking about…

Also this is new (after updated JMP) when I try to use the j3o object in the scene using this code:

Node teapotNode = (Node) assetManager.loadModel(“Models/player/player.j3o”);
Geometry teapot = (Geometry) teapotNode.getChild(0);

I get that it cannot convert a node to a geometry. but looking in the scene explorer I can only see a node and a mesh. why is the mesh considered a node?

PS: where does it mention that in the manual?

It is mentioned here : https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:external:blender#animations
There was another place, where it was written in big red letters, but I can’t find it today…

For the casting, them importer often build a deep tree of nodes. So your geometry may no be the child, but the child of the child of the child…
Just open the J3O in the scene composer…

1 Like

Thank you so much, I can’t thank you enough, I feel stupid that I missed it (assuming that my model is static and has no animations)

cheers

btw what was the crash u were getting when u set the distance? maybe I can help with that

@all, the binary command line converter is integrated in the SDK and you can invoke it by using “advanced import” for ogrexml or by just importing .mesh files like normal.

It doesn’t work for us and that’s why we’re doing it form the command prompt… for me nothing happens when I use advanced import.