How to create water with IPOs in realtime?
My guess is to:
1- create a plane
2- subdivide it 2 to 4 times
3- triangulate it
4- animate each vertex by hand
5- play the animation
6- refine the animation
7- add UV and logic to it
This is the only solution that I have. This is what was used in half-life
so it sold work. The key to good water is the texture. Make sure you have a good texture.
I didn’t think you could animate each vertex for the real-time engine.
:-?
There was a guy working on animating ocean waves in the Work In Progress forum a while back, produced some quite stunning results in the render engine. His method wouldn’t work in the real-time engine though i dont think
actually, you CAN modify vertex locations at run time in the game engine. I used it at one time to make a waving flag in a game.
However, you should shy away from using sin() or cos() and just use a couple of lookup tables to increase its speed as much as you can. In fact, you could just set up thevertices beforehand and just try passing each vertex’s z coordinate to the next vertex. Of course you would need to know the actual order of vertices to do it this way.
It’s been a while, so I dont remember the details of getting access to the vertex data in the game engine, but I can guarantee that it is possible, since I’ve done it.
-nt20
sweet!!! great job!!
ps: i think the best for now is to use animated textures.
THe even best best way would be to use animated textures, vertex animation (through code) and texture scrolling through code. Then it has waves, is constantly scrolling, and is physically wavy all at the same time!
I made a lava pit with a scrolling uv texture, waves, as well as the whole plane was rotating constantly. Came out to look pretty realistic.
Python would be the best i guess, you can create a square patch with the vertices in a specific order quite easily. I made a little cloth sim thing that worked well so the technique could be modified for water i suppose.
However, I think the easiest option without python is to use an armature. 1) Create your water plane and subdivide till it looks OK
2) Create a armature of 3/4 bones (depending on the number of waves)
3) Use the circle select thingy (‘B’ key twice, whats it called?) to select random areas of the mesh.
4) create wavy shaped vertex groups and parent to the armature etc.
5) animate the bones moving up and down.
Ok, so its not accurate, but depending on the situation it can look effective, especially with a good texture.
Cheers
Piran
Wow! i didn’t know you could do that with python! That’s pretty nice NT
Wow! You are using the Realtime API along with the standard API! This is quite new… and I never thinked of it being possible!!! :o This opens a broad renge of possibilities… like… realtime terrain deformation (walls that break or get dents at near explosions) metaballs in realtime… very good and original work, NikolaTesla!!!
I have to tell you it was not my original idea - well, the flag was, but the code to do vertice access was in a NAN demo waaaay back, by Calli. I can’t take any credit for it
-nt20
I never knew you could do that! :o I knew you couldn’t access the Blender module (import Blender) so I assummed that anything like that wouldn’t work as well.
Hmmm… I guess I’d better get up to speed with the non-realtime API and see what other effects can be done…
Thanks niko!
Actually, isn’t this the realtime api? The realtime api does give you some mesh control, you just can’t create new meshes in realtime. From all the tests I have done, you can use the standard api in a realtime game, but if you change a mesh, or add a mesh, you have to restart the scene to have the effects take place.
The same method to do the flag is also the method gargola was recently using for his health bar, and its also the method that let us do animated textures through python when they weren’t supported!
It’s pretty awesome
Cluh/lizard (don’t remember which one, think it was liz) also managed to use this on the CAMERA mesh which made a very odd, drunk-like effect on the view.
Hello
Funny, that you’ve noticed the Gargola demo health bar trick, Saluk
I’m very bad with Python, and when i’ve tried to help him i’ve noticed
the “own.getMesh” and the “mesh.getvertex” methods?
Can you explain this a little better, please?
Bye
António
Hmm :-? I can understand everything, but I still have a one question.
When I’m creating water, then how do I set the height of the wave?
i remember that demo… i still have it, it was made by calli
If you look at the script then you will notice that the vertices are translated through a sin-function multiplicated with a certain value. This factor is the amplitude of the wave, or in other words the maximum height - since a sinusvalue oscillates between -1 and 1.
that scripts great for flags and cloaks etc but youd have to add multi-directional sine waves with random amplitudes/frequencies to make realistic water. Id be interrested in any results any1 produces tho.
Now REAL wave physics would royally rock! But man they’d be hard. You would have to have sin waves that bounce off of each other and mix with them and stuff, nifty. I’ll look over my old physics homework and see what I come up with, but I make NO promises:)
well u could do it that way if you want to make it perfectly accurately but i don’t think you need to make it that complecated. Since all you’re setting is the height of each vertex all you need to do is set it to the output of various sine wave functions added together. you would use say 5 different sine waves, some moving along the x axis, some along the y axis. give them varying frequencies and amplitudes, and increment their displacements along the x (or y) axis a certain distance every time the script runs. Use different increment values for the diffrent sine waves so there like energy ripples moving at different speeds, then for each vertex you would calculate its height like this:
height = sinewave1 + sinewave2 + sinewave3 + .....
if u choose the right values for frequencies etc you could end up with quite a good looking effect. And it wouldn’t repeat itself too often either.
Wouldn’t be tilable though so the whole thing would have to be 1 mesh :-?
Keith.