Archived

This topic is now archived and is closed to further replies.

WoolyLoach

[java] Java3D vs. GL4Java

Recommended Posts

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)?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ).

Share this post


Link to post
Share on other sites
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. :-/

Share this post


Link to post
Share on other sites
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 .

Share this post


Link to post
Share on other sites
Nope, I''ve had many a heated discussions with Jacob. I just wanted to make sure people did not think I was personally downing his work, I just question his conclusions. He seemed to have problems with java3d and other 100% pure solutions becuase he had written his own JNI/C++ framework for 3d rendering ( java3d was not availible then ).

If you think you have a hedache now, just wait till you start actually programming the game logic!!! Forget about 3d, I''m just taking the AI and other NPC code.

Share this post


Link to post
Share on other sites
Well, after a more or less sleepless night worrying about everything in the Universe I''ve come to a decision: I''m going to start out down my merry path to Hell with Java3D. There looks to be some good activity going on with Java and gaming, and my life is difficult enough without having to add developing an entire 3D engine from the lowest level up to it! Sure, no shaders etc. until late 2003 from the looks of the JSRs I''ve seen, but with the Java Game Profile and the Java3D 1.4 stuff it _looks_ like things are (if nothing else) on the right path.

If I have to, I can always get dirty and use JNI until I get what I want native (heh heh heh evil spud that I am).

I see no reason why I can''t get 30fps on what I expect to be the ''midrange'' consumer box by my ship date (late next year). My only real concern is how to best get the proper JRE and Java3D libs onto the users machine, but (famous last words) I''ll burn that bridge when I come to it!

Share this post


Link to post
Share on other sites
Java3d can be loaded dynamicly with Webstart!

You just need to craft a proper xml file and you application will automatically install J3d if it''s not already installed. Check out the javagaming.org forums for exact info.

Good choice. You don''t need shaders to make a game. Gameplay is the most important factor, everything else is just eyecandy.

Share this post


Link to post
Share on other sites
Well, it appears that my target customers aren''t interested in downloading 20MB+ of JRE/JAI/JMF/Java3D just to check out my demo. Ugh, I knew I had to eat the download cost of the JRE (at 12MB for the 1.4 JRE International/Windows version) but the rest of it is pretty much death-in-a-bucket.

Pragmatically, I''m left with no choice but to get dirty and use JNI to go down into a native engine written in C++ and, at least, remove the JAI/JMF/Java3D download burden from my (potential) customers (that''s about 15MB worth of stuff, by the way). Maybe by the time I ship everyone in the world will have broadband, but.. I kind of doubt it.

What a long, strange trip it''s been.

Share this post


Link to post
Share on other sites
Maybe this is a small consolation, but why not get the English-only version (a tiny amount less than 9 Mb by my count)? And you can include a stripped down version of the JMF with your program if you use the Customizer included with it. Still, you''re talking about 10 Mb, and then plus your program data/code... but that''s still a significant amount shaved off of what you''re talking about.

-pirate_dau

Share this post


Link to post
Share on other sites
Hi,

This is a bit of a problem that im facing too.
But im making a 3d engine, so I can just spend more time on the 3d coding.
Problem remains:

Java3d
pro: Well suported, high level, good performance
con: slow implementation time for new features

OpenGL4Java
pro: fast, will expose all the features of the hardware.
con: Doesnt apear to be very well suported ATM

If you want all the possible options, you can use GL4Java.
Then again java3d is bound to support it too within time.
Keep in mind that designing a game can take up to a few years (by which time java3d might include all the extra''s)

I want to avoid the whole AWT/Swing part for 3d rendering, so I will most likely use JNI (C++, ugh) and SDL

Any ideas?

Share this post


Link to post
Share on other sites
Well, my issues weren''t just with download size, I had problems with poor functionality with audio (for both sound effects and music) and the need to throw in bloated class libs just to be able to read certain image formats and play video. No single thing in and of itself was the deal-breaker, but combined, there were too many problems to make going ''pure Java'' worthwhile. Sure, maybe Java3D will have most of what I need by the end of my 18-24 month development cycle.. but, of course, I''ll have access to the latest and greatest and still end up ahead. I should have known there were going to be Problems(tm) when I discovered that the Java3D collision detection system was asynchronous and I''d have to write my own to prevent collisions from happening in the first place (a couple of threads on www.javagaming.org on this topic if you want to find out what I''m talking about).

