' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  007   as   just create a single mesh
'   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
 
 

 
 

'---------------------------
' define a ManualContruct Mesh
  Dim mesh as Mesh

' Create the mesh
  mesh=_CreateEmptyMesh()


' add one buffer For vertices And faces
' define 3 vertices 
  dim v1 as Integer= _AddVertexMesh(mesh, 0, 0,0,0, 0,0,0,  &hff00)
  Dim v2 as Integer= _AddVertexMesh(mesh, 0, 2,2,0, 0,0,0,  &hff00)
  Dim v3 as Integer= _AddVertexMesh(mesh, 0, 2,0,0, 0,0,0,  &hff00)
  
  ' add one face
  _AddFaceMesh(mesh, 0,  v1,v2,v3)

' add second buffer For vertices And faces
  _AddEmptyMeshBuffer(mesh)
' define 3 vertices 
  v1= _AddVertexMesh(mesh, 1, 0,2,0, 0,0,0,  &hff00)
  v2= _AddVertexMesh(mesh, 1, 2,2,0, 0,0,0,  &hff00)
  v3= _AddVertexMesh(mesh, 1, 0,0,0, 0,0,0,  &hff00)
  ' add one face

 _AddFaceMesh(mesh, 1, v1,v2,v3)

  
  

' Create a mesh with one of the 3D Object loaded
  Dim element as EntityNode = _CreateEntityNode(mesh)



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



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

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


' just turn our sphere
 _TurnNode(element, 0,0.5,0)



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

Wend 
' end
_FreeEngine()
