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

' Dimes
Dim app As any Ptr
Dim Quit As Integer


'----------------------------------------------------------
' open n3xt-D screen
app = _CreateGraphics3D(800,600)
If app=NULL Then
  End
End If
 
'----------------------------------------
 ' Load 3D objects 
Dim obj As Mesh = _LoadMesh("media/room.3ds")
  
  
  
'----------------------------------------
' Create traditional light And set position
 Dim light as LightNode = _CreateLight(&hffaaaaaa, 250)
  _PositionNode(light, 0,100,0)
'----------------------------------------


'----------------------------------------
' Create ROOM
Dim room as EntityNode =  _CreateEntityNode(obj)
' Load two textures
Dim colormap as NTexture = _LoadTexture( "media/wall0.jpg") 
' change planar texture mapping on the mesh
_MakePlanarTextureMappingMesh(obj, 0.004)

' set texture in the New room (room2)
_MaterialTextureNode(room, colormap , 0)

' set material For room parallax mapping 
Dim material as NMaterial = _NodeMaterial(room, 0)
_SpecularColorMaterial(material, 0)
'----------------------------------------



'----------------------------------------
' Create one hillmesh
Dim hillMesh as Mesh = _CreateHillPlaneMesh(20,20, 40,40, Null, 0,	0, 0,10,10)'

' Create WaterNode
Dim water as EntityNode = _CreateWater(hillMesh,  3.0, 300.0, 30.0)
_PositionNode(water, 0,7,0)
' 
_LoadTextureNode(water, "media/glass.bmp", 0, 0)
'_LoadTextureNode(water, "media/water1.jpg", 0, 0)
_LoadTextureNode(water, "media/water.jpg", 0, 1)
' 
'_MaterialTypeNode(water, EMT_REFLECTION_2_LAYER)
_MaterialTypeNode(water, EMT_TRANSPARENT_REFLECTION_2_LAYER)

'
'_ScaleTCoordsMesh(hillMesh, 4.0, 4.0, 2)
'_MakePlanarTextureMappingMesh(hillMesh, 0.02)
'----------------------------------------



'----------------------------------------
' Create a camera
Dim cam as CameraNode = _CreateCameraFPS( )
_PositionNode(cam, -95,155,-263)
_TurnNode(cam, 17,15,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()
     _DrawText(font, "water demo",  10,10,0,0)
  _EndScene()


Wend 
' end
_FreeEngine()

