Author Topic: new to JAVA and JPCT - how to create a 3d model viewer?  (Read 5917 times)

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
new to JAVA and JPCT - how to create a 3d model viewer?
« on: May 13, 2015, 11:54:37 am »
Hi guys,
I am new to JAVA but have done programming and coding in VB and c#.
I want to create a simple windows-based application for loading, viewing and rotating 3d models with textures.
How should I do that using JPCT?
I have downloaded and installed JDK and Netbeans. how should I start? the Netbeans environment is very different from VB environment. moreover the JPCT wiki has some explanations that I don't understand. for example:

"The 3D engine itself is one jar only (jpct.jar). It can be found in the distribution's lib-directory. Just include that jar into your classpath and you are ready to compile and/or run jPCT applications."
what is classpath?

please give me a clue to start.
Many thanks
Reza

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new to JAVA and JPCT - how to create a 3d model viewer?
« Reply #1 on: May 13, 2015, 01:27:24 pm »
classpath is the path in which the VM is looking for classes that your project is using. Depending on the IDE, this might be part of a setting called build path or similar. A jar is bascially a zipped folder that contains class files. By adding a jar to the class path you are basically adding this zipped folder as a source for compiled classes.
Anyway, these are Java basics and I don't think that this forum is the right place to cover them in detail.

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: new to JAVA and JPCT - how to create a 3d model viewer?
« Reply #2 on: May 13, 2015, 01:57:19 pm »
Dear EgonOlsen,

You are right, what I asked was JAVA basics and I started learning JAVA right now. I will learn the JAVA basics and then I will come back here for question about JPCT. now my specific questions are:

- Please see attached picture. I want to have a program like the attached picture at the end. it is a side by side model viewer. when I rotate the space I want two models rotate simultaneously and harmonically. in other meaning, I want to have two models loaded side-by-side with the same zoom and rotational reactions to the mouse events. Can I develop and create this type of viewer at the end using JPCT? am I in the right place at all?
- I understand that I should use eclipse IDE for JAVA development. Is eclipse IDE a proper tool for my goal described above? Am I going the right way at all?

Many thanks for your help.
Best regards,
Reza

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new to JAVA and JPCT - how to create a 3d model viewer?
« Reply #3 on: May 13, 2015, 03:50:00 pm »
Yes, you can do something like that. If this requires the exact same camera perspective for both models, it becomes a little more complex, but it's nothing that you can't do.
Just a question: Is this for jPCT (desktop) or jPCT-AE (Android)? Because your IDE choice depends on that to a degree.

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: new to JAVA and JPCT - how to create a 3d model viewer?
« Reply #4 on: May 13, 2015, 05:20:43 pm »
Dear EgonOlsen,
Thanks for your response.it helps me a lot.

First, in the answer to your question, I want both Android and Windows-based applications. Since I am new to Java and JPCT and am a little afraid of Android, I decided first complete the Windows-based application then starting the more important application in Android. (Android app is the main program I want and I plan to rotate both models using only one touch of finger rather than mouse movement).
I don't know maybe I could complete the Android application first and then run that Android application in Windows using some emulator or players, I don't know, do you have any opinion?

Second, I have an IDE called "Netbeans" with my JDK and now I have both "Netbeans" and "Eclipse". What IDE should I use?

Third, You mentioned a very important point about camera perspective. before you said about this, I was thinking to load both models side-by-side and in ONE environment. But as you said, using one environment for both models, causes a little difference in view angle of each model and I don't want that. I want both models to look the same as far as it is possible. therefore, Now I have to change the plan and use two separated 3d spaces (two separated border-less windows) each one loading one of the models. what's your idea, is this possible?

Fourth, Here rises another question. is it possible to have two separated 3d worlds and rotate them simultaneously using only one finger touch (or one mouse drag)?

Many thanks for your help.
Best,
Reza

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new to JAVA and JPCT - how to create a 3d model viewer?
« Reply #5 on: May 14, 2015, 01:21:30 pm »
Personally, I would start with a desktop application. jPCT and jPCT-AE are widely compatible. You can usually build apps for both platforms from some shared base project and a little platform specific code.

Regarding the IDE, just use what suits you more. I'm using Ecplise for most cases but Netbeans it fine too. For Android, use either Android Studio or the outdated Eclipse plugin for Android. The problem with Android Studio is, that it's solely targeted to Android. It's almost impossible to create something with it that runs on Android and on the desktop ( Ibranted about that in some thread here).
About the dual view, I assume that both models are different meshes?! Because that makes things a little easier...
I can think of different ways to do that...either render the scene twice with different camera positions, so that once appears on the left and one on the right...that's the 'I don't know any better' approach. It might work but it's fiddly and the objects can still overlap in some cases. Other solutions are to shift the viewport for both renders (there a setting in Config to do that) or render both models in two different textures and blit them onto the screen afterwards. That might be the best solution.

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: new to JAVA and JPCT - how to create a 3d model viewer?
« Reply #6 on: May 14, 2015, 04:20:28 pm »
yes, both models are different meshes. very similar to each other but with some differences.
I think I understand your third and best solution for dual view. (blit method)
maybe there is another method that I am not sure about that. when we rotate an object in 3D space, I think we are usually rotating the camera rather than the object itself. what about rotating the object in this case?
I don't know if JPCT supports conditions described below:
- using one world.
- loading two meshes and their textures and placing them with a predefined distance between them.
- creating two cameras each one looking at one of the meshes.
- rotating the meshes around their own central axis as user drags the mouse or touches his finger.
- having output of two view-ports each one coming from each camera.
- placing the outputs side by side in realtime

what is your idea about this flowchart? does JPCT have such abilities or I am far away from available methods?

Best,
Reza

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new to JAVA and JPCT - how to create a 3d model viewer?
« Reply #7 on: May 14, 2015, 04:59:21 pm »
That's basically the first solution that i mentioned. But both camera views would be rendered into the same frame buffer, so you have to make sure that one appears on the left and one on the right side of the screen....but the perspective will be slightly different for both view because of this. You can compensate this by shifting the viewport, but then you are basically back to solution 2.