Archived

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

Challenger17

Using JAVA to develop 3D game? help plz.

Recommended Posts

Challenger17    116
A media lab of my university is just started trying developing a 3D game using java for sb. the reason they don''t use C++ is becuz this game under plan is designed to be enable running on various platforms, not just on Windows. And they intend to use OpenGL or JAVA3D as graphics API. to be honest i have only learned Direct3D, once took a glance at OpenGL & i have no idea about JAVA3D. now i have to give them a suggestion on the graphics part of the game. now the question is. among mainstream games(those famous ones of course) on mainstream platforms i''ve ever heard, there''s not even one game was developped using java. java is slow that it doesn''t fit game-developing very well. i''m afraid this project would failed. is here anybody familiar with java-game developping? any experience? any ideas? should we change the plan and use C++ together with Direct3D instead? but by doing that how can we make it cross-platform? thx a lot!

Share this post


Link to post
Share on other sites
dmikesell    157
quote:
Original post by Challenger17
A media lab of my university is just started trying developing a 3D game using java for sb. the reason they don't use C++ is becuz this game under plan is designed to be enable running on various platforms, not just on Windows.



Which platforms, which they plan to target with Java, do not have C++ available to them?



[edited by - dmikesell on March 29, 2004 10:23:36 AM]

Share this post


Link to post
Share on other sites
paulecoyote    1065
quote:
Original post by Challenger17
... among mainstream games(those famous ones of course) on mainstream platforms i''ve ever heard, there''s not even one game was developped using java.



Well that''s what''s great about universties... it''s a chance to do something that no one else has done!

There are Java games out there, and Java is getting major support among mobile platforms (mobile phones for example - think I''ve even heard rumors of a GBA JVM). Nokia''s N-Gage has MonkeyBall, Tomb Raider and Tony Hawk on it, which are all Java.

There is no reason why Java cannot be used to create a decent 3d game on todays machines. It''s flexible, powerful and mature. Anyone who says otherwise is just closed minded.

Once upon a time a lot of the C community shunned C++, the way C++ now shuns Java. To dismiss a platform by it''s popularity rather then it''s technical abilities is shortsited.

If you want to keep down the Java route, have a look at:
http://www.amazon.co.uk/exec/obidos/ASIN/1592730051/qid=1080574730/sr=2-1/ref=sr_2_3_1/026-0761487-4754867
"Developing Games in Java" by David Brackeen

As this is for an academic project it makes sense to properly investigate this avenue with Java, it also provides you with a wealth of comparison material with other languages, as at least you on your team know C++. Consider the rest of the team too - there is no point going off one way while they go another.

I get the feeling that you''ve written off Java already, so to answer your last question: http://www.libsdl.org/index.phpprovides cross platform bindings for various things in C++, but the licencing may not suite your needs.

Share this post


Link to post
Share on other sites
dmikesell    157
quote:
Original post by paulsdsrubbish
Once upon a time a lot of the C community shunned C++, the way C++ now shuns Java. To dismiss a platform by it's popularity rather then it's technical abilities is shortsited.



But I get the feeling that the converse often happens: because a language is popular, its technical abilities are sometimes misinterpreted. Java's great for client/server web applications. The fact that the overwhelming majority of games are still done in C and C++, however, says (to me anyway) that Java isn't ready for this arena. Some of its exclusion is likely due to the bias that you allude to, but game companies exist to make money. If Java were truly a better solution than C and C++ for games, I would have expected more widespread adoption by now. Why not switch if you can make games that are just as good and cut your development time? It makes good business sense.

I'm not trying to turn this into a flame war, but I think Java missed the boat for these kinds of applications. If anything, C# will start taking "market share" away from C/C++ in the future, not Java.

[edited by - dmikesell on March 29, 2004 12:14:02 PM]

Share this post


Link to post
Share on other sites
markr    1692
quote:
Original post by Challenger17
now the question is. among mainstream games(those famous ones of course) on mainstream platforms i''ve ever heard, there''s not even one game was developped using java.



I have heard of some games being developed with Java. Admittedly, they were not typically "100% pure java" as tended to use native code for some things.

But a lot of web games exist in Java.

quote:
java is slow


I''m afraid you have been misinformed. You are obviously using it incorrectly if you find it too slow (either that or doing something VERY intensive).

If Java does not perform well enough for your game, rewrite the low-level rendering code in C, and call it as a JNI library. That is likely to include only a tiny proportion of your code, but will be making up a large proportion of the runtime (as determined by your profiler).

But a lot of optimisations can be done just by coding it correctly in Java.

quote:

Is here anybody familiar with java-game developping? any experience? any ideas?



Only on J2ME devices. Java is obviously very slow on J2ME devices, but this is largely because they have extremely slow CPUs (and their libraries suck a lot). But that''s just me having a whinge

