Author Topic: Maximum detail allowed for model?  (Read 2859 times)

Angelo

  • Jr. Member
  • **
  • Posts: 32
Maximum detail allowed for model?
« on: June 19, 2012, 06:18:50 PM »
Hi. Is there any kind of limit to the maximum amount of detail for a model to be loaded in Bonzai Engine? I am trying loading a model with 27K vertices and 45K faces, through an AsyncModel, and the .get() for the Model in render() always returns null after several minutes.

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Maximum detail allowed for model?
« Reply #1 on: June 19, 2012, 06:30:11 PM »
I successfully loaded another model, with 14K vertices and 24K polygons, in only 18 seconds. But this model (twice as big) for some reason never gets loaded.

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Maximum detail allowed for model?
« Reply #2 on: June 19, 2012, 07:50:56 PM »
The limit to number of vertices and indices is maximum value of integer (which is way above 45k).

Depending on the model format you're using (like dae, obj and other), loading huge model can takes lot of memory and cpu time (especially if you running on an android device). If you have converted in jmf, loading just be very fast on all platforms.

You can check the loading status of an AsyncModel with getLoadState or isLoaded/isLoading/isFailed.

If you think there's some problem with your model, send me to contact email (or a link where I can get it) and I'll give a look.
In the meantime, the only thing I can suggest would be to launch in debug and look for thread status,ortry to load it in the viewer.
« Last Edit: June 19, 2012, 07:52:53 PM by jerome_j »

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Maximum detail allowed for model?
« Reply #3 on: June 21, 2012, 12:55:58 PM »
I thought the problem was with the format I used, OBJ, which might have been too slow to parse. In fact, I tested the getLoadState() as you suggested, and the loading actually fails. I even switched to a binary format such as 3ds. It still fails. I am working on the Android version of Bonzai Engine. Maybe that is the cause of the problem? I merged the models I need to load in a single 166K-polygon model, and I tried loading it in the Bonzai Engine viewer, and it works fine. Here is a link to this model: https://dl.dropbox.com/u/14911350/scene.3ds

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Maximum detail allowed for model?
« Reply #4 on: June 21, 2012, 01:45:17 PM »
The loading exception is probably some kind of out of memory.

Quote
I am working on the Android version of Bonzai Engine. Maybe that is the cause of the problem?
The problem is limitation on your device which has less memory and slower cpu. All model reader are heavy in memory usage for reading and converting model into engine format, except jmf/jma which are heavily optimized.

Therefore, on android, we only advice to use jmf (or jma) format without lzma compression and texture in dds or tex using opengl es compression (see tutorial 16).
If you have many models or need to update them regularly, the best way to manage the conversion would be by using a batch tool or by importing the models in the editor and let him build optimized data for mobile device.

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Maximum detail allowed for model?
« Reply #5 on: June 21, 2012, 01:46:36 PM »
I see. Ok, thank you very much.

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Maximum detail allowed for model?
« Reply #6 on: June 25, 2012, 02:57:00 PM »
I tried converting my model in the JMF format and visualizing it in my Android application. I use the same code for the application, which works with OBJ models. The only difference now is that the ModelReaderSettings passed to "loadModelAsync" contains a stream for a file that ends with ".jmf" instead of ".obj". Anyway, the model loading fails, as I can see by calling asyncModel.getLoadState().

Should I change something in my code to load JMF models instead of OBJ models?

P.S. The JFM file that I'm using is loaded correctly by the Bonzai Engine Viewer.

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Maximum detail allowed for model?
« Reply #7 on: June 25, 2012, 03:16:39 PM »
There should not be any difference loading jmf file compared to obj, except if the jmf file is compressed using lzma (if specified in ModelWriterSettings with lzmaCompression). Lzma compression is not recommended in android (slower reading) but if you're using it make sure to include lzma.jar third party in your android project.

I'll make a test in android this evening with your model to see what's going wrong.

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Maximum detail allowed for model?
« Reply #8 on: June 25, 2012, 04:32:33 PM »
No, the model is not compressed. Here is a link to the JMF model: https://dl.dropbox.com/u/14911350/model.jmf.

This is the code I use to load the model.


Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Maximum detail allowed for model?
« Reply #9 on: June 25, 2012, 05:02:40 PM »
To be sure that the problem is not caused by errors in my code, I recreated the experiment using just the code of this tutorial: http://bonzaiengine.com/tutorials.php?id=17.

Again, the OBJ teapot is loaded correctly.
But my JMF teapot is not loaded.

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Maximum detail allowed for model?
« Reply #10 on: June 25, 2012, 07:26:11 PM »
They was a regression in jmf reader of the build 26-05-2012. I tought the fix was already pushed in dev build and forgot to track in changelog.

I've made a new build today: 1.2.5 25-06-2012 today, if you upgrade it should works fine with your teapot and your building model.
« Last Edit: June 25, 2012, 07:27:26 PM by jerome_j »

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Maximum detail allowed for model?
« Reply #11 on: June 25, 2012, 07:39:04 PM »
Perfect. Now it works. Thank you very much. :)