jirr and irredit
jirr and irredit
Does jirr load irredit stuff? I noticed there wasn't an example 15.
If anyone is still interested in example 15. Code will look like this:
Enjoy!
Code: Select all
// java port done by jirr
import net.sf.jirr.*;
import java.io.IOException;
/*
Since version 1.1, Irrlicht is able to save and load
the full scene graph into an .irr file, an xml based
format. There is an editor available to edit
those files, named irrEdit on http://www.ambiera.com/irredit,
which can also be used as world and particle editor.
This tutorial shows how to use .irr files.
Lets start: Create an Irrlicht device and setup the window.
*/
public class TestLoadIrrFile
{
// load the wrapper lib at startup
static
{
System.loadLibrary("irrlicht_wrap");
}
public static void main(String args[])
{
// ask user for driver
E_DRIVER_TYPE driverType = E_DRIVER_TYPE.EDT_OPENGL;
System.out.println("Please select the driver you want for this example:\n"
+ " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"
+ " (d) Software Renderer\n (e) Burning's Software Renderer (f) NullDevice\n"
+ " (otherKey) exit\n\n");
try
{
int i = System.in.read();
switch (i)
{
case'a':
driverType = E_DRIVER_TYPE.EDT_DIRECT3D9;
break;
case'b':
driverType = E_DRIVER_TYPE.EDT_DIRECT3D8;
break;
case'c':
driverType = E_DRIVER_TYPE.EDT_OPENGL;
break;
case'd':
driverType = E_DRIVER_TYPE.EDT_SOFTWARE;
break;
case'e':
driverType = E_DRIVER_TYPE.EDT_BURNINGSVIDEO;
break;
case'f':
driverType = E_DRIVER_TYPE.EDT_NULL;
break;
default:
System.exit(0);
}
}
catch (IOException e)
{
e.printStackTrace();
}
// create device and exit if creation failed
IrrlichtDevice device = Jirr.createDevice(driverType, new dimension2di(640, 480));
if (device == null)
{
System.exit(1); // could not create selected driver.
}
device.setWindowCaption("Load .irr file example");
IVideoDriver driver = device.getVideoDriver();
ISceneManager smgr = device.getSceneManager();
/* Now load our .irr file.
.irr files can store the whole scene graph including animators, materials
and particle systems. And there is also the possibility to store arbitrary
user data for every scene node in that file. To keep this
example simple, we are simply loading the scene here. See the documentation
at ISceneManager::loadScene and ISceneManager::saveScene for more information.
So to load and display a complicated huge scene, we only need a single call
to loadScene().
*/
// load the scene
smgr.loadScene("../media/example.irr");
/*
That was it already. Now add a camera and draw the scene
*/
// add a user controlled camera
smgr.addCameraSceneNodeFPS();
// and draw everything.
int lastFPS = -1;
while (device.run())
{
if (device.isWindowActive())
{
driver.beginScene(true, true, new SColor(0, 200, 200, 200));
smgr.drawAll();
driver.endScene();
int fps = driver.getFPS();
if (lastFPS != fps)
{
String str = "Load Irrlicht File example - jirr [";
str += driver.getName();
str += "] FPS:";
str += fps;
device.setWindowCaption(str);
lastFPS = fps;
}
}
}
device.drop();
System.exit(0);
}
}
Thanks. I'm kind of tossed now, because I tried dev c++ and it works perfectly. Jirr seems to run a little slower on my computer and jerks a little more. It's also kind of missing the real selling point of java which is simple cross platform compatibility, but I imagine that's because it's still a little immature.
Sorry, but what Do you mean by immature and selling point? What do you expect in fact? Full time support and dozens of programmers doing work for nuts?fireside wrote:Thanks. I'm kind of tossed now, because I tried dev c++ and it works perfectly. Jirr seems to run a little slower on my computer and jerks a little more. It's also kind of missing the real selling point of java which is simple cross platform compatibility, but I imagine that's because it's still a little immature.
jirr is an open source project and is done by hobbyists in the rare spare time. No one pays anything for it nor adds code nor provides binaries for other packages at this very moment. And do not forget: You are getting it for free. Also it is open source. So if you are missing something you can add it and contribute to the project!
Furthermore: though there are only binaries for windows it is still possible to compile it for linux at least. The cvs contains the required makefiles. Ever heard of bolzplatz 2006 (really cute soccer game hosted on sourceforge) that was done using jirr and was released for linux also?
And what is more easy: You could take the .h and .cpp files from the src package and compile it on your own. No need for getting the right version of swig for generating the required sources. Just compile the native part and get lucky. Should be possible for all platforms that are supported by irrlicht.
If you do not know to start with cpp or java: Try the one that suits you the most. There are pros and cons for any way. If you are familiar with cpp go with irrlicht. If you want java give a try to jirr. If you have not programmed in either language before - go with the one tthat gives you most control and independence. jirr is not the holy grail It has been done to give java programmers the possibility of using a state-of-the-art 3d engine.
Apart from that: Currently there is only one way to get a device independent library for java and this requires you to make your own library become part of the JDK! Otherwise you have to release your custom lib for all possible platforms.
If you must have device independent libs use java 3d (though that requires additional native libs also).
And one final word to speeds: Yes, native irrlicht is faster then jirr (roughly 2 to 7%) That is due to connecting both worlds. It will never be possible to run both at the same speed. So if you cannot live with a difference of 2 frames when running at 100 fps in irrlicht that is kind of a problem, isn't it?
I should add that java 3d is generally a lot slower than this difference when it comes to frames per second ...
At least: good luck to your own projects!