Author Topic: Viable engine?  (Read 28064 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Viable engine?
« Reply #30 on: May 20, 2012, 02:11:41 pm »
I just wanted to be sure that i'm not looking at some compression artifacts...really strange. Does this happen with the camera image in the background only? Can you try it on a different device that uses another gpu? I'll try to reproduce it on my device, but i don't remember seeing anything like it.
« Last Edit: May 20, 2012, 02:20:02 pm by EgonOlsen »

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #31 on: May 20, 2012, 02:30:07 pm »
It happens without the camera preview as well. And appears on the Galaxy SII as well as on my Galaxy Nexus.

If you want to see it in the app, I can send you the APK.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Viable engine?
« Reply #32 on: May 20, 2012, 02:39:56 pm »
That would be helpful.

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #33 on: May 20, 2012, 04:07:51 pm »
Another thing. When loading via: model = Loader.loadSerializedObjectArray(getAssets().open("model.ser"));
Is it possible to somehow check when the loading is done? I need to load the car in the background, as it takes a lot of time.
but the .loadSerializedObjectArray() function starts a new thread in the background when run, which means I can't just wait for the function to finish.

EDIT: Looks like from the logs that its not loading the model itself thats the problem. But its adding it to the scene.
If I load it before entering the activity, it still takes a while to show up, a while after the onSurfaceChanged have run.
« Last Edit: May 20, 2012, 04:14:37 pm by MrAdam »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Viable engine?
« Reply #34 on: May 20, 2012, 05:53:30 pm »
The engine doesn't spawn any additional threads. When the methods in Loader return, the loading is done. The delay that you notice is caused by the engine compiling the mesh to be processed by the gpu in the most optimal way. This happens in two steps. The second one has to happen in the render thread, you can't get around that. However, the first step can be triggered from anywhere. To do this, add the objects to the world and call World.compileAllObjects. That should remove some load from the render thread.

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #35 on: May 20, 2012, 05:54:48 pm »
The engine doesn't spawn any additional threads. When the methods in Loader return, the loading is done. The delay that you notice is caused by the engine compiling the mesh to be processed by the gpu in the most optimal way. This happens in two steps. The second one has to happen in the render thread, you can't get around that. However, the first step can be triggered from anywhere. To do this, add the objects to the world and call World.compileAllObjects. That should remove some load from the render thread.
Its not really the timing that matters. Its mostly so I can create a ProgressDialog and dismiss it when it is actually done.

EDIT: Is it possible to check when all the VBO's has been created for the object?
« Last Edit: May 21, 2012, 10:09:28 am by MrAdam »

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #36 on: May 21, 2012, 11:32:55 am »
A totally different question: I use a rotation matrix to set the position of the car in 3D.
Is it possible to set the rotation around a specific axis to 0?
Lets say I only wanted the rotation matrix to rotate pitch and roll, not yaw, of the car.

EDIT: I was thinking it might be possible to pull just the two vectors out of three from the matrix, and applying them to the model, not completely sure how to do that though.
« Last Edit: May 21, 2012, 11:40:06 am by MrAdam »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Viable engine?
« Reply #37 on: May 21, 2012, 01:40:52 pm »
Why don't you use the rotate?()-methods instead?

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #38 on: May 21, 2012, 01:42:02 pm »
Why don't you use the rotate?()-methods instead?
Because Im getting a rotation matrix from the phones sensors. I can only set the rotation, not get the current rotation of the car :-/

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Viable engine?
« Reply #39 on: May 21, 2012, 02:30:06 pm »
I see...you can derive the euler angles from the matrix and create a new matrix with only a sub-set, but i'm not sure if the results will be satisfying. The basic problem is that an unlimited number of cascaded transformations result in the same output. The derived angles are just one way to do it...anyway, here's some code: http://www.jpct.net/forum2/index.php/topic,1191.0.html

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #40 on: May 22, 2012, 10:10:39 am »
I see...you can derive the euler angles from the matrix and create a new matrix with only a sub-set, but i'm not sure if the results will be satisfying. The basic problem is that an unlimited number of cascaded transformations result in the same output. The derived angles are just one way to do it...anyway, here's some code: http://www.jpct.net/forum2/index.php/topic,1191.0.html
Thanks, that helped :-)

Also, I've noticed that if there is solid objects behind transparent objects, it will render the solid objects behind as transparent as well.
We had the same issue in the iPhone version, which was solved by setting a glColorMask after drawing transparent stuff (http://stackoverflow.com/questions/10450680/isgl3d-transparency-issues)
Is it possible to somehow implement this in your engine?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Viable engine?
« Reply #41 on: May 22, 2012, 11:20:54 am »
Is it possible to somehow implement this in your engine?
Yes. You can add an implementation of the IRenderHook-interface to your transparent object(s) that does this.

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #42 on: May 22, 2012, 11:59:50 am »
Is it possible to somehow implement this in your engine?
Yes. You can add an implementation of the IRenderHook-interface to your transparent object(s) that does this.
And what is the best way to expose the GL20 object to do raw gl calls inside the IRenderHook?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Viable engine?
« Reply #43 on: May 22, 2012, 12:07:44 pm »
You don't. It's a static class. Just do GLES20.glColorMask(...);

Offline MrAdam

  • int
  • **
  • Posts: 51
    • View Profile
Re: Viable engine?
« Reply #44 on: May 22, 2012, 01:27:11 pm »
You don't. It's a static class. Just do GLES20.glColorMask(...);
Thanks! Worked wonders. Although, now the transparent lines appearing are even more visible ^^

EDIT: It appears that this is not a shader-problem, as its still visible without the shader enabled:
« Last Edit: May 22, 2012, 02:14:51 pm by MrAdam »