Author Topic: side-by-side 3D model Viewer and Comparator  (Read 2979 times)

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
side-by-side 3D model Viewer and Comparator
« on: November 30, 2015, 07:23:42 pm »
Hey friends,

I am a new user of JPCT. I had a topic some month later:
http://www.jpct.net/forum2/index.php/topic,4379.msg30466.html#msg30466

in that topic, I was going to develop a "side-by-side 3D model viewer". (please see the attached image); two models should be placed side-by-side and I want those similar models rotate simultaneously around their axis As I drag the mouse to left or right.

Now I need to know how to start. I have developed a simple 3d model viewer thanks to JPCT and helps of Dear EgonOlsen.

But I do not have enough knowledge to continue the project. for example based on the recommendation of EgonOlsen I tried to understand blitting (topic mentioned above), but I couldn"t understand what does that function really do and what's the relation to side by side viewing the models!!:(

Please help me.
thanks.
« Last Edit: November 30, 2015, 07:26:01 pm by Reza »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: side-by-side 3D model Viewer and Comparator
« Reply #1 on: November 30, 2015, 08:45:07 pm »
Blitting itself is really easy. It simply means that you paint a 2d image onto the screen. In jPCT, this would be a texture (or a part of it). The method described in the thread is a little more complicated than that. You don't render the image onto the screen but into a texture. To do that, you assign a render target (=texture) to your framebuffer and render the scene: http://www.jpct.net/doc/com/threed/jpct/FrameBuffer.html#setRenderTarget(com.threed.jpct.Texture). After rendering into the texture, you remove the render target again http://www.jpct.net/doc/com/threed/jpct/FrameBuffer.html#removeRenderTarget(), set a a second texture as render target for your second scene and repeat the process. In the end, you have two scenes of two different models rendered into two different textures. All that's left now, is to blit these textures onto the actual screen (without any render target set).

...but before I go into even more detail: Is this for desktop Java or for Android?

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: side-by-side 3D model Viewer and Comparator
« Reply #2 on: November 30, 2015, 09:03:40 pm »
I exactly want it for Android, but i assumed that maybe it's easier for me as a "new user of  JPCT" to firstly do the whole process on Desktop and then going to Android

I hope there would be a slight amount of required changes when converting the "desktop code" to "Android code"

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: side-by-side 3D model Viewer and Comparator
« Reply #3 on: November 30, 2015, 09:27:19 pm »
No, it's basically the same thing. The reason why I was asking is that the Android version supports NPOT-textures while the desktop version doesn't, and they might be useful for this. Anyway, you can start with the desktop version.

Try to get a grip on normal rendering, then on render targets and than on the rest...this might help as well: http://www.jpct.net/forum2/index.php?topic=3716.0

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: side-by-side 3D model Viewer and Comparator
« Reply #4 on: November 30, 2015, 10:06:48 pm »
Thanks for introducing NPOT-Textures. I am glad to have that option in Android. it is useful for my work.

Ok, about my main question, thanks to "Hello World" program Now I am able to load my own .obj and its texture. I can rotate my Model too. I use these codes for that purpose:

world.renderScene(buffer);
world.draw(buffer);
buffer.update();

Now I want to go to next step: RenderTarget
but I have a question before coding; when you say "In the end, you have two scenes of two different models rendered into two different textures", what Should I do in order to join those two scenes so they create a side-by-side look?
I assume that the key action for joining two scenes is inside the blit function parameters, right?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: side-by-side 3D model Viewer and Comparator
« Reply #5 on: November 30, 2015, 10:09:46 pm »
Not quite. You render one scene in one texture, the other in the other and than do two blitting operations to display them both.