I already searched the wiki and the forum for this, but its hard to find something when you don't know what its called…
To generate "water" glest uses a set of textures( tileable and animated) which are used as a texture on a plane and are played back like an animated gif. I know that jmonkey has very cool watereffects and I already played with them a bit, but I want to support the original glest style water too ( and I hope its faster too ).
How is a water/texture effect like glest does it called in 3d games and how should I implement it best in jme2?
Actually I don't know the name for that and don't know if there is a nice implementation for that. If I would want to implement that I would think of two different approaches (although I'm not so sure how to handle the animated gifs?).
Let's assume we find a solution for reading the animated file, we create on the fly a texture-tilemap with this. If we just want to map that to a quad it would be quite simple.
- create quad
- set texcoords on the first tile of the texture
- write a controller that waits a certain amount of time and jump to the next tile by chaning the texcoords to the next tile
e.g. you can set the texcoords for a quad like this with a 2x2 tilemap and selecting the lower left tile:
FloatBuffer newTexcords = BufferUtils.createFloatBuffer(0, 0.5f, 0, 0, 0.5f, 0, 0.5f,0.5f);
((FloatBuffer)quad.getTextureCoords().get(0).coords.position(0)).put(newTexcords);
Second approach(where I would prefer the first one): Read every frame and create a texture out of it. write a controller and switch between the different textures.
Hope it helped a bit or maybe brought you some new ideas...
So what you suggest is simply changing the texture of the quad frame based or time based?
Thats simple, I will try it this evening :).
No, he's suggesting one texture with different tiles (e.g. four quarters) with each representing one picture of the animation. Then by setting the texture coordintaes to just one tile you can go through the images.
Changing the texture was the second suggestion…
First was using one texture and change only the texturemapping. So if we have four frames all on one texture I ony change the texture-coordinates that shows what part of the texture is shown by the quad…
Actually I have the feeling one texture-version would be faster for the gpu, but actually I don't have a clue as I just started to have a deeper look into engine…