Author Topic: Running the ModelLoading tutorial on Android  (Read 4998 times)

Angelo

  • Jr. Member
  • **
  • Posts: 32
Running the ModelLoading tutorial on Android
« on: April 20, 2012, 08:32:42 PM »
Hi. I am trying to run the ModelLoading tutorial on Android. I succeeded running it on my PC, and I tried to run the same code on Android, but it does not work: only the background is drawn, no model, no text. I used the original tutorial codes, and just made small modifications to make it usable both on Android and on my PC. I marked my modifications with "ANGELO". This is the code I use:

TutorialSelector.java:

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Running the ModelLoading tutorial on Android
« Reply #1 on: April 20, 2012, 08:33:42 PM »
ModelLoading.java:

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Running the ModelLoading tutorial on Android
« Reply #2 on: April 20, 2012, 08:34:15 PM »
ITutorial.java:

Main.java

As I said, it works well on my PC. So I tried to use the same code on Android. The files ITutorial.java, ModelLoading.java and TutorialSelector.java are the same. Plus, I use BonzaiEngineActivity.java (which I found in the tutorials too; no modifications) and my own Bonzai_Test_AndroidActivity.

BonzaiEngineActivity.java

Bonzai_Test_AndroidActivity.java

In the Android Manifest, I had to add BonzaiEngineActivity.

And I put all the necessary files (models, GUI, fonts) in the "assets" folder. But as I said, it does not work. I only get a grey background.

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Running the ModelLoading tutorial on Android
« Reply #3 on: April 20, 2012, 08:48:43 PM »
ModelLoading is not intended to run on android. It does not initialize any shader, so nothing will be rendered with a opengles 2 context (ie android).
If you wish to run it on android, you'll have to initialize shader, as shown in android tutorials and other tutorials (seach for ShaderList).

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Running the ModelLoading tutorial on Android
« Reply #4 on: April 20, 2012, 08:52:26 PM »
I tried that one, but probably I wrote wrong code, because nothing changed.
Anyway, shouldn't I at least get the text rendered, the one that explains the keyboard commands and prints FPS, geometry information, etc.?

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Running the ModelLoading tutorial on Android
« Reply #5 on: April 20, 2012, 08:57:36 PM »
It would be better to start from android tutorial (ModelDemo, BeStandaloneTutorial, ModelLoadingStandalone, some other initialize shader too) code which initialize shader properly, than reusing TutorialSelector which is not made for any kind of reuse.
In all the code you shown, nothing intialize shader so it will surely render nothing on android.

The ui text could only be rendered if you have the nifty gui theme jar in your project, may be it's missing.
« Last Edit: April 20, 2012, 08:59:34 PM by jerome_j »

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Running the ModelLoading tutorial on Android
« Reply #6 on: April 20, 2012, 09:22:47 PM »
Ok, now I am using the ModelDemo. I finally managed to see a model. But it's all white. I changed the LightingAlgo of Light0 to PerVertex, and the model gets all black. Again, I marked with "ANGELO" the modifications I made to the original code. Any idea?


jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Running the ModelLoading tutorial on Android
« Reply #7 on: April 20, 2012, 09:40:07 PM »
Textures are certainly not loaded due to addPathInTextureFinder = false. You should not use that, it will force searching texture only in path registeredmanually (ie "/textures/").

If you wish to use dynamic lights, you'll also have to setup lighting properly, by using  a LightManager object as shown in some other tutorial (or in ModelDemo version below).

I've update ModelDemo by removing addPathInTextureFinder, added lighting initialization and asynchronous loading.
You can get the lastest source code online (bottom of the page).
« Last Edit: April 20, 2012, 09:49:03 PM by jerome_j »

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: Running the ModelLoading tutorial on Android
« Reply #8 on: April 20, 2012, 09:57:55 PM »
It worked!!! Thank you very much, I never would have got to this point without your help! :D