Porting from 2D to 3D

Hi,
I’m the architect of Tacticat http://www.tacticat.com, a 2D sim for sailing races written in java.
The sim is a technical training tool, intended for racers training for the olympics, altough it has naturally evolved during a year to a full multi-user interactive game.
A server-client all-java, the servers today located in Dallas, London and Brisbane to cover sailors from all over the world. The client side a java application via webstart.

We have decided to go 3D. We want to keep all the communications layer, physics engine and rules engine (sailing rules i mean), and we have decided that today 2D clients will play concurrently wit the future 3D clients, in the same ‘universe’.

After studying the available possibilities we have decided to give Java 3D a try, the first proto seems OK. I’d like to know of other people having done something similar. The recommended NOT-TO-DO and the important things not to forget.

Any ideas, recommendations or whatever are welcome.
And if you like sailing you can try the sim (it is free of course).

Amando Estela
Tacticat,

Hi !

There will be a working to do waht you want but it is totally possible with Java 3D
Take also a look on jogl which is very efficient in 3D.

How important are the performance gains using JOGL?
With Java3D I do have scenograph functionality, that’s good.
What about the ‘universality’ of the application?, I mean I need it to be runnable by a wide variety of users and platforms, most of the current users of Tacticat run the 2D sim with small computers and low-end graphic cards… JOGL or Java3D then? or is it the same?.

I’d rather not start studying JOGL if I can avoid it. Just understanding Java3D took me a while…

aestela.

Stick to Java3d for this kind of application. JOGL is a pure OpenGL binding, so there is no scenegraph included and deployment is slightly more complex (there is a webstart extension entry to deploy the needed jar and native libraries, so it is not that problematic). If you need the latest in graphics (e.g. shaders), you might have to use JOGL, but if you are satisfied with the visual possibilities, Java3D is good enough.

Very satisfied. It’s a big jump from the current 2D sim.

We’re starting the porting soon. Right now we have tested all techniques we will need:

  • loading a 3DS model for the boats
  • moving the boats using the current physics engine
  • moving the camera(s), we haven’t yet decided how many we will give to the user. A external camera, aft and up of their boat and maybe 4 views (bow, aft, starboard and port) from the boat.
  • displaying text with the boats and HUD-like
  • capturig the mouse and key events that will be forwarded to the existing code

One thing we haven’t solved yet is that when we go 3D it makes sense to put waves, both in the display and in the physics engine. The physics has no secret and we can easily model the boat behaviour but what about the display part?.

How do we create the waves? We would have the function y=f(x,z,t), we know for every point in the water what is its height at any time. How can we create it in terms of background, objects, shapes or whatever? And move it? (waves move, and get bigger, and disappear!)

Anyone with a recommendation??
That would help a lot.

A.

You could create a regular grid representation of the water surface:

o Compute the initial vertices of this grid incorporating the height values via your y=f(x,z,t=0)
o Create a TriangleArray using the computed vertices as coordnate array
o Create a Shape3D with the TriangleArray as geometry
o start your game loop

  • Recompute the vertices of the grid using y=f(x,z,dt*n)
  • Update the coordinates of your TriangleArray with this data

This should basically work. Start with a rough grid resolution (e.g. 32x32) and see how the performance is going. There might be more performant ways to implement this, but I am no java3d pro…