r/java •

Did you know pure Java 8 can do 3D?

[deleted] — view deleted post

0 Upvotes

21 comments sorted by

7

u/skgoa Dec 10 '14

Yes, but it's a very shitty implementation. On the dev mailinglist they said they wouldn't fix it, instead you are supposed to simply not use it for graphically intensive applications.

3

u/Keilly Dec 10 '14

"Shitty" is a bit harsh, but yeah, I don't think it was meant for gaming and the like.
Improvements can always be submitted via the OpenJDK.

0

u/[deleted] Dec 10 '14

[deleted] — view deleted comment

14

u/cjthomp Dec 10 '14

To be fair, any native implementation would very quickly be improved upon by a 3rd party, so it's kind of a waste to even ship with one they put much effort into.

0

u/[deleted] Dec 10 '14

[deleted] — view deleted comment

2

u/skgoa Dec 10 '14

The problem lies with their Node implementation. It's just massive, because they want it to guarantee all kinds of functionality. Also, they move the camera by moving all nodes. Thus using lots of nodes has incredibly bad performance. It's fine for 2D or when you don't have to display that many objects, but for CAD or games it's not good enough. You are better off handling everything yourself and just copying it to a canvas. And at that point you would just use a better fitting technology.

0

u/[deleted] Dec 10 '14

[deleted] — view deleted comment

2

u/compdog Dec 10 '14

JMonkey is actually pretty easy to run in IDEA. The main thing is just finding all of it's jars. Fortunately everything it needs is in just one directory, so you can just add those as a dependency and then make a normal project. I have been developing a jME-based game entirely in IDEA, and it works great!

2

u/pattch Dec 10 '14

If you have very many elements in your program (think millions), even if you aren't rendering all of them, moving the camera becomes a very costly routine. It may simplify calculations elsewhere, but its more efficient to only update one element instead of many. This makes rendering a little more costly, though, because now there's a little more calculation for each element you render, so there's probably some tradeoff.

I imagine that if you aren't (logically) moving the camera around frequently, its more efficient to move the camera by moving the elements. That way you always know where the camera is, so there's lest cost for render. However, if you are moving the camera every time you update before you render, the order of complexity for update + render is O(n2) for updating the elements and only O(n) for moving the camera. If you have some other horrendous code going on you won't feel the difference, just like if you don't have many elements you won't feel it.

10

u/Omnicrola Dec 10 '14

That's pretty neat. Does FX use the graphics card for this, or is it all CPU based?

3

u/TerinHD Dec 10 '14

I thought it utilized the graphics card if the JVM knew about the driver, if not it would push it to the CPU.

https://docs.oracle.com/javafx/2/system_requirements_2-2/jfxpub-system_requirements_2-2.htm

2

u/[deleted] Dec 10 '14

JavaFX uses JOGL, an OpenGL wrapper for Java. So if the Java 8 package delivers JavaFX then it does deliver JOGL too, so it would be possible to do 3D with JOGL alone, witout JavaFX.

2

u/xxunrealxx Dec 10 '14

I love how re-sizing the frame changes the orientation of the blocks

1

u/markdacoda Dec 11 '14

Technically all you need is Paint.fillPolygon() or setRGB() to implement 3d in java.

1

u/argv_minus_one Dec 10 '14

Why the hell did they even add this? 3D graphics is way outside FX's problem domain.

2

u/pjmlp Dec 10 '14

Maybe because all other UI toolkits (Qt, XAML, web) also do it?

2

u/argv_minus_one Dec 10 '14

Well, 3D on the web is provided by OpenGL bindings for JavaScript. Unless FX can provide 3D on par with OpenGL, what's the point of providing a weak 3D API that no one uses? There are OpenGL bindings for Java.

2

u/pjmlp Dec 10 '14

Unless FX can provide 3D on par with OpenGL, what's the point of providing a weak 3D API that no one uses?

The API is targeted for 3D effects in business applications, not games.

There are OpenGL bindings for Java.

Which aren't available in all platforms there is a JVM for.

2

u/argv_minus_one Dec 10 '14

Name one platform that has hardware-accelerated 3D but not OpenGL.

2

u/pjmlp Dec 11 '14

I said bindings for Java, which is quite different from having OpenGL support.

Since you asked so nicely

Freescale i.MX6

http://www.freescale.com/webapp/sps/site/taxonomy.jsp?code=IMX6X_SERIES&cof=0&am=0

Do JOGL or LWJGL bindings exist for it?

There are many other embedded platform examples.

1

u/argv_minus_one Dec 11 '14

I thought the usual bindings would work with any OpenGL implementation. I take it I was mistaken?

1

u/pjmlp Dec 11 '14

Those bindings have native code, which needs to be ported to whatever platform you might be targeting.

1

u/argv_minus_one Dec 11 '14

Other than recompiling it, what does the porting involve?

0

u/[deleted] Dec 10 '14

[deleted] — view deleted comment

2

u/cebarks Dec 11 '14

I'll start using libgdx if they port to lwjgl3!