Graphics3D 1024,768 cam = CreateCamera() light = CreateLight() MoveEntity cam,0,45,-15 TurnEntity cam,15,0,0 ;WireFrame enable Global WATER_GRID_SIZE = 32 Global WATER_HEIGHT# = 16 Dim WaterY(WATER_GRID_SIZE+1,WATER_GRID_SIZE+1) Global wz,wx Global hite# Global waterlevel# Global waterangle# Global water Global watert Global curdetail For q = 0 To WATER_GRID_SIZE For j = 0 To WATER_GRID_SIZE WaterY(q,j) = Rnd(0,360) Next Next ; Create some terrain and load the water texture onto it water = CreateTerrain(WATER_GRID_SIZE) ;watert = LoadTexture("wswirl.jpg") watert = CreateTexture(256,256) SetBuffer TextureBuffer(watert) Color 0,0,255 Rect 0,0,256,256 Color 255,255,255 For i = 1 To 75 circle = Rnd(2,25) Oval Rnd(0,225),Rnd(0,225),circle,circle,0 Next ;waterg = LoadTexture("wswirl.jpg") waterg = CreateTexture(256,256) SetBuffer TextureBuffer(waterg) Color 0,200,0 Rect 0,0,256,256 For i = 1 To 10000 Color 0,Rnd(5,135),0 Plot Rnd(0,255),Rnd(0,255) ;Oval Rnd(0,225),Rnd(0,225),circle,circle,0 Next SetBuffer BackBuffer() TextureBlend watert,3 ScaleTexture watert,.2,.2 ScaleTexture waterg,.5,.5 EntityTexture water,watert,0,1 EntityTexture water,waterg,0,0 EntityAlpha water,.9 ; Resize and position the water PositionEntity water,-1000,8,-1000 ;MoveEntity water,0,5,0 ScaleEntity water,WATER_GRID_SIZE*4,WATER_HEIGHT#,WATER_GRID_SIZE*4 ; Modify the detail of the terrain TerrainShading water,False curdetail = 500 TerrainDetail water,curdetail,False Repeat water_wave() RenderWorld Flip Until KeyHit(1) = 1 Function water_wave() ; Here we itterate through all the cells on the terrain grid (switch wireframe on to ; see them) and then make them simply bounce up and down. For wz = 0 To WATER_GRID_SIZE-1 For wx = 0 To WATER_GRID_SIZE-1 hite# = Sin(WaterY(wz,wx)) ModifyTerrain water,wx,wz,(hite#/4)+.5,False WaterY(wz,wx) = WaterY(wz,wx) + 2 If watery(wz,wx)>3439 Then watery(wz,wx) = 1 Next Next waterangle# = waterangle# +.2 If waterangle#>360 Then waterangle#=.2 RotateTexture watert,Sin(waterangle#) ;;RotateTexture cloudmask,waterangle# End Function