How insert a 3D viewer into java application for .obj file? - java

I created a simple Java application using JavaFX. I would like to integrate a 3D viewer on my window with which I can interact with the mouse (only to rotate the 3D object).
Is it possible to achieve such a thing in Java with JavaFX?
The purpose of my project would be to display a 3D object from a .obj file.
I use java 8 and I looked at Java 3D but I can not find many examples on the Internet.

This is all possible with JavaFX which directly supports some 3D graphics.
Start with a general tutorial here:
https://docs.oracle.com/javase/8/javafx/graphics-tutorial/javafx-3d-graphics.htm
and then use the model loaders from here:
http://www.interactivemesh.org/models/jfx3dimporter.html

Related

Pure java 3D (without libraries)

I was searching a way to emulate 3d graphics. I found the cherno project, but i realized that it doesn't explain correctly the way to obtain the 3d view. Is there a good tutorial (or a good explanation) that shows correctly how to do it (or how games like prelude of the chambered work with 3d graphics)? (whithout any libraries, only pure java)

Show line and points in 3 axis in Java

I have 100 point in 3D and all of them are connected with each other via a segment line.
I want to show points and connecting lines in 3D axis(x,y,z) in Java.
I read some answers and I saw java 3D and JavaFX Scene Builder but they were so sophisticated.
I used to work with MATLAB. It provides really simple tools to show such things.
Is there any possible simple way or library in Java to do so?
Please don't refer to strange and sophisticated projects.
Thanks.

How to use OpenGL in JavaFX?

I want to write a very simple Java 3D editor(for experiment). I know the basic JavaFX usage, and I know enough OpenGL knowledge. But all my OpenGL experience is from working with C/C++.
Could I make a 'canvas' in JavaFx application and map OpenGL viewport on it?
Internally, JavaFX can use OpenGL as a rendering pipeline, so some care on integration between the two is required to avoid conflicts.
OpenGLNode in JavaFX
Richard Bair, JavaFX team lead posted on the openjfx development mailing list:
One thing I want to see done (for example) for the 8 update is to have an OpenGLNode or NativeSurfaceNode or something along those lines so that if you are doing your own D3D / OpenGL you can have a way to send those raw commands down to the graphics card but still have your node composited in the scene graph.
So a future JavaFX release update might include an OpenGLNode.
Such a feature would probably not see inclusion in a JavaFX general availability release until the next JavaFX feature release after the initial Java 8 release (my guess is that would put it at about September 2014).
3rd Party OpenGL/JavaFX integration
You don't need to wait so long to start integrating JavaFX and OpenGL. All of the required source code to start an implementation is open in the OpenJFX repository, so you could try building a custom integration of that code with a library such as lwjgl or jogl.
This answer will get dated as developers start performing integrations of JavaFX with existing Java wrappers for OpenGL apis. Some developers have started such work already - run a google search of lwjgl javafx or jogl javafx to find out about current integration projects and their status.
The simplest integration is probably to have a 3rd party library render to an off screen buffer then transfer the pixels from the buffer to a JavaFX WritableImage or Canvas as required to get the OpenGL rendered graphics composited into the JavaFX scene graph.
JavaFX 3D API Alternative
JavaFX has its own lightweight 3D api that provides the ability to composite phong shaded 3d models into the JavaFX scene graph. The JavaFX 3D api is not going to provide all the power of a full OpenGL api integration, however using the JavaFX 3D api is relatively simple. A description, with code examples of the 3D features in Java 8 is on the open-jfx wiki.
Interactive Mesh provides a free 3D model importer for JavaFX, that allows you to very simply bring complex shaded and textured 3D models into a JavaFX scene graph.
There is a 3D Viewer project in the openjfx repository that you could fork to create a basis for your proposed JavaFX based 3D editor.
The nashorn JavaScript engine has a switch that allows you to use JavaFX and its 3D features from JavaScript, so you can use alternative jvm languages to access JavaFX 3D features if you prefer.
Yes, by all means, you can use JOGL to achieve effectively everything you could in Java with OpenGL as you can in C/C++.
You can use the OpenGLFX library, which mixes the previously mentioned JOGL/LWJGL and JavaFX. The code has the best performance available without changing the source code of JavaFX itself.

How to render a 3d cube in LWJGL?

I can`t find a good tutorial on the web, about rendering a 3d cube in the Lightweight Java Game Library! I have been learning LWJGL for some time now. I know how to draw 2d objects. Could Somebody Help me?
Here is a lesson of a tutorial for "normal" OpenGL but in the bottom of the site you can find code for the tutorial lesson in plenty of different languages and libraries, including Java with LWJGL.
To get the java code out of this jar you can open it with e.g. 7-zip and find the .java file in the folder named Lesson05.

What libraries are available to help create 2D Java games for phones?

I want to begin developing 2D Java games for phones (on J2ME) therefore I'd like to know if any libraries or "engines" exist to help out in the various graphical tasks:
Drawing text with pixel fonts?
Drawing bitmaps for sprites with multiple frames like animated GIFs?
Drawing graphics with code, lines, beziers, flood-filling and gradient fills?
Ordering / layering of sprites?
Or maybe a great book exists, that gives you enough code samples to get off the ground quickly?
MIDP (JSR-118) includes the basics (most of the things you listed above) mainly in the javax.microedition.lcdui and javax.microedition.lcdui.game namespaces.
I didn't use it myself, but heard some good reference on here.
And here is even a list of libraries, you might need.
There was a book released quite a few years ago called Developing Games in Java by David Brackeen.
That covers the basics of 2d and 3d development in pure Java as well as how to handle time jumps and update the physical properties of your game characters. It is a good introduction to the topic.

Categories

Resources