I''ll do my engine in DirectX, use the invocation API to start up a JVM, then run the primary game code in Java and let it control the engine via JNI. I''ll abandon cross-platform compatability for now, it''s not critical to the product. It''s an ugly solution but a pragmatic one.

Share this post


Link to post
Share on other sites
Nooo WoolyLoach, don''t do it!

First examine:
http://www.javagaming.org/samplecode/Terrain.zip
(needs Geforce) - there''s your Java performance.

Then examine:
http://sourceforge.net/projects/java-game-lib

The answer to most of your troubles I should hope. There should be alpha code up within the next two weeks and beta in about 4.

And the best bit is the whole lot should weigh in at under 400k.

My other advice to you is not to use complex data formats such as .PNG and the like but to encode them at development time into a far simpler format without the heavyweight library overhead (eg. just zip 32bit ARGBs and prepend the image width, height, and depth etc as ints). Same goes for sounds.

Another thing to note is that using LWJGL you have no reliance on AWT, and therefore no reliance on Sun. You are free to compile your game with Jet (which, when I compiled the terrain demo above, gave me performance on a par with server VM but with a vastly quicker startup time) or even GCJ.

Cas

Cas

Share this post


Link to post
Share on other sites
Warm up the frying pan, I''m going to eat my words! Anyone got mustard? :0

I''ve spent the past several days working on various parts of my design for the engine. I then sat down and estimated how long it would take me to complete just the basics - octree-based scene graph handler, renderer, collision detection, file loaders, specialized tools - JUST the engine and supporting stuff, no "game". Figuring evenings and weekends (can''t always get away with coding games at work lol, I''m an embedded systems engineer and having MD3 models running around on the screen doesn''t classify as "embedded software") - I''ll have it done around Q3 2003. Then add another 10-12 months for game logic, game artwork/assets, testing, debugging.. ugh.. maybe I ship a game right about the time I retire! :-/

Sooo, I''m going to implement my first title as a Dungeon Siege total conversion (lol, really, I mean it) while working on Java/Java3D stuff and pushing to get more "game oriented" functionality into Java (or waiting for the Java Game Library) and slowly forging a Java engine suitable for my NEXT game. This way I get to "work on the game" and lower my frustration level, while giving time (and trying to push lol) for Java and/or Java3d and/or Java game libraries to Get Where I Want Them.

There''s nothing like sitting down for several days, working on a design for your own scene graph, then downloading and reading through someone''s open-source code, and realizing that you''ve got a year of work at least to make you realize it''s better to try to leverage existing assets instead of dying of old age before shipping (!!).

Share this post


Link to post
Share on other sites
quote:
Original post by princec

First examine:
http://www.javagaming.org/samplecode/Terrain.zip
(needs Geforce) - there''s your Java performance.

Then examine:
http://sourceforge.net/projects/java-game-lib


Cas



Yes, I saw it yesterday....NICE!

Im thinking of using it for my 3d engine

Share this post


Link to post
Share on other sites
Windows 2000, Service Pack 3, JDK 1.4.0, Java3D 1.3. Clicking on the JAR file produces the infamous selection list and the wonderful question ''Click the program you want to use to open ''demo.jar''''. Ugh. I wonder if this means there''s something messed up in my installation?

Share this post


Link to post
Share on other sites
Yes, looks like your installation''s a bit dicky.
To run it from the commandline you can do

java -cp demo.jar demo.client.Demo

For fun you can try experimenting with a few switches on the commandline to see how it affects performance like

java -server -Xincgc -cp demo.jar demo.client.Demo

etc.

There''s also

java -cp demo.jar demo.client.Demo enablekeys

which enables some extra keys that to fiddle with the number of lights.

Various keys do things but the readme seems to have gone AWOL.



Cas

Share this post


Link to post
Share on other sites
Assuming the jarfile has the appropriate manifest file, you can also just type ''java -jar demo.jar''. If you want to extract the classfiles (and whatever other files reside within the jarfile), they you can type ''jar -xf demo.jar'' (that will unzip them in the current directory).

So there are a lot of ways you can do this

-pirate_dau

Share this post


Link to post
Share on other sites