Smooth Water
Blitz3D Forums/Blitz3D Programming/Smooth Water
| ||
Hello, I'm trying to make a plane of water move up, then back down, to simulate the waves. I'm not sure if this is how you would normally do it, but I decided it would be the easiest way, and it would still look OK. Here's the water updating code:Function MEDIA_UpdateWater() If EntityY(water) <= 5 w_move# = 0.002 ElseIf EntityY(water) >= 5.15 w_move# = -0.002 EndIf TranslateEntity water, 0, w_move#, 0 End Function[/code] w_move# is initially set to 0. When the program is run, the water plane goes up and down, but it looks so uniform, and not very smooth and water-like. What should I do to fix this? Thanks, No Enemies |
| ||
Check out CyberGoth's water-demo in the code archs: http://www.blitzbasic.com/codearcs/codearcs.php?code=364 |
| ||
Thanks...I'll be using this. |
| ||
To make the water smoothly flow up and down, you should use a sinewave. The "sin" and "cos" functions are not only useful for triginometry, they have a very nice wave graph. You should probably do something like this:Global wavecount ;... While KeyHit(1)=0 ;... wavecount = wavecount + 5 ;change the 5 to whatever speed you want the water to wave PositionEntity water, 0, Sin(wavecount) * .5, 0 ;Change the .5 to the height of the waves ;... UpdateWorld RenderWorld ;... Wend |
| ||
Thanks...I'm going to have to mess around with it a bit, but I think I can make it work. |