[java] Java3D vs. GL4Java

Started by
37 comments, last by WoolyLoach 21 years, 7 months ago
Ok, I''m looking into alternatives for developing a simple, online-capable RPG and am checking into using Java for at least some of it. I''ve dug into JNI a bit (reading-wise) and it looks as if it''d be a lot easier to use something already developed than to write my own DirectX or OpenGL wrapper (or worse, implement most of the engine in C++ and expose it all to Java via JNI, which is my fallback position). I don''t need triple-digit framerates for a basic RPG, but I _do_ need at least 30fps on my target system (PIII-850MHz. with a GeForce3-class graphics card). The Java3D examples I''ve run are relatively slow, but they''re _examples_ so I''m sure they''re not optimized for performance. The GL4Java examples run fairly well but setup is a pain in the tail and I''m not sure end-users would want to deal with it all. Any comments, recommendations (URLs, books, alternatives)?
Wooly Games for Wooly Minds!
Advertisement
Well here I go doing a shameless plug for WildTangent again. I can get framerates of about 30-31 on a duron 700 with a 4meg video card, and mind you those framrates are capped from 40-50, and thats with junky unoptimized poorly planned code, so you could probably do wonders, or set the frame-cap higher.
Java3D does not support the latest features on modern graphics cards such as Geforce3 and gives you less control over rendering than OpenGL, but it also gives you some features (such as model loaders and view-frustrum culling) that you will have to implement yourself if you go with OpenGL. Since you have more control over the rendering with OpenGL, it can be made to perform faster than Java3D.

I think both APIs could be make a basic RPG perform at 30+ fps on the system that you describe, but our perception of ''basic RPG'' might differ. There is a online RPG called Cosm being developed using Java3D.
Just some points and corrections.

Pro

Java3d can perform bettern than gl4java. It has an auto-optimizing scene graph that can allow you to concentrate more on you objects than the rendering pipeline. It run on DX or GL under windows.

Con

Java3D does not support Mac, gl4java does. There are rumors of java3d under mac, but nothing anyone has actually put on paper as a PR or whatever. Java3d scene graph technology is annoyingly complex almost too complex at times and is still not 100% ( two thing that should work the same operate at widly diffrent speeds ). Java3d API is fairly stable, but it is an evolving spec.

Gl4java is extremly easy to get running on a windows and linux and only slightly more difficult for a mac box. Just use the web installer, or use a webstart app.

Other things you might want to think about.

Joystick access?
Sound?
Server?
Oh, most of these issues have been discussed on another forum too..

http://www.javagaming.org/
Thanks to everyone for all the info. I''m off to the javagaming site for more research, but I think I have a better understanding of the issues involved now (read: less clueless).
Wooly Games for Wooly Minds!
quote:Original post by snowmoon
Just some points and corrections.

Pro

Java3d can perform bettern than gl4java. It has an auto-optimizing scene graph that can allow you to concentrate more on you objects than the rendering pipeline.


http://www.rolemaker.dk/articles/evaljava/

"Unfortunately there are also several drawbacks of using Java3D:
Significantly reduced performance compared to highly tuned OpenGL or DirectX applications. In the 3D Demo benchmark (see section 7.10) we saw that the Java3D version (Java3D 1.3 beta 1 for OpenGL was used) was about 2.5 times slower than the equivalent GL4Java version. This is a significant slow down since most of the processing time is supposed to be in 3D hardware."

and...

"Given the poor performance of Java3D I can not recommend the use of Java3D for games with high requirements in performance."

I''m not sure if the author has resolved these issues (I stopped paying attention to the Java3D-interest mailing list a while back) but they do indicate that perhaps GL4Java is the best route at present.

Java3D is great for creating things quickly (once you get the hang of the ridiculous amount of classes required for most tasks or wrap them up in simpler function calls). It will probably perform well enough on your wanted system and it will speed up development time. Note that if you are interested then have a look over at Daniel Selman''s book. The source code is over here.
Just little quibble.. nothing agains your work jacob...

Java3d has been shown to be within 10% of gl4java ( for most TESTS ) once you understand the java3d quirks. Java3d has much room for improvement without any changed to your code. When J3d implements a T&L path your gl4java game would be left in the dust. Real world performace proves that j3d is a real cntender and it''s improvement on the deliverable bottom line is a big win too.

If it only ran on mac I could justify the learning curve over gl ( whick I already know ).
Well, more reading and surfing about has certainly brought me wisdom, knowledge, and a screaming headache.

Since I''m _NOT_ looking for triple-digit framerates and I''d rather focus on game logic than re-inventing the wheel, Java3D is looking pretty good. My only remaining concern is how soon new hardware features will be implemented in the API - for instance, vertex and pixel shaders. I suspect it''s going to be sssslllooowww arriving in Java3D due to platform-independence issues...

It just gets more interesting as time goes on. :-/
Wooly Games for Wooly Minds!
Basic tutorials: http://www.java3d.org
Other FAQs, lots of code: http://www.j3d.org
Free (entire) online book, source code up a level in dir:
http://www.manning.com/selman/onlinebook
Java3d-interest mailing list archives:
http://archives.java.sun.com/archives/java3d-interest.html
Stuff (including tutorials):
http://java.sun.com/products/java-media/3D/collateral/
More tutorial-related stuff:
http://java.sun.com/products/java-media/3D/collateral/class_notes/slides/mt0
000.htm

news://comp.lang.java.3d (which is a bit cack really - it''s like a ghost town... stick to the mailing list

Use the OpenGL version of Java3D because it''s faster and more stable than the Direct3D version. Read this too and note that the .compile() method for BranchGroups does not do anything with the default settings! (I think you need to setPickable(false) and setCollidable(false) for yer objects IIRC). I think that Java3D tries to combine and optimise shared appearances, etc., when you call this method. This page talks about advanced techniques.

IIRC you''ll have to wait until the next big release of Java3D before you get da shader goods. Unfortunately, that''ll be in a year or two (I forget which). There will always be feature lag with Java3D so you''ll have to grin and bear it.

Make sure you sign up for the mailing list: it''s where all the big-wigs (Java3D creators, etc.) hang out. Also, note that there are one or two undocumented ''features'' for some of the classes. One that I remember is with the Text2D class. You have to divide the scale by 256 in the setScale method, assuming I''m remember correctly. It''s not mentioned in the documents.

P.S. snowmoon, I hope you don''t think I''m Jacob .

This topic is closed to new replies.

Advertisement