TGE as a Java component?
by James Anderson · in Torque Game Engine · 03/17/2005 (9:03 am) · 13 replies
Can anyone here tell me whether it would be possible (in principle) to use TGE as a 3D viewer GUI component in a Java application? For example, would it be possible (via the Java Native Interface) to attach the renderer to a given HWND on a Win32 platform?
Also, would it be possible to write a Java native interface to access the TGE features (to manipulate objects in the world, execute scripts, etc.)?
Thanks in advance for any info on this.
James
Also, would it be possible to write a Java native interface to access the TGE features (to manipulate objects in the world, execute scripts, etc.)?
Thanks in advance for any info on this.
James
#2
03/17/2005 (4:53 pm)
I think the first step would be to write a dll (in C++) that has access to those aspects of Torque that you need. I would be very surprised if Java didn't have some way to access dlls.
#3
03/17/2005 (6:49 pm)
You can do it, but it breaks the core concept that Java was built around by circumventing the black box that Java prrograms run inside of. It would kill any chance of creating it as an applet, though.
#4
Thanks for the reply. Yes, I realise that Torque is all C++ and that it would be no easy task to interface it with Java. However, if Torque has anything like a C++ API, then presumably it would be possible to write a corresponding Java API using JNI. I've done this sort of thing with other components (a VRML browser and a speech recognition engine).
I'm interested in this because I have a Java app which uses an ActiveX component to display 3D content, but I'd like to 'beef up' the 3D side of things. A game engine would be just the ticket, if only I could interface the two. I don't want to have to go the route of rewriting the Java app in C++.
Eric:
Yes, that would be the approach. Java can accesses native code in DLLs via JNI (see here). JNI also allows you to get the HWND of an AWT component (e.g. Canvas) and draw to it (see here). So my question is whether it would be possible to get TGE to render to an arbitrary HWND.
03/18/2005 (1:10 am)
David:Thanks for the reply. Yes, I realise that Torque is all C++ and that it would be no easy task to interface it with Java. However, if Torque has anything like a C++ API, then presumably it would be possible to write a corresponding Java API using JNI. I've done this sort of thing with other components (a VRML browser and a speech recognition engine).
I'm interested in this because I have a Java app which uses an ActiveX component to display 3D content, but I'd like to 'beef up' the 3D side of things. A game engine would be just the ticket, if only I could interface the two. I don't want to have to go the route of rewriting the Java app in C++.
Eric:
Yes, that would be the approach. Java can accesses native code in DLLs via JNI (see here). JNI also allows you to get the HWND of an AWT component (e.g. Canvas) and draw to it (see here). So my question is whether it would be possible to get TGE to render to an arbitrary HWND.
#5
You mean it breaks the portability principle? Okay, yes, but this isn't an issue for me in this project since that principle has already been trampled under foot. :)
Also, I'm working with a stand-alone Java app, not an applet.
03/18/2005 (1:14 am)
David:Quote:You can do it, but it breaks the core concept that Java was built around by circumventing the black box that Java prrograms run inside of.
You mean it breaks the portability principle? Okay, yes, but this isn't an issue for me in this project since that principle has already been trampled under foot. :)
Also, I'm working with a stand-alone Java app, not an applet.
#6
Perhaps you should take a look at Ogre which is a loose collection of components (primarily rendering) that can be picked and choosed from.
03/18/2005 (2:38 am)
Torque isn't an API. It is a fully fledged and tightly integrated game engine with some heavy dependencies. You really can't use pieces of Torque in conjuction with another project. It is designed around the principal of building your project inside the engine.Perhaps you should take a look at Ogre which is a loose collection of components (primarily rendering) that can be picked and choosed from.
#7
Thanks for the clarification. I was aware that Torque isn't an API, but was wondering whether the source code might provide something like an API, on which I could build a Java interface. Anyway, the consensus seems to be that I'm barking up the wrong tree. :)
Thanks also for the Ogre tip. Looks good!
03/18/2005 (2:51 am)
Matthew:Thanks for the clarification. I was aware that Torque isn't an API, but was wondering whether the source code might provide something like an API, on which I could build a Java interface. Anyway, the consensus seems to be that I'm barking up the wrong tree. :)
Thanks also for the Ogre tip. Looks good!
#8
03/18/2005 (3:04 am)
James, I don't think that trying to do this project would be a good use of your time, or even possible.
#9
Received and understood. :)
I appreciate the feedback I've received here. I'll give Torque consideration as a possible stand-alone platform for any future 3D interface projects.
03/18/2005 (3:10 am)
Pat:Received and understood. :)
I appreciate the feedback I've received here. I'll give Torque consideration as a possible stand-alone platform for any future 3D interface projects.
#10
03/18/2005 (8:21 am)
As Matthew stated, Ogre would be a much more viable solution. I wasn't sure of the implementation that you were going for.
#11
-Josh
03/18/2005 (8:52 am)
We use Torque as compiled in a shared library (Python extension). This is primarily a packaging measure and there's really no direct benefit other than having it play with Python a little better. Which might be the same case with Java.-Josh
#12
Another thing you might want to research is Jake2 which is a fully functional quake2 engine written in Java. No kidding.
03/18/2005 (8:58 am)
As a professional Java programmer who has done JNI work I would concur with the majority opinion here. It's theoretically feasible but would require way too much custom C++ coding to be worth it and the chances it will go off without a hitch is pretty much zero.Another thing you might want to research is Jake2 which is a fully functional quake2 engine written in Java. No kidding.
#13
03/18/2005 (9:28 am)
Oh hell! I completely spaced Jake2! It started playing (loudly) when my boss walked in the room a while back. Plus it has complete source!
Associate David Montgomery-Blake
David MontgomeryBlake