Page 1 of 2

experiment with water

Posted: Sun Jun 01, 2014 4:46 pm
by applePi
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)
Image
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

Re: experiment with water

Posted: Sun Jun 01, 2014 6:04 pm
by applePi
simulate dropping a sphere with physics, when it reaches height < 0, disable its physics then let it move like that for other spheres.
many plans and cheats are possible
i know you want circular waves !!. i don't know if it is possible with Hydra at a specific position

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, 300 , 640, #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)
      CreateSphere(13, 20)
      CreateEntity(13, MeshID(13), MaterialID(1),0,200,0)
      EntityPhysicBody(13, #PB_Entity_SphereBody, 1, 1, 1)
      WorldGravity(-100)



      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)
        
        If DisBallPhys = 0
          
          If EntityY(13) < 10
            DisableEntityBody(13, #True) ;ball lost physics
            MoveEntity(13, 0, WaterHeight(0, 0, 0), -20, #PB_Absolute) ; to sink a little
            DisBallPhys = 1 ; flag for ball lost physics
          EndIf
        EndIf  
        
        If DisBallPhys = 1 
          MoveEntity(13, 0, WaterHeight(0, 0, 0)+10, 0, #PB_Absolute) ; the sphere up /down with water heights
        EndIf  
          
        
        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

Re: experiment with water

Posted: Sun Jun 01, 2014 11:00 pm
by Samuel
Nice examples, applePi.

Using the new WaterHeight() command. A person could also create a splash effect when the ball hits the water.

Re: experiment with water

Posted: Mon Jun 02, 2014 11:13 am
by applePi
Samuel, where is the possibility to do a splash ?, i have looked at the Hydrax site i don't see splash effect http://www.paradise-sandbox.com/#hydraxskyx.php
but one of the pictures here http://www.ogre3d.org/tikiwiki/Hydrax have a splash effect near the moving ship, also i see a great splash demo here http://www.youtube.com/watch?v=wyAsQRg7yus

Re: experiment with water

Posted: Mon Jun 02, 2014 2:11 pm
by Bananenfreak
I think he used particles for this.
Heli splash is particle, but the ship... I don´t know.

EDIT: The white water thing is direct from Hydrax...
http://modclub.rigsofrods.com/xavi/05AP ... 9cfb33f9ab
This could be a way he added those foamthings behind the ship and under the heli.

OFFtopic:
https://www.youtube.com/watch?v=BQyXeSgle7c
Mr. Shift, are you here? Someone used shaders for a cool late(?) medieval Scene.

Re: experiment with water

Posted: Mon Jun 02, 2014 4:56 pm
by Bananenfreak
Here´s a test for splashs with particles... I didn´t found a good splashtexture with Alpha, so use your own ^^

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
Define.i splashMat, splashTex
Define.b toggle
NewList emitter.i()


Procedure.i MakeEmitter(x.d, z.d, mat.i)
  Protected.i emitter
  
  
  emitter = CreateParticleEmitter(#PB_Any, 0, WaterHeight(0, 0, 0), 0, #PB_Particle_Point)
  ParticleMaterial(emitter, MaterialID(mat))
  ParticleVelocity(emitter, 500, 1000)
  ParticleTimeToLive(emitter, 0.05, 0.1)
  ParticleSize(emitter, 20, 20)
  ParticleEmissionRate(emitter, 500)
  ParticleEmitterDirection(emitter, x, 0, z)
  ProcedureReturn emitter
EndProcedure


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, 300 , 640, #PB_Absolute)
      
      CameraLookAt(0, 4 * 10, 0, 40)
      
      ;-Water
      CreateWater(0, 0, -15, 0, 0, #PB_World_WaterHighQuality | #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)
      CreateSphere(13, 20)
      CreateEntity(13, MeshID(13), MaterialID(1),0,200,0)
      EntityPhysicBody(13, #PB_Entity_SphereBody, 1, 1, 1)
      WorldGravity(-100)
      
      
      splashTex = LoadTexture(#PB_Any, "smoke.png")        ;Foam.png  Fresnel.bmp
      splashMat = CreateMaterial(#PB_Any, TextureID(splashTex))
      
      
      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)
        
        If DisBallPhys = 0
          
          If EntityY(13) < 10
            DisableEntityBody(13, #True) ;ball lost physics
            
            AddElement(emitter())
            emitter() = MakeEmitter(1, 0, splashMat)
            AddElement(emitter())
            emitter() = MakeEmitter(0, 1, splashMat)
            AddElement(emitter())
            emitter() = MakeEmitter(-1, 0, splashMat)
            AddElement(emitter())
            emitter() = MakeEmitter(0, -1, splashMat)
            time = ElapsedMilliseconds()
            
            MoveEntity(13, 0, WaterHeight(0, 0, 0), -20, #PB_Absolute) ; to sink a little
            DisBallPhys = 1 ; flag for ball lost physics
          EndIf
        EndIf  
        
        If DisBallPhys = 1 
          MoveEntity(13, 0, WaterHeight(0, 0, 0)+10, 0, #PB_Absolute) ; the sphere up /down with water heights
        EndIf  
        
        If DisBallPhys = 1 And time + 200 <= ElapsedMilliseconds() And toggle = #False
          ForEach emitter()
            FreeParticleEmitter(emitter())
          Next emitter()
          toggle = #True
        EndIf
        
        
        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

Re: experiment with water

Posted: Mon Jun 02, 2014 6:05 pm
by Samuel
Bananenfreak wrote: I think he used particles for this.
Heli splash is particle, but the ship... I don´t know.
He may have used particles for the foam too. Purebasic doesn't have all the particle features yet, but particle scripts take care of that problem.
http://www.ogre3d.org/docs/manual/manual_34.html
Bananenfreak wrote: OFFtopic:
https://www.youtube.com/watch?v=BQyXeSgle7c
Mr. Shift, are you here? Someone used shaders for a cool late(?) medieval Scene.
Those are all sample compositors that come with Ogre. Comtois posted an example showing all of them except bloom.
http://www.purebasic.fr/english/viewtop ... 36&t=53917
If your interested in bloom I can post it in a separate topic.

Re: experiment with water

Posted: Mon Jun 02, 2014 8:17 pm
by Bananenfreak
?? How is this white thing done with a particleemitter? Hmm, i think only way is to use a small angle and direction against velocityvector. This for each "engine". Whats the english word for those rotating things behind the engine? Ahh, we need a function for ParticleEmitterAngle()!

Second thing:
Interesting thing is, someone programmed this with PB...

Re: experiment with water

Posted: Tue Jun 03, 2014 9:55 am
by DK_PETER
@ApplePi
Nice examples.

Samuel is right. Particles is the way to go.

Here's a simple example, which mimics the foam emanating from the bow of a ship.
Note: it's far from perfect and requires more particles...But it's a start.

Create two folder: scripts and textures

Particle scripts:

file: pbwater.particle

Code: Select all

particle_system pbwater
{
	quota	10000
	material	PE/lensflare
	particle_width	0.5
	particle_height	0.5
	cull_each	False
	renderer	billboard
	billboard_type	oriented_self

	emitter HollowEllipsoid
	{
		angle	5.68
		colour	1 1 1 1
		colour_range_start	1 1 1 1
		colour_range_end	1 1 1 1
		direction	1 0 0
		emission_rate	2000
		position	0 0 -800
		velocity	5
		velocity_min	5
		velocity_max	20
		time_to_live	1
		time_to_live_min	1
		time_to_live_max	1.8
		duration	0
		duration_min	0
		duration_max	0
		repeat_delay	0.2
		repeat_delay_min	0.2
		repeat_delay_max	0.2
		width	14.75
		height	36
		depth	600
		inner_width	0.8115
		inner_height	0.8017
		inner_depth	0.9828
	}

	affector LinearForce
	{
		force_vector	48 -18 0
		force_application	add
	}

	affector Scaler
	{
		rate	2.787
	}

	affector Rotator
	{
		rotation_speed_range_start	0
		rotation_speed_range_end	0
		rotation_range_start	0
		rotation_range_end	360
	}
}

Particle script: pbwater2.particle

Code: Select all

particle_system pbwater2
{
	quota	10000
	material	PE/lensflare
	particle_width	0.5
	particle_height	0.5
	cull_each	False
	renderer	billboard
	billboard_type	oriented_self

	emitter HollowEllipsoid
	{
		angle	5.68
		colour	1 1 1 1
		colour_range_start	1 1 1 1
		colour_range_end	1 1 1 1
		direction	1 0 0
		emission_rate	2000
		position	0 0 -800
		velocity	5
		velocity_min	5
		velocity_max	20
		time_to_live	1
		time_to_live_min	1
		time_to_live_max	1.8
		duration	0
		duration_min	0
		duration_max	0
		repeat_delay	0.2
		repeat_delay_min	0.2
		repeat_delay_max	0.2
		width	14.75
		height	36
		depth	600
		inner_width	0.8115
		inner_height	0.8017
		inner_depth	0.9828
	}

	affector LinearForce
	{
		force_vector	0 18 -48
		force_application add
	}

	affector Scaler
	{
		rate	2.787
	}

	affector Rotator
	{
		rotation_speed_range_start	0
		rotation_speed_range_end	0
		rotation_range_start	0
		rotation_range_end	360
	}
}

particle script: pbSplash.particle ; The engine foam emanating from the stern of the ship

Code: Select all

particle_system pbSplash
{
	quota	10000
	material	PE/lensflare
	particle_width	5
	particle_height	5
	cull_each	false
	renderer	billboard
	billboard_type	oriented_self

	emitter Box
	{
		angle	1.0
		colour	1 1 1 1
		colour_range_start	1 1 1 1
		colour_range_end	1 1 1 1
		direction	1 0 0
		emission_rate	600
		position	320 0 -800
		velocity	20
		velocity_min	20
		velocity_max	90
		time_to_live	1
		time_to_live_min	0.1
		time_to_live_max	0.4
		duration	0
		duration_min	0
		duration_max	0
		repeat_delay	0.8
		repeat_delay_min	0.8
		repeat_delay_max	0.8
		width	5
		height	18
		depth	18
	}

	affector LinearForce
	{
		force_vector	55 -28 2
		force_application	add
	}

	affector DirectionRandomiser
	{
		randomness 5
		scope 0.3
		keep_velocity true
	}



}
Materials script: PE_Materials.material

Code: Select all

material PE/lensflare
{
	technique
	{
		pass
		{
			lighting off
			depth_write off
			scene_blend add
			texture_unit
			{
			  texture flare.png
			}
		}
	}
}

Code example:

Code: Select all

EnableExplicit ;just for you Bananenfreak ;-)

InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()

UsePNGImageDecoder()

Add3DArchive("textures",#PB_3DArchive_FileSystem)
Add3DArchive("scripts", #PB_3DArchive_FileSystem)

DeclareModule WaterWorld
  
  Declare.i SetResolution(Width.i, Height.i, FullScreen.i = #False)
  Declare.i RunWaterWorld()
  
EndDeclareModule

Module WaterWorld
  
  Structure mainVars
    Win.i
    Scr.i
    FS.i
    Cam.i
    Quit.i
    lgt.i
    lgt2.i
  EndStructure
  
  Structure EntityVars
    id.i
    mes.i
    mat.i
    tex.i
  EndStructure
  
  Global va.mainVars
  
  Declare.i MakePart()

  Global foam1.EntityVars
  Global foam2.EntityVars
  Global foam3.EntityVars
 
  

  Procedure.i MakePart()
    foam1\id = GetScriptParticleEmitter(#PB_Any, "pbwater")
    foam2\id = GetScriptParticleEmitter(#PB_Any, "pbwater2")
    foam3\id = GetScriptParticleEmitter(#PB_Any, "pbSplash")
  EndProcedure

  
  Procedure.i SetResolution(Width.i, Height.i, FullScreen.i = #False)
    va\FS = FullScreen
    Select FullScreen
      Case #False ;Windowed
        va\Win = OpenWindow(#PB_Any, 0, 0, Width, Height, "WaterWorld", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
        va\Scr = OpenWindowedScreen(WindowID(va\Win), 0, 0, Width, Height, #False, 0, 0, #PB_Screen_SmartSynchronization)
      Default
        va\Scr = OpenScreen(Width, Height, 32, "Waterworld", #PB_Screen_SmartSynchronization, 60)
    EndSelect
    va\Cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
    MoveCamera(va\Cam, 0, 150, 0)
    va\lgt = CreateLight(#PB_Any, $EEEEEE, 0, 1000, -3000, #PB_Light_Directional)
    LightDirection(va\lgt, 1, -1, 0)
    
    LightLookAt(va\lgt, 0, 0, 0)
    va\lgt2 = CreateLight(#PB_Any, $FFFFFF, 0, 1000, 300, #PB_Light_Directional)
    LightDirection(va\lgt2, 0, 0, -1)
    CreateWater(va\Cam, 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))
    
  EndProcedure
  
  
  Procedure.i RunWaterWorld()
    Protected Quit.i = 0
    Protected mypath.s = GetPathPart(ProgramFilename()) + "textures\"
    Parse3DScripts()
    ret = MakePart()

    
    Repeat
      
      If va\FS = #False
        Repeat
          ev = WindowEvent()
          If ev = #PB_Event_CloseWindow
            Quit = 1
          EndIf
        Until ev = 0
      EndIf
      ExamineKeyboard()
      RenderWorld()
      
      FlipBuffers()
      
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
    
  EndProcedure
  
  
EndModule



WaterWorld::SetResolution(1024, 768, #False)
WaterWorld::RunWaterWorld()


Re: experiment with water

Posted: Tue Jun 03, 2014 1:56 pm
by applePi
thats good DK_PETER , it gives ideas to start with. i like your art scene with a nightly full moon casting its light over the dark blue sea, i am sure you enjoy these scenes.
i have tried Bananenfreak attempt for the splash, it needs may be timing and suitable texture. while browsing the web i have found a funny title "Bounce Tumble,and Splash! Simulating the Physical World with Blender 3D", but it is for blender and i don't like blender nor python language. it has some videos and a big 523 MB file download from oreilly
a related subject :the clothes, in this video, the clothes have a physics properties, it is done with Ogre3d and ballet engine. it is literally amazing:
http://www.youtube.com/watch?v=D5YlCCubQ4A&t=1m17s

Re: experiment with water

Posted: Tue Jun 03, 2014 4:34 pm
by Bananenfreak
@applePi:
I think many things in games, Demos,... is in any case timed (scripted). I want to include Sounds for a falling tree, for physic contacs,... and for all you have to make scriptevents. Example: Treeleaves of my trees don´t have a physicsbody. So how PC know when it´s time for a "Wuuuuuuuuuush" (leafsound)? If tree will fall down (Is cut), Sound is played with cracks, wuushes and Crash at the end. Sadly no dynamic Sound.

Look, what I´ve found: https://www.youtube.com/watch?v=vi7BbNaO-98 This could be another way to get cool watereffects ^^

Re: experiment with water

Posted: Tue Jun 03, 2014 6:12 pm
by AndyLy
DK_PETER, Samuel correctly written, how it's done.
About Unreal demo there (https://www.youtube.com/watch?v=vi7BbNaO-98).
They have some clever calculation system. I saw a demo where particles (sparks) pass only through the holes in the sheet metal and not through the sheet itself.

Re: experiment with water

Posted: Tue Jun 03, 2014 7:32 pm
by DK_PETER
AndyLy wrote:DK_PETER, Samuel correctly written, how it's done.
Ehhh...yes..As I stated above..I agree with Samuel. Particles IS the way to go...

@ApplePi.
Nice vid indeed, thank you.
And yes, I do enjoy creating scenes.. :wink:

Re: experiment with water

Posted: Thu Jun 05, 2014 6:38 pm
by DK_PETER
Edit...Redundant post..

Re: experiment with water

Posted: Thu Jun 05, 2014 7:27 pm
by Bananenfreak
Very interesting, DK_Peter, thank you for sharing :)

Hmm, I think if watersplash gets an angle of 360° and some bouncing in Y-axis, watersplash could become very cool!