Water dynamics needed

Hello all.

  I'm rather new to jME so I'm not familiar with all its features.

However, there are two effects I need to simulate and perhaps someone can lead me toward literature that can help.

The two things I need to figure out:

  1. Buoyancy in water on arbitrary shapes.
  2. Water surfaces generated from a Fast Fourier Transform technique.



    I'm familiar with the coding required for #2 but was wondering if anyone's heard of an implementation in jME or if there would be any issues I might run into trying to get it working.



    Buoyancy I know has been done before many times but I can't find any solid references or articles on the basic idea.



    Thanks for any help!

    -Len


Hm.  Not a lot of takers on this one.



Okay, here's a simpler question:

  I may want to build my own FFT-based water simulation.

There are FFT libraries out there for C++ that make it relatively easy.

Does anyone know of similar libraries for Java that would work nicely with jME?

Or is it fairly easy to tie into C++ libraries from jME?



Just trying to get a handle.

It's kind of important before choosing to go with jME for a pretty big project I'm starting.



Thanks.


len said:

Does anyone know of similar libraries for Java that would work nicely with jME?

Having never heard about FFT water simulations before, I don't know what specific functionality in such a library you are looking for.
But of course there are a number of good math libraries available, http://commons.apache.org/math/ is but one of them.

len said:

Or is it fairly easy to tie into C++ libraries from jME?

The question should be "Or is it fairly easy to tie into C++ libraries from java?" - and the answer is, it is doable in a reasonable amount of time if you are familiar with the JNI (java native interface), the library you are trying to interface to, and c coding. Optionally you can try a wrapper generator like SWIG, but IMO that would not really be worth the effort for a small, specific subset of a math lib.

Thanks for the response!

There appear to be some java FFT implementations out there.

I guess the next question is whether the speed will suffer under Java compared to C++ for such a thing.

The basic idea of FFT water simulation is:

  • Truly realistic ocean surfaces are made up of an essentially infinite superposition of pure sine waves
  • We can describe that giant collection easily in frequency (fourier space) and even have time propagation defined there.
  • The (inverse) FFT algorithm lets us quickly move from frequency space to xyz space so we get position data
  • We height displace a poly grid based on this continuously changing data and we get a pretty dang sweet ocean surface.
  • Repeat at 60 fps or whatever the hardware can handle.



    I know the PS3 has this functionality built-in at a hardware level so oceans should be looking pretty nice in those games eventually.

    Any real-time ocean system that looks really good is probably using this technique.  It has become pretty standardized.

    There is at least one free real-time engine (like jME) that does this out of the box but I would like to stick to Java if possible and I like the jME docs and structure.


len said:

Or is it fairly easy to tie into C++ libraries from jME?

Probably you can integrate it with ODE and get the wrapper much cheaper, as you only need to modify ODEJava (and jME Physics, of course) only a little...

Yeah, good idea.  I was dreaming that ODE would include something like this already but no luck.

But, hey!  ode.org is back up and running!  Last few days it was dead.

I actually also discovered that one of the fastest FFT implementations, FFTW (Fastest Fourier Transform in the West, believe it or not) actually has some java bindings ready to go.  Very cool.  Java may work out after all.