Hello i was wondering if it was possible to Create a particle water easily with the collision detection, so i could make a fluid water system, i did some search on the subject but no one seem to explain how they are doing.
If i am right, i should be using the gpu to move my particle, and the bullet physic to do the collision, but i m not quite sure about this, anyway if some one can give me a hint i would appreciate it.
Hi n3cr0,
I do fluid simulation (water particles colliding and things) using PhysX 3.1. It is included in their SDK.
However, PhysX is written in C++ so you need to write a JNDI wrapper interface to access the C++ methods from Java. To create this interface, I recommend you using the software package named Swig. In my opinion, calling the PhysX methods directly from Java is not such a good idea. Instead, what I would do is write PhysX functions you want in C++, and then call those functions from Java.
For example, if you wanted to create some water particles, instead of writing all the PhysX code in Java you could write a C++ function “createWaterParticles()” which handles all the PhysX logic in C++ and then just call that function from Java using JNDI. I find this works out nicer when dealing with pointers and other memory space issues.
For rendering, you can try this method: Screen Space Fluid Rendering
Good luck!
PS: If you don’t want to use PhysX, you can look at SPH (smoothed-particle hyrdrodynamics) algorithms and implement one in Java. It’s a little involved though, so if you can, I would try to find a library first.
PPS: Regarding the GPU; If you want to write your own algorithm you should first write your algorithm on the CPU. So just use regular old Java until it is working how you expect. Then transfer it over to the GPU piece by piece. This is recommended because the GPU development environment is not very easy to work with. To write code on the GPU you can look into DirectCompute or (since this is an OpenGL based engine) OpenCL
Wow thx, i will probably write my own then. Thank you for the hint.