Include "WaterEngine.bb"
Graphics3D 1024, 768, 32, 2
SetBuffer BackBuffer()
;Camera
Global Cam = CreateCamera()
PositionEntity Cam, 0, 3, 0
PointEntity Cam, CreatePivot()
CameraRange Cam, 1, 10000
;Water
InitWater()
wat = CreateWater("Skybox.jpg", 100, 100)
;Skybox
Sky = CreateSprite(Cam)
MoveEntity Sky, 0, 0, 800
ScaleSprite Sky, 800, 600
EntityOrder Sky, 999999
EntityTexture Sky, LoadTexture("Skybox.jpg", 385)
MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2
FlushMouse()
timer = CreateTimer(60)
While Not KeyDown(1)
UpdateWater()
DX7_EnableRenderBumpTexture()
RenderWorld
DX7_DisableRenderBumpTexture()
UpdateProgram(.1)
WaitTimer timer
Flip
Wend
FreeWater()
End
Function UpdateProgram(freelook_speed# = 1)
If freelook_speed# > 0 Then
MoveEntity Cam, (KeyDown(32) - KeyDown(30)) * freelook_speed#, 0, (KeyDown(17) - KeyDown(31)) * freelook_speed#
RotateEntity Cam, EntityPitch(Cam) + MouseYSpeed(), EntityYaw(Cam) - MouseXSpeed(), 0
MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2
EndIf
End Function
the water include: =>
Type Water
Field ent
End Type
Const WaterWaveHeight# = .1
Global WaterBumpTex, WaterBumpFrame#
Dim Water(100, 100)
Function InitWater()
If DX7_SetSystemProperties(SystemProperty$("Direct3D7"), SystemProperty$("Direct3DDevice7"), SystemProperty$("DirectDraw7"), SystemProperty$("AppHWND"), SystemProperty$("AppHINSTANCE")) Then RuntimeError "Error initializing dx7."
If DX7_SupportsBumpMapping() = False Or DX7_SupportsLumiBumpMapping() = False Then RuntimeError("Graphic card does not support bump mapping.")
DX7_SetBumpInfo WaterWaveHeight#, 0, 0, WaterWaveHeight#, 1, 0, 0
WaterBumpTex = LoadAnimTexture("WaterBump.png", 257, 256, 256, 0, 23)
ScaleTexture WaterBumpTex, 3, 3
End Function
Function FreeWater()
For w.Water = Each Water
If w\ent Then FreeEntity w\ent
Delete w
Next
FreeTexture WaterBumpTex
End Function
Function CreateWater(cubetex$, sx = 10, sz = 10, detail = 1)
w.Water = New Water
w\ent = CreateMesh()
surf = CreateSurface(w\ent)
sx = sx / detail
sz = sz / detail
For x = 0 To sx
For z = 0 To sz
Water(x, z) = AddVertex(surf, x * 2 * detail, 0, z * 2 * detail, x * detail, z * detail)
Next
Next
For x = 0 To sx - 1
For z = 0 To sz - 1
AddTriangle surf, Water(x, z), Water(x, z + 1), Water(x + 1, z)
AddTriangle surf, Water(x + 1, z + 1), Water(x + 1, z), Water(x, z + 1)
Next
Next
PositionMesh w\ent, -sx * detail, 0, -sz * detail
UpdateNormals w\ent
EntityFX w\ent, 17
EntityTexture w\ent, CreateTexture(1, 1)
cubemap = LoadTexture(cubetex$, 385)
TextureBlend cubemap, 3
EntityTexture w\ent, cubemap, 0, 2
Return w\ent
End Function
Function UpdateWater()
WaterBumpFrame# = (WaterBumpFrame# + 1) Mod 22
For w.Water = Each Water
EntityTexture w\ent, WaterBumpTex, WaterBumpFrame#, 1
Next
End Functioni have got problems with my uploading, so you have to replace these images with any others... or zmatrix could maybee upload the water animated bump textures??