Ferrari3D: java3d racing game/simulation/tech demo

Hi all,

I have been using Java3D for quite a while now, and as a result of this I’ve made this racing game to see if it was any good for making games. It’s not actually a game since there is only one car on the track. The collision detection is dodgy, and the physics still need work but overal I’m pretty happy with the result.

I’m very interested in your feedback, although it’s far from completed I’m curious how it rates among Java game design experts. If anyone wants to know how I did certain features just ask.

Download: http://www.freewebtown.com/dennisbijlsma/files/ferrari3d/ferrari3d_150.zip

http://www.dennisbijlsma.com/data/ferrari3d/screenshot1.jpg

http://www.dennisbijlsma.com/data/ferrari3d/screenshot5.jpg

This looks very interesting- I haven’t had time to get it downloaded yet, but the screenshots look great!

Great stuff, works fine here out of the box.

I’m always interested in the simple things: how did you implement text output?

I don’t really understand what you mean by ‘text output’. If you mean the HUD, I override the postRender method of Canvas3D. I read everywhere that it’s supposed to be very slow, but I didn’t see any major differences in performance.

There is one bug that I find really annoying, after loading, when the Canvas3D is created, you have to click it before the keylistener works (I partly solved it by warning on the loading screen). I’m thinking it may have something to do with the lightweight menu and the heavyweight Canvas3D transition. Has anyone else had this problem?

Looking good ;D. Worked without problems. I like the interface graphics! The controls/smoothness of motion needs some work though!

The wheels don’t turn :frowning:

You’ve put a lot of effort into this though, so ignore the complaining. I wonder what is slowing it down so much on my computer.

Erm…they do…at least on my computer ??? About the motion, I get a framerate of 22, dropping to about 17 in the ‘busier’ parts of the track, but since my graphics card is terrible I thought it would be the same or faster on other computers.

Did he mean “steering” turn or “spinning” turn?

They are supposed to turn in both lateral (turning) as well as longitudinal (rolling) direction :wink:

Wow great job. Did you model everything yourself ?(very impressive I think)

Maybe the Frame has focus at first. Either call requestFocus on the canvas in it’s addNotify()-method or add the Listener to the Frame instead (you might have to set focusable to false on the canvas then).

Yes. Although everything consists of the car and the track (which isn’t that good) :slight_smile:

Yet another question :slight_smile: Is it possible to make a material in Java3D look something like the car in this screenshot:

http://www.dennisbijlsma.com/data/ferrari3d/shader.jpg

I’m guessing it uses a custom pixel shader, as the differences in color seem to be caused by the sky texture, so there must be some raytracing involved. This look probably isn’t possible with Java3D’s standard Appearance class, but there seems to be little to no information about how to use GLSL shaders, and I don’t think I’m capable of writing one myself. Is there anyone who can point me to some sort of starting point for this?

Every time I download the file it’s corrupt when I try to open it :-\

[quote]'m guessing it uses a custom pixel shader, as the differences in color seem to be caused by the sky texture, so there must be some raytracing involved. This look probably isn’t possible with Java3D’s standard Appearance class, but there seems to be little to no information about how to use GLSL shaders, and I don’t think I’m capable of writing one myself. Is there anyone who can point me to some sort of starting point for this?
[/quote]
You don’t (necesarily) need pixel shaders to pull that of, let alone raytracing :wink:
Look up for the term “environment mapping” on google, it’s a cheap way of achieving that effect.

Thijs

Erm…yes, you are right. I thought it had something to do with pixel shaders because that’s where I first saw it.

However, I couldn’t find any actual example on how to use it in Java3D. I know that I must render an image taken from the car, combine it with the existing texture, and then use the TexCoordGeneration class to make it look spherical. Is there some actual example of this being done on the internet, and if so, where ???

Most games don’t bother having dynamic environment mapping, the cube maps are just calculated ahead of time somehow (either when the level is made or using a generic artist drawn texture).

Edit: Got it working now, the effect isn’t that noticable, but those little graphical touches make a big difference.

http://www.dennisbijlsma.com/data/ferrari3d/shader2.jpg

I assume you used a TexCoordGeneration object in REFLECTION_MAP mode for the second ‘gloss’ texture?

OK, I’ve finally finished a stable version. You can download it at http://www.freewebtown.com/dennisbijlsma/files/ferrari3d/ferrari3d_150.zip. I also changed the link in the first post. Performance still isn’t too great, but I can’t think of any quick ways to improve it, and it’s not too bad if you have a decent graphics card. Maybe I’ll continue on this in the future, but for now thanks to all who have looked at and answered my questions!

@otelo: Yes :slight_smile:

…or you can use the java.awt.Robot class to move the mouse to where you want, press and release a mouse button. (but I think it is a little slower)