Author Topic: Compiling .ser & Reloading full Scene  (Read 1023 times)

Offline thomasb

  • byte
  • *
  • Posts: 4
    • View Profile
Compiling .ser & Reloading full Scene
« on: September 21, 2013, 05:58:18 pm »
Hi there,

I am developing a little App where I load several .ser files into a 3d world. I have everything running, but still there are a few problems that I dont seem to be able to solve.

1. Compilation of .ser to "indexed fix point data" files takes very long and I dont seem to have an influence on that or on when this compilation actually happens. Correct? Loader.loadSerializedObject loads it, but doesnt compile it. I tried to get around it by adding a Progress Dialog, but I have no way of getting information on when exactly this compilation is done. I put it at the end of onSurfaceCreated but that is still way too early. Suggestions?

2. What is the best way to completely rebuild such a scene? I tried to set the renderer and the GLSurfaceView to null and reinitiate both (just like on the first initiation), but that doesnt seem to be the trick as I am getting into trouble with the Object3d files (that still seem to exist at that point?) as far as I can understand. Suggestions?

Greetings
Tom

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Compiling .ser & Reloading full Scene
« Reply #1 on: September 23, 2013, 07:41:08 am »
You may call http://www.jpct.net/jpct-ae/doc/com/threed/jpct/World.html#compileAllObjects() to compile objects beforehand instead of an demand.

The best way to trebuild it is not to rebuild it but use the former instance. I usually keep a static reference to some parent object(s) and copy them from there into the new Activity if that has changed (that can be seen in the examples). There might be better ways to do this, because this way is still based on my Android 1.5 experiences, but anyway...

Offline thomasb

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Compiling .ser & Reloading full Scene
« Reply #2 on: October 07, 2013, 04:21:15 pm »
Thanks, compileAllObjects() works like a charm. The world and all its contents have to be loaded/initialized first though as well, which is not a problem in my case.

For the second problem: I am holding the 3d scene in a GLSurfaceView, which I am pushing to and pulling off the top of a self-built view stack. Rendering happens in an extra class. So when I push the view to the stack for the second time, all I get is a black screen.

Ive seen you mentioning the method to make as many elements of the Renderer static as possible, but couldnt find the appropriate examples. Mind giving me a hint?

Greetings

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Compiling .ser & Reloading full Scene
« Reply #3 on: October 07, 2013, 08:22:40 pm »
Ive seen you mentioning the method to make as many elements of the Renderer static as possible...
I've never said that...and if i did, i didn't mean it.. ;) I'm keeping one static reference in the Activity and move out as much stuff as possible from the renderer. I'm not sure what the problem with your stack/GLSurfaceView combination is though. Is the gl context lost if you push the view onto the stack for the second time or why is everything black? Any log output that might help?

Offline thomasb

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Compiling .ser & Reloading full Scene
« Reply #4 on: October 07, 2013, 08:59:30 pm »
Context stays the same and isnt lost in this specific case as I am staying within one Activity (although I can imagine additional problems arising when I pause & resume the App).

Basically I am creating the GLSurfaceView and its Renderer on startup of the App. When selected, I load the GLSurfaceView with a ViewFlipper (bringing it to the front). But that only seems to work for the initial run, for the second time and onwards I get a black screen.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Compiling .ser & Reloading full Scene
« Reply #5 on: October 07, 2013, 09:10:39 pm »
...But that only seems to work for the initial run, for the second time and onwards I get a black screen.
Ok, but the question is what causes this. Can you post the log output of the second run to see if the engine actually tries to do something? Maybe it doesn't trigger at all.

Offline thomasb

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Compiling .ser & Reloading full Scene
« Reply #6 on: October 07, 2013, 09:48:16 pm »
As far as I can tell, there is no Log output when loading the View for the second time. Loading the first time, it looks like this:

Code: [Select]

10-07 21:36:43.725: I/jPCT-AE(2730): Loading Texture...
10-07 21:36:43.725: I/jPCT-AE(2730): Texture loaded...131072 bytes/256*128 pixels!
10-07 21:36:43.735: I/jPCT-AE(2730): GLRenderer created with id 0 on Thread[GLThread 11,5,main]
10-07 21:36:43.735: I/jPCT-AE(2730): OpenGL vendor:     Qualcomm
10-07 21:36:43.745: I/jPCT-AE(2730): OpenGL renderer:   Adreno 200
10-07 21:36:43.745: I/jPCT-AE(2730): OpenGL version:    OpenGL ES-CM 1.1
10-07 21:36:43.745: I/jPCT-AE(2730): OpenGL renderer initialized (using 2 texture stages)
10-07 21:36:43.755: I/dalvikvm(2730): Total arena pages for JIT: 11
10-07 21:36:43.775: I/jPCT-AE(2730): Allocating native memory for 8*8 texture(true/false/false/false/): 256 bytes!
10-07 21:36:43.775: I/jPCT-AE(2730): New texture's id is: 1
10-07 21:36:43.785: I/jPCT-AE(2730): New texture uploaded: com.threed.jpct.Texture@405ee1c0 in thread Thread[GLThread 11,5,main]
10-07 21:36:43.785: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.795: I/jPCT-AE(2730): VBO created for object 'object2'
10-07 21:36:43.915: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.915: I/jPCT-AE(2730): VBO created for object 'object2'
10-07 21:36:43.915: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.915: I/jPCT-AE(2730): VBO created for object 'object19'
10-07 21:36:43.925: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.925: I/jPCT-AE(2730): VBO created for object 'object19'
10-07 21:36:43.925: I/jPCT-AE(2730): Allocating native memory for 8*8 texture(true/false/false/false/): 256 bytes!
10-07 21:36:43.925: I/jPCT-AE(2730): New texture's id is: 2
10-07 21:36:43.925: I/jPCT-AE(2730): New texture uploaded: com.threed.jpct.Texture@406cf640 in thread Thread[GLThread 11,5,main]
10-07 21:36:43.925: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.925: I/jPCT-AE(2730): VBO created for object 'object5'
10-07 21:36:43.935: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.935: I/jPCT-AE(2730): VBO created for object 'object6'
10-07 21:36:43.935: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.935: I/jPCT-AE(2730): VBO created for object 'object7'
10-07 21:36:43.935: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.945: I/jPCT-AE(2730): VBO created for object 'object8'
10-07 21:36:43.945: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:43.945: I/jPCT-AE(2730): VBO created for object 'object9'
10-07 21:36:44.015: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.015: I/jPCT-AE(2730): VBO created for object 'object10'
10-07 21:36:44.015: I/dalvikvm(2730): Total arena pages for JIT: 12
10-07 21:36:44.015: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.025: I/jPCT-AE(2730): VBO created for object 'object11'
10-07 21:36:44.025: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.035: I/jPCT-AE(2730): VBO created for object 'object12'
10-07 21:36:44.035: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.035: I/jPCT-AE(2730): VBO created for object 'object13'
10-07 21:36:44.035: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.035: I/jPCT-AE(2730): VBO created for object 'object14'
10-07 21:36:44.045: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.045: I/jPCT-AE(2730): VBO created for object 'object15'
10-07 21:36:44.045: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.055: I/jPCT-AE(2730): VBO created for object 'object16'
10-07 21:36:44.055: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.055: I/jPCT-AE(2730): VBO created for object 'object17'
10-07 21:36:44.055: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.065: I/jPCT-AE(2730): VBO created for object 'object18'
10-07 21:36:44.065: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.065: I/jPCT-AE(2730): VBO created for object 'object4'
10-07 21:36:44.065: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.075: I/jPCT-AE(2730): VBO created for object 'object3'
10-07 21:36:44.075: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.075: I/jPCT-AE(2730): VBO created for object 'object20'
10-07 21:36:44.075: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.075: I/jPCT-AE(2730): VBO created for object 'object21'
10-07 21:36:44.085: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.085: I/jPCT-AE(2730): VBO created for object 'object22'
10-07 21:36:44.085: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.085: I/jPCT-AE(2730): VBO created for object 'object23'
10-07 21:36:44.085: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.095: I/jPCT-AE(2730): VBO created for object 'object24'
10-07 21:36:44.095: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.095: I/jPCT-AE(2730): VBO created for object 'object25'
10-07 21:36:44.095: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.095: I/jPCT-AE(2730): VBO created for object 'object26'
10-07 21:36:44.095: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.105: I/jPCT-AE(2730): VBO created for object 'object27'
10-07 21:36:44.105: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.105: I/jPCT-AE(2730): VBO created for object 'object28'
10-07 21:36:44.105: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.105: I/jPCT-AE(2730): VBO created for object 'object29'
10-07 21:36:44.115: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.115: I/jPCT-AE(2730): VBO created for object 'object30'
10-07 21:36:44.115: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.115: I/jPCT-AE(2730): VBO created for object 'object31'
10-07 21:36:44.115: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.125: I/jPCT-AE(2730): VBO created for object 'object32'
10-07 21:36:44.125: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.135: I/jPCT-AE(2730): VBO created for object 'object33'
10-07 21:36:44.135: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.135: I/jPCT-AE(2730): VBO created for object 'object34'
10-07 21:36:44.135: I/jPCT-AE(2730): Creating buffers...
10-07 21:36:44.135: I/jPCT-AE(2730): VBO created for object 'object35'
10-07 21:36:44.145: I/jPCT-AE(2730): Allocating native memory for 256*128 texture(true/false/false/false/): 131072 bytes!
10-07 21:36:44.145: I/jPCT-AE(2730): New texture's id is: 3
10-07 21:36:44.145: I/jPCT-AE(2730): New texture uploaded: com.threed.jpct.Texture@40d63ae0 in thread Thread[GLThread 11,5,main]



The onTouchEvent method is still called though..