But developing for J2ME is fun in a kind of masochistic way... having a few 100k to play with, a very slow processor, limited debugging capabilities and a recalcitrant javax.microedition library is certainly challenging

quote:

should we change the plan and use C++ together with Direct3D instead? but by doing that how can we make it cross-platform?



You can make it x-platform without using Java. You can use C++, and openGL - then you will only need to rewrite your UI / Startup / Event handling code.

Or you can use C++, SDL, and OpenGL - then you should (theoretically) have to rewrite exactly nothing. On the other hand, you would then be limited to platforms supported by SDL.

Mark

Share this post


Link to post
Share on other sites
dmikesell    157
quote:
Original post by markr
You can make it x-platform without using Java. You can use C++, and openGL - then you will only need to rewrite your UI / Startup / Event handling code.



Not if you use a portable GUI toolkit like wxWidgets (formerly wxWindows).

Share this post


Link to post
Share on other sites
Ataru    133
If cross platform dependancy is the reason to use Java, you should use C++ in this case.

Why? Java3D Only supports linux and windows, it does not support mac. Just write it in OpenGL and use glut. You can easily compile the same code in both windows and linux platforms.

Except for a few minor compilier syntax differences, it''s all the same.

If you need to stick with Java, don''t use Java3d. It is very buggy, we''re developing in it right now, and we are moving away from it.

Instead, use something like JOGL, those are wrappers for OpenGL. They are much better, more stable, and perform wayyyy way better.

Share this post


Link to post
Share on other sites
UfoZ    150
quote:
Original post by paulsdsrubbish
Nokia''s N-Gage has MonkeyBall, Tomb Raider and Tony Hawk on it, which are all Java.



Actually, they''re native C++.

Share this post


Link to post
Share on other sites
teamonkey    200
I''m sure this sort of thing has been covered many, many times before. :/

Regarding cross-platformability, remember that C++ needs to be recompiled on/for every target whereas that''s not true for Java. Not that that makes a difference as you''ll still have to debug for multiple platforms.

It''s only a matter of time before Java3D is ported to the Mac. The trouble with JOGL or LWJGL is that they are both lower-level APIs and require OpenGL drivers on all platforms.

And Java may be slightly slower than equivalent code in C++ (or it may not, you never know) but any difference will be near-unnoticable for pretty much everything you''ll want it to do.

Share this post


Link to post
Share on other sites
Aldacron    4544
Java3D may not be the answer for you. There is a much faster scenegraph library avaiable called Xith3D. It''s not yet in a 1.0 release, but is very stable and much. much more performant than Java3D (on which it is based). Internally, Xith is currently implemented on top of JOGL, an open source, AWT/Swing-based native OpenGL interface (Linux/Mac/Windows) which was started by Sun (along with other gaming APIs). Finally, LWJGL was written for games from the ground up. It''s a native interface (Linux/Mac/Windows) to OpwnGL, OpenAL, and native input (including DirectInput on Windows). One indie title has been released with it already and several more are under development.

Share this post


Link to post
Share on other sites
nonnus29    105
People who don't know what they are talking about shouldn't post anything at all (dmikesell ).

There are two big problems with using Java in 3d:

1. Loading binary files - you can't cast a chunk of memory to a MD2 header or whatever. You have to parse the entire file.

2. Java does bounds checking on arrays; for processing massive amounts of vertex information this can be a noticable performance hit.

Otherwise various benchmarks have shown that managed, just in time compiled code is faster than native code (this is true for c# and java). The future is managed code.

[edited by - nonnus29 on March 30, 2004 1:11:41 AM]

Share this post


Link to post
Share on other sites
Challenger17    116
thx every one! your suggestions are very helpful!

i''ve got to emphasize our game is designed to run on Personal Computer, not on mobile device or PDA, etc. so anything like J2ME would not be taken into consideration. i think now what makes me worried most is JAVA''s performance hit. yes JAVA is easy to learn, java is pure OO, java can definitely cut the development cost, java doesn''t need to be compiled... i know its advantage. but in order to have all these advantage, there''s cost, right? and IMHO i think that cost is the performance hit. for now the Virtual Machine technology still doesn''t have enough strength to beat those "compile-type" language like C/C++. what i don''t know is HOW MUCH performance hit there is. so i wonder if there''s any successful example : a popular game developped by java. like Markr said some game is being developed by java, but how many is designed for PC? and which one of them is successful?

if there''s no benefit of taking this avenue, i wouldn''t take it.

btw, we won''t use both C++ & java, coz that would increase the complexity of the project.

Share this post


Link to post
Share on other sites
teamonkey    200
AlienFlux: www.puppygames.net

Seriously, the performance hit is very small. You''ll also have a hit when doing trig on x86 machines, but again this is small. There''s also an extra bit of memory needed for the JRE.

I could play Q3A on a P200MMX with 64MB RAM and Voodoo Graphics card (remember them?). Assuming that you produce a game engine as complex as Q3A (highly unlikely for a university project) in Java, then you might only be able to run it on a PII 266 and a Voodoo2 card (remember them?).


Is it quicker to code in Java? Yes. Does it matter? In this case, yes.
Performance hit? Slight. Does it matter? Not a jot.

Share this post


Link to post
Share on other sites
Zahlman    1682
quote:
Original post by nonnus29
There are two big problems with using Java in 3d:

1. Loading binary files - you can''t cast a chunk of memory to a MD2 header or whatever. You have to parse the entire file.



Wtf. You certainly do NOT have to parse an entire file to extract header information. Look up the InputStream and OutputStream classes and their subclasses. You do need to extract each element of a header, yeah; but it''s not really that big of a deal. I suppose that''s what you were really getting at - but I can''t see that being a "big problem with using Java [for] 3d". It gains you a measure of safety and explicitness about what you''re doing, anyway. Oh, and if your binary file includes multiple length-counted fields, then you''re stuck doing that kind of processing *anyway*.

quote:

2. Java does bounds checking on arrays; for processing massive amounts of vertex information this can be a noticable performance hit.



Some compilers can optimize away the bounds checking in easy cases. On other compilers, you can sometimes realize a speed gain by the (admittedly ugly) hack of using an Exception to break out of the loop instead of an explicit check (so that you only do the implicit check that would have to happen anyway).

Share this post


Link to post
Share on other sites
GamerSg    378
quote:
Original post by teamonkey
The trouble with JOGL or LWJGL is that they are both lower-level APIs and require OpenGL drivers on all platforms.




Wow i didnt know nVidia and ATI were releasing Java3D drivers.

What do you think Java3D actually uses below it''s bloated interface?

All NGage games released on the MMC cards are coded for the Symbian OS in C++. Java gaming on mobile phones is a joke(I have a Java enabled phone).

Like some people said, if Java were so good, why hasn''t any game company taken the plunge and gone 100% java code? Most of the Java games (less than a handful) used Java for the logic of the game but all had C++ renderers.

My diploma taught us OpenGL in Java and from my experience, you should stay away from it. Or, you could try doing a few benchmarks and testing the performance yourself.

And i would say C++ with cross-platform librariers is still more portable then Java.

Share this post


Link to post
Share on other sites
polly    532
quote:
On other compilers, you can sometimes realize a speed gain by the (admittedly ugly) hack of using an Exception to break out of the loop instead of an explicit check (so that you only do the implicit check that would have to happen anyway).


Never, ever do this. The code is uglier and its always slower- as Exceptions were designed only to be used in exceptional conditions (hence the name), never as a way to break out of a loop.

Jon

EDIT: Typo

[edited by - jonpolly99 on March 30, 2004 4:36:43 AM]

Share this post


Link to post
Share on other sites
paulecoyote    1065
quote:
Original post by UfoZ
quote:
Original post by paulsdsrubbish
Nokia''s N-Gage has MonkeyBall, Tomb Raider and Tony Hawk on it, which are all Java.



Actually, they''re native C++.


http://www.forum.nokia.com/main/1,6566,050_40,00.html

Err I guess so. You should really post some proof when contridicting someone like that. :-)

HOWEVER in my defence SplinterCell, a Tomb Raider game (though not the touted one) and of course this one from the news ARE: http://bomber.whiletrue.com/

Share this post


Link to post
Share on other sites
paulecoyote    1065
quote:
Original post by Challenger17
thx every one! your suggestions are very helpful!

i''ve got to emphasize our game is designed to run on Personal Computer, not on mobile device or PDA, etc. so anything like J2ME would not be taken into consideration.



Alrighty, sorry about my posts being a bit off topic, but if it can do games on a mobile phone then it can do games elsewhere.

Java will be easier to deploy over multiple platforms - because although you can link to different libraries with C++ for specific platforms, you will likely have to use more then one compiler and compile it on each of the OSs you want to test it on each time. Java offers a single set of tools, CVS integration with free tools like Netbeans and Eclipse and cool features like webstart that let you distribute your fully fledged game in a way that it can automatically update itself.

You can achieve the same things with C++ and an array of tools, and you may be able to achieve all of the above in free tools (although the webstart thing may well need something like Install Shield).

You have to go with what your team knows, you''ve not mentioned time scales but I''m sure they are going to be pretty tight.

If this is an academic (and marked) venture then your best bet is to stick with what you know and prove your design and tools decisions.

You sound pretty sold on C++, just make sure the rest of your team are as competent as you at it.

Have a look at this site http://www.brackeen.com/home/ it contains example java games and source code from the book I posted about before.

Good luck anyway!

Share this post


Link to post
Share on other sites
dmikesell    157
quote:
Original post by nonnus29
People who don't know what they are talking about shouldn't post anything at all (dmikesell ).



What do you disagree with that I posted? Debate my post with me, don't fire a stupid attack across the bow and then run for cover.


[edited by - dmikesell on March 30, 2004 9:06:09 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by teamonkey


It''s only a matter of time before Java3D is ported to the Mac. The trouble with JOGL or LWJGL is that they are both lower-level APIs and require OpenGL drivers on all platforms.



Java 3D is available for Mac:
http://www.apple.com/downloads/macosx/apple/java3dandjavaadvancedimagingupdate.html

On the Mac Java3D will use OpenGL for its 3D rendering. For Windows it can use either OpenGL or Direct3D. It needs these low level API''s to get hardware acceleration.

Share this post


Link to post
Share on other sites
HenryApe    120
Java will probably work well for your purposes.

Using a scenegraph architecture helps productivity but I would not recommend Java3D, the multi-threaded architecture that makes it suitable for multi-processor scientific visualizations means trouble for most games. Better alternatives include the Xith3D project, which is a game-optimized open source port of Java3D, or straight OpenGL (through LWJGL or JOGL).

To debate with dmikesell
quote:
The fact that the overwhelming majority of games are still done in C and C++, however, says (to me anyway) that Java isn't ready for this arena.

There aren't any JavaVMs available for consoles, that's the only really good reason why Java isn't ready for AAA-level development of titles suitable for consoles.

Then there are of course other reasons why established firms may not be ready for Java development yet. For instance, there will be a cost associated with having their programmers learn the language and its tools, and their productivity tools may be tied C/C++.

That equation is likely to shift with time though. Java development is very common in other industries than game development and at colleges, both sources for recruitment to the game industry.
quote:
If anything, C# will start taking "market share" away from C/C++ in the future, not Java.

Pity that Microsoft started competing with Sony in the console market. That move probably ensured that C# will never make it onto the PS2. Sure, Java may never make it onto the Xbox, but the PS2 is still BY FAR the most important console and Java just has to cross that hurdle to become a very attractive candidate for AAA-level development.

Java-compiler firm Excelsior (developers of JET) have mentioned in the forums at javagaming.org that they have been in contact with Sony and Sun regarding the terms of a PS2 compile-target, then there is also GCJ, and the KaffeVM has been ported to Linux for the PS2. It wouldn't surprise me if some company drops a Java game script engine into one of its PS2 games in the near future.

We have also seen several off-the-shelf titles developed in Java in genres that may not be suitable for console ports (or by companies not eligable for console licenses), and it will be very interesting to see what happens when one such game really hits it big in the market (think Doom's effects for C development over assembly).

Still, just as there are still plenty of business systems in COBOL, C++ will be around long after something new (Java, C#, D, whatever) pushes it from its top position in desktop/console-AAA-client-game development (Java already owns mobile development, C++'s position is becoming contested on the server side, and Director is a strong contender for non-AAA level games such as children's games).

[edited by - HenryAPe on April 16, 2004 7:23:33 PM]

Share this post


Link to post
Share on other sites
GekkoCube    116
Java is not necessarily bad for games, I just wouldnt say it is a viable language for high-profile, mainstream, performance games.

However, I''ve seen J2ME games running on high-end cellphones that can do fancy 3d graphics. Also, voxel graphics is always an alternative to 3d-polygons.

One more thing: with Java, it''s "write once, debug everywhere."

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
There is also a very promising 3D API in Java called jME (jMonkey Engine). http://www.mojomonkeycoding.com. This looks very interesting, and I was more impressed by it than Xith3D.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by nonnus29
There are two big problems with using Java in 3d:

1. Loading binary files - you can''t cast a chunk of memory to a MD2 header or whatever. You have to parse the entire file.



nope

quote:

2. Java does bounds checking on arrays; for processing massive amounts of vertex information this can be a noticable performance hit.



which is why you shouldn''t try to force c++ style on java. use the proper way to do it using buffers, this is the way lwjgl does it, and it''s quite fast for large amounts of vertex data

quote:

Otherwise various benchmarks have shown that managed, just in time compiled code is faster than native code (this is true for c# and java). The future is managed code.



of course. lots of people compare equal code in c++/java and say c++ has a performance edge. well, if i''m developing a game, which will turn out faster: using c++, and spending a week hunting down all the memory bugs, or using java(or for those inclined, c#) and spending that week a, say, O(N^2) algorithm into O(N)? you can program the whole thing in assembly even, and as andre lamothe says all the assembly in the world ain''t going to make a O(N^2) algorithm much faster.

sure c++ may be faster in benchmarks but we''ll see how many jit''d (or managed) games show up in the future.

Share this post


Link to post
Share on other sites