' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  029  : Water Avanced rendering.
'   Historique  :
'     29/03/09  19:16    TMyke
'
' ------------------------------------------------------------
' Includes libraries
#include "N3xtD.bi"

' Globales
Dim app As any Ptr
Dim Quit As Integer


'----------------------------------------------------------
' open n3xt-D screen
app = _CreateGraphics3D(800,600)
If app=NULL Then
  End
End If

 
 
'----------------------------------------
' Create traditional light And set position
  Dim light as LightNode = _CreateLight(&hffaaaaaa, 450)
  _PositionNode(light, 0,100,0)
'----------------------------------------



Dim obj as Mesh = _CreateCubeMesh(10.0)


  Dim cube1 as EntityNode = _CreateEntityNode(obj)
  _PositionNode(cube1, 0,12,50)
  _LoadTextureNode(cube1, "media/stone.bmp")

  Dim cube2 as EntityNode = _CreateEntityNode(obj)
  _PositionNode(cube2, 40,12,20)
  _LoadTextureNode(cube2, "media/wall0.jpg")
  
  
  
'------------------------------------------------------------------------------------
' Create Skybox
Dim sky as EntityNode = _CreateSkybox( _LoadTexture("media/up.jpg"),_LoadTexture("media/dn.jpg"),_LoadTexture("media/lf.jpg"),_LoadTexture("media/rt.jpg"),_LoadTexture("media/ft.jpg"),_LoadTexture("media/bk.jpg"))



'----------------------------------------
' Create a camera
Dim cam as CameraNode = _CreateCameraFPS()
_PositionNode(cam, 0,35,-63)



'----------------------------------------
' Create one water plan
_DataWaterAR("media/waterNormal.png", "media/waterDUDV0.png", 0.025)  

Dim water as EntityNode = _CreateWaterAR(32.0, 32, True, True)

_ColorWaterAR(water, &h8866b7ff) 
_SpeedWaterAR(water,  10000)
_ClipPlaneOffsetWaterAR(water, 2.0)


'----------------------------------------


' simple text inside the scene area 
_LoadFont("media/courriernew.png")
Dim font as IGUIFont = _GetFont()


' ---------------------------------------
'           Main loop
' ---------------------------------------
While Quit=0
 

' If Escape Key, Exit	
  If _GetKeyDown(KEY_ESCAPE) then
    Quit=1
  EndIf


  	' ---------------
  	'      Render
  	' ---------------
  _BeginScene()
     _DrawScene()
  _EndScene()


Wend 
' end
_FreeEngine()

