' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  010   as   first texturing

'   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

 
'Create mesh
 Dim cubemesh as Mesh = _CreateCubeMesh()
 Dim spheremesh as Mesh = _CreateSphereMesh()
 Dim cylindermesh as Mesh= _CreateCylinderMesh(1.0, 3.0)
 
 
' Create all entity with mesh 
 Dim cube as EntityNode = _CreateEntityNode(cubemesh)
 _PositionNode(cube, -6,0,0) 
' first Method To texturing
 Dim material as NMaterial = _NodeMaterial(cube)
' Load texture
 Dim tex as NTexture = _LoadTexture( "media/wall.jpg") 
' set texture in material 
  _TextureMaterial(material,  0, tex) 



' Create a sphere And set position
 Dim sphere as EntityNode = _CreateEntityNode(spheremesh)
_PositionNode(sphere, -2,0,0) 
' second Method
_LoadTextureNode(sphere, "media/body.bmp") 


' Create a cylinder And set position
 Dim cylinder as EntityNode = _CreateEntityNode(cylindermesh)
_PositionNode(cylinder, 2,0,0) 
' Load texture
_LoadTextureNode(cylinder, "media/five.bmp") 




' Create a camera
dim cam As CameraNode = _CreateCamera( )
_PositionNode(cam, 0,0,-10)


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

' If Escape Key, Exit	
  If _GetKeyDown(KEY_ESCAPE) then
    Quit=1
  EndIf
   
   
  	' ---------------
 	'      Render
  	' ---------------
  _BeginScene(12,12,12)
     _DrawScene()
  _EndScene()


Wend 
' end
_FreeEngine()
