Game development

Hi. I’m starting to learn how to use xith3d, and my own experience is that there are very few examples for newbie’s like me on how to create 3d games.
My intention is to post my own code as it develops. I hope this is ok. This way I and others can also get some feedback on what to do / not to do.

The code as it is now uses the ASE loader to load the world. I have added a very simple keyboard control that changes the view.
One of the current problems with the “game” is that it will crash on a slow computer. I think this might have something to do with the handling of threads, but I am working on this now.

I successfully loaded a level with 200000+ polygons on a p4 2.4 GHz with an ATI Radeon Mobility 9000 graphics card with 64mb memory. I think this is quite nice but I removed some of the demanding objects for this example because it will totally crash a computer if it is not fast enough to run the code.
If it should crash, try changing the sleep thread in the while loop to e.g. 40.

If you have any comments they are of cause very welcome :slight_smile:

Source: http://www.harme.dk/testlevel.zip

http://www.harme.dk/level1.jpg

http://www.harme.dk/level2.jpg

http://www.harme.dk/level3.jpg

  • 03-10-2005
    Added simple material and light

-03-12-2005
Added Fog

Win2k/MatroxG400 (OGL 1.1.3 aug 31 2004)/Celeron500Mhz/256MB RAM

As you can see, my machine is from the stone aged. Still, your both demos launched so thats a good thing. Most 3d demos dont want to run my machine anymore.

Few issues:

  1. readme.txt
    attach always a short readme.txt file describing the demo/app and xith3d, jogl and/or lwjgl versions you have used. There are so many versions avail and sometimes app just want to have that one specific version to work properly.

  2. launch.bat
    This is a launch bat example I used. I dont have a global envvars for jogl and xith folders. I always create a this batch to launch applications. I sort of create a “java system32” path on the fly.

You demo needs vecmath.jar file from the xith distro, so I added a classpath reference.


set xith=C:/projects/xith3d/lib
set jogl=c:/projects/jogl/lib
set cp=%xith%/vecmath.jar
set cp=%cp%;./libs/xith3d.jar;classes;.
set cp=%cp%;%jogl%/jogl.jar

java.exe -Djava.library.path=%jogl% -cp %cp% org.xith3d.gsg.Engine
pause

Files:
c:/projects/xith3d/lib/vecmath.jar
c:/projects/xith3d/lib/xith3d.jar (used your bundles jar instead)
c:/projects/jogl/lib/jogl.jar
c:/projects/jogl/lib/jogl.dll
c:/projects/xith3d/testlevel/launch.bat
c:/projects/xith3d/testlevel/ ase/, classes/, src/*
c:/projects/xith3d/testlevel/libs/xith3d.jar

Versions:
jogl: jogl-1.1.0-b04-bin-windows.zip
xith: your bundled jar, dont know a buildnumber.

Both jogl.jar and xith3d.jar buildscripts dont add “Implementation-Version” tag to the MANIFEST.MF file. Its a pity as java lib version controlling is sometimes a nightmare.

  1. demos
    Well, slow very slow. But dont worry, its only my machine. Demo did not have a fps counter so cannot exactly say how slow a frame renderer run.

  2. unzipping
    Had problems with .jar file. I use Powerarchiver and it did not work. I managed to unzip it with 7-Zip File Manager.

[quote]Win2k/MatroxG400 (OGL 1.1.3 aug 31 2004)/Celeron500Mhz/256MB RAM

As you can see, my machine is from the stone aged. Still, your both demos launched so thats a good thing. Most 3d demos dont want to run my machine anymore.
[/quote]
It’s nice that it runs on you computer. I have still only tested it on the Mobility 9000 graphics card which really stinks :slight_smile: The demo of cause do not demaind anything specific right now, so this could also be the reason it works on your computer :slight_smile:

[quote]Few issues:

  1. readme.txt
    attach always a short readme.txt file describing the demo/app and xith3d, jogl and/or lwjgl versions you have used. There are so many versions avail and sometimes app just want to have that one specific version to work properly.
    [/quote]
    Your right. I’ll add a readme text explaning the use and version numbers

[quote]2) launch.bat
This is a launch bat example I used. I dont have a global envvars for jogl and xith folders. I always create a this batch to launch applications. I sort of create a “java system32” path on the fly.
[/quote]
I’ll try to look at this, but I’m not sure it will be just yet. I’ll need to reinstall my system first to be sure where to put the different files so they work, because as I have installed xith3d (jogl ect.) they are copied to so many directories that it will be impossible for me to know if it will work.

[quote]3) demos
Well, slow very slow. But dont worry, its only my machine. Demo did not have a fps counter so cannot exactly say how slow a frame renderer run.
[/quote]
I hope that others will try to run it and give me some feedback. It’s nice that it didn’t crash on your computer, but I still think there is something wrong with the rendering method.
Shouldn’t you test to see that the render is finished before rendering the next frame?

[quote]4) unzipping
Had problems with .jar file. I use Powerarchiver and it did not work. I managed to unzip it with 7-Zip File Manager.
[/quote]
I packed the files with winrar, so I don’t understand the rars don’t work perfectly, but maybe I should use zip’s instead?

Correction, I had problems with the original download .rar file , not .jars inside the package. Probably you play safe if just use .zip files. At least its more widely supported.

jars are zips. Rars arn’t zips are they?

Kev

indeed. rar is not really a good way to distribute java programs as it’s primarily windows, and even then not ubiquitous.

When you say it crashes - got a stack trace or anything? What happens when it crashes?

Will.

The file has now been changed to zip, and I have added a small readme and also included vecmath.jar

When it crashes, the entire computer freezes up and I am not able to do anything (not even ctrl+alt+del). Then after a while, I get an error that something has happened to the graphics driver, and the screen switches to 640x480, 16 colours, and then the computer reboots :slight_smile: I can’t see a errormessage because of this, and I can’t seem to pipe it out?

I have updated the code to include simple material and lightning support. This is taken from one of the examples in the xith package, and works ok. I would however like to use the material information included in the ase file. Is it possible to do this, and how? I can’t seem to find an example on this. The only thing I can find is the AseMaterial() method, but I’m a little unclear on how to implement it?

You’re not the first to ask. Material’s are a 3dsmax only thing I am afraid. Xith3D uses OpenGL which supports textures and shaders, so you will have to make do with them.

Will.

Eh? OpenGL supports materials, or are ASE Materials very different things?

Kev

[quote]Eh? OpenGL supports materials, or are ASE Materials very different things?
[/quote]
I was also wondering about that. Also, if there is no support for ase materials, what does the AseMaterial class do?

I have changed the zip to include all libraries and dll’s needed. Could someone test if it works?

Hi. I have added a fps counter and I was very surprised by the result.

When I just run the level (without sky, fog or light), I get approximately 180fps.
By adding the sky to the scene I get 160fps
Adding fog gives me 130fps
Adding ambient light gives me: 120fps
Adding directorial light gives me 90 fps!

Can it really be true that fog and directorial light takes so many resources or am I doing something wrong? If not, is there anything I can do to increase the performance?

There is an error with either xith3d or the new x600 mobility graphics card.

I tried the “game” on a friend’s computer, and it doesn’t show fog?!? He has a Ati x600 mobility SSE2 graphics card with 128mb ram! When he runs some of the new games (which runs FAST! in comparison to my mobility 9000) there is fog. Is there a problem with xith?

  • edit -
    Isn’t there an error in the Javadoc under Options?

It says: “Whether or not OpenGL’s second exponential fog algorithm (GL_EXP2) should be used instead of GL_EXP2 in the rendering of exponential fog.”

  • edit -

[quote]Eh? OpenGL supports materials, or are ASE Materials very different things?

Kev
[/quote]
ASE stores all the 3D MAX stuff like bump maps, alpha maps, self illumination maps and many others. Can OpenGL support these?

(see: http://www.cglearn.com/tutorials/max3/12_sub_object_materials_still_life_pt_2.html about 30% down the page for a partial list)

Will.

[quote]Hi. I have added a fps counter and I was very surprised by the result.

When I just run the level (without sky, fog or light), I get approximately 180fps.
By adding the sky to the scene I get 160fps
Adding fog gives me 130fps
Adding ambient light gives me: 120fps
Adding directorial light gives me 90 fps!

Can it really be true that fog and directorial light takes so many resources or am I doing something wrong? If not, is there anything I can do to increase the performance?
[/quote]
An interesting point was raised about very high framerates in the lwjgl forums. When your frame rate is that fast, any extra calculation is likely to drastically cut your frame rate. Perhaps a less squewed measure is the amount of nanoseconds the new feature adds to the rendering frame.

Will.

[quote]There is an error with either xith3d or the new x600 mobility graphics card.

I tried the “game” on a friend’s computer, and it doesn’t show fog?!? He has a Ati x600 mobility SSE2 graphics card with 128mb ram! When he runs some of the new games (which runs FAST! in comparison to my mobility 9000) there is fog. Is there a problem with xith?
[/quote]
Could it be a driver problem?

Yes, that was an error.

It now reads:


the Javadoc bug, it now reads:

/**
 * Whether or not OpenGL's second exponential fog algorithm (GL_EXP2)
 * should be used instead of its first exponential fog algorithm (GL_EXP)
 * in the rendering of exponential fog.
 */

To find out the difference between the two, I suggest you check an OpenGL resource.

Will.

Ok, and as it states all should be fine until the framerate drops below 60. Great.