' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  021   as   Mesh particle demo.
'   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

'-----------------------------------------
' set ambient light
 _AmbientLight( &hffaaaaaa)


'----------------------------------------
' Load 3D objects 
  Dim obj as Mesh = _LoadMesh("media/sphere.x")


'-----------------------------------------
Dim sp as EntityNode =  _CreateEntityNode(obj)




'----------------------------------------
'----------------------------------------
' Create PARTICLE SYSTEM
Dim part as ParticleSystemNode = _CreateParticleSystem()
' Create a box particle emitter
  Dim mesh_emitter as ParticleEmitter = _CreateParticleMeshEmitter(part, obj, TRUE,0, 0.03, 0, 100,  -1, False, 50, 100, &h00ffffff, &h000000ff, 2000,4000,0,5.0,5.0,5.0 ) 
  
  
' change SizeOf each particle inside the particle emitter
  _MinStartSizeParticle(mesh_emitter,  10.0, 10.0  )
  _MaxStartSizeParticle(mesh_emitter,  10.0, 25.0  )
' add New emitter inside the particlesystem
  _AddEmitterParticleSystem(part, mesh_emitter ) 
' fadeout element
  _FadeOutParticleSystem( part )

' adjust some material settings
  _LoadTextureNode(part, "media/fireball.bmp")
   
  Dim mat As NMaterial = _NodeMaterial(part, 0)
  _TypeMaterial(mat,  EMT_TRANSPARENT_ADD_COLOR) 
  





'----------------------------------------
' Create a camera
Dim cam as CameraNode = _CreateCamera( )
_PositionNode(cam, 0,1,-120)


'-----------------------------------
' simple text inside the scene area 
_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
  
  _TurnNode(sp, 0,0.15,0)
  
 

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

Wend 
' end
_FreeEngine()
