' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  024   as  split test
'   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(1024,768)
If app=NULL Then
  End
End If


 
'----------------------------------- 
' add in memory management system a zip file 
 _AddZipFileArchive( "media/map-20kdm2.pk3" )


'-----------------------------------
' Load Quake3 scene Object
  Dim obj as Mesh = _LoadMesh("20kdm2.bsp")


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



'-----------------------------------
' Create And position  cameras
  ' camera 1
  Dim cam1 as CameraNode = _CreateCamera( )
  _PositionNode(cam1, 1850, 800, 1850)
  _RotateNode(cam1, 30,200, 0)
  
  Dim cam2 as CameraNode = _CreateCamera( )
  _PositionNode(cam2, 1300, 1800, 1300)
  _TargetCamera(cam2, 1300,1000, 1300)
  ' camera 3
  Dim cam3 as CameraNode = _CreateCamera( )
  _PositionNode(cam3, 100, 500, 150)
  _TargetCamera(cam3, 180,500,170)
  ' camera 4
  Dim cam4 as CameraNode = _CreateCameraFPS( )
  _PositionNode(cam4, 726, 724, 330)
  _TargetCamera(cam4, 826, 724, 830)



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


Dim ResX as Integer=1024
dim ResY As Integer=768

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

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

_TurnNode(cam1, 0, 0.25, 0)

 	' ---------------
 	'      Render
 	' ---------------
	_SetViewPort( 0,0,ResX,ResY)
   _BeginScene(0,0,0)
  
    _ActiveCamera(cam1)
    _SetViewPort( 0,0,ResX/2,ResY/2)	
    _DrawScene()

    _ActiveCamera(cam2)
		_SetViewPort( ResX/2,0,ResX,ResY/2)
    _DrawScene()

    _ActiveCamera(cam3)
		_SetViewPort( 0,ResY/2,ResX/2,ResY)
    _DrawScene()

    _ActiveCamera(cam4)
		_SetViewPort( ResX/2,ResY/2,ResX,ResY)
    _DrawScene()
    
    _DrawText(font, "move camera4 with mouse(click left) and dir key",  10,10,0,0)
  _EndScene()


Wend 
' end
_FreeEngine()
