' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  033   as   sprite3D code.
'   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 obj1 as Mesh = _LoadMesh("media/plane.3ds")



'-----------------------------------------
' Create plane
Dim plane as EntityNode =  _CreateEntityNode(obj1)
_ScaleNode(plane, 2,2,2)
'----------------------------------------



'-----------------------------------------
' Create billboard
Dim spMesh as Mesh = _CreateSpriteMesh( 8.0, &h22ffffff)
Dim i as Integer
For i =0 To 64
  Dim spG As SpriteSceneNode = _CreateSprite3D(spMesh, "media/grass.bmp")
  _PositionNode(spG, -40+Rnd()*80,11, -40+Rnd()*80)
  _MaterialTypeNode(spG, EMT_TRANSPARENT_ALPHA_CHANNEL)
  _OrientationSprite3D(spG,1)
Next


'-----------------------------------------
' Create first  camera
Dim cam as CameraNode = _CreateCameraFPS( )
_PositionNode(cam, 0,25,-60)



'-----------------------------------
' Load font png
_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(100,100,100)
    _DrawScene()
    _DrawText(font, "Sprite3D demo",  10,10,0,0, &hff00ffff)
     _DrawText(font, "Primitives as  "+ str( _PrimitiveCountDrawn() ) ,  10,45,0,0, &hffffffff)
  _EndScene()

Wend 
' end
_FreeEngine()

