' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 049   as   texture wrap samples
'   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

_ChangeWorkingDirectory("media")


  dim obj as Mesh = _LoadMesh("cube3.x")
 
'------------------------------------------
' Create a mesh cube
dim cube as EntityNode = _CreateEntityNode(obj)
_PositionNode(cube, 0,0,0) 
_RotateNode(cube, 0,0,50)
dim material as NMaterial = _NodeMaterial(cube)



'------------------------------------------
' Create a camera
dim cam as CameraNode = _CreateCamera( )
_PositionNode(cam, 0,0,-100)


'------------------------------------------
' simple text inside the scene area 
_LoadFont("courriernew.png")
dim font as IGUIFont = _GetFont()


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

' If Escape Key, Exit	
  If _GetKeyDown(KEY_ESCAPE) then
    Quit=1
  EndIf
  
  _TurnNode(cube, 1,1,0)
  
 
 If _GetKeyUp(KEY_F1) then
    _TextureWrapMaterial(material, 0, 0) 
 EndIf
 If _GetKeyUp(KEY_F2) then
    _TextureWrapMaterial(material, 1, 1) 
 EndIf
 If _GetKeyUp(KEY_F3) then
    _TextureWrapMaterial(material, 2, 2) 
 EndIf
 If _GetKeyUp(KEY_F4) then
    _TextureWrapMaterial(material, 3, 3) 
 EndIf
 If _GetKeyUp(KEY_F5) then
    _TextureWrapMaterial(material, 4, 4) 
 EndIf
 


  	' ---------------
  	'      Render
  	' ---------------
  _BeginScene(50,50,50)
     _DrawScene()
     _DrawText(font, "press F1-F2-F3-F4-F5 to change texture wrap",  10,10,0,0)
  _EndScene()


Wend 
' end
_FreeEngine()

