experiment with water
Posted: Sun Jun 01, 2014 4:46 pm
the new water are great, we can make islands, lakes, etc, by covering the infinite water, may be by a model you design, here we make small swimming pool from a cylinder with open top, we can change the sun position such as a lightning ball, what we see is its light reflection on water, the reflection can't be hide with wall so we design what is suitable to a specific case. don't forget if you put a ship over water use "WaterHeight" such as
MoveEntity(i, i * 40, WaterHeight(0, i * 40, 40), 40, #PB_Absolute)

this is the water example itself with some play lines:
use the mouse / keys to move around. look at the street behind the pool
MoveEntity(i, i * 40, WaterHeight(0, i * 40, 40), 40, #PB_Absolute)

this is the water example itself with some play lines:
use the mouse / keys to move around. look at the street behind the pool
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Water
;
; (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 10
#cyl = 15
;IncludeFile "Screen3DRequester.pb"
IncludeFile #PB_Compiler_Home + "Examples/3D/Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
For k = 0 To 0
If Screen3DRequester()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/desert.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Water",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem)
Parse3DScripts()
WorldShadows(#PB_Shadow_TextureAdditive)
SkyBox("desert07.jpg")
Fog(RGB(128,128,128), 10, 10, 10000)
GetScriptMaterial(0, "Color/Red")
CreateSphere(0, 10)
For i=0 To 9
CreateEntity(i, MeshID(0), MaterialID(0))
Next
CreateCamera(0,0,0,100,100)
MoveCamera(0, 60, 200 , 340, #PB_Absolute)
CameraLookAt(0, 4 * 10, 0, 40)
;-Water
CreateWater(0, 0, -15, 0, 0, #PB_World_WaterLowQuality | #PB_World_WaterCaustics | #PB_World_WaterSmooth | #PB_World_WaterFoam | #PB_World_WaterGodRays)
;Sun(10000, 10000, -100000, RGB(238, 173, 148))
Sun(0, 200, -350, RGB(238, 173, 148))
;-Light
CreateLight(0, RGB(255, 255, 255), 1560, 900, 500)
AmbientColor(RGB(50,50,50))
CreateMaterial(0, LoadTexture(0, "nskinrd.jpg"))
Entity = CreateEntity(#PB_Any, MeshID(CreateCube(#PB_Any, 2)), MaterialID(0), 0, 0, 0)
ScaleEntity(Entity, 10000, 0.05, 500)
MoveEntity(Entity, 0,0,900)
CreateMaterial(1, LoadTexture(1, "wood.jpg"))
;MaterialBlendingMode(1, #PB_Material_AlphaBlend)
MaterialCullingMode(1, #PB_Material_NoCulling)
CreateCylinder(#cyl, 400, 200 , 6, 0, 0)
CreateEntity(#cyl, MeshID(#cyl), MaterialID(1),0,0,0)
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
For i=0 To 9
MoveEntity(i, i * 40, WaterHeight(0, i * 40, 40), 40, #PB_Absolute)
Next
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Next
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End