'' ----------------------------------------------------------------------------
'' Irrlicht Wrapper For Imperative Languages - Freebasic Examples
'' Frank Dodd (2006)
'' ----------------------------------------------------------------------------
'' Blitz-Irrlicht 1.8.3 Interface by Ed Musolino (AquaLung 2015)
'' ----------------------------------------------------------------------------
'' Example 56: Zone Management Bounding Boxes
'' This example demonstrates the display of bounding boxes created by adding
'' child objects To parent zone managment objects
'' ----------------------------------------------------------------------------

'' ////////////////////////////////////////////////////////////////////////////
'' Includes For extension libraries
Framework usr.birrlicht
Import brl.retro

'' ////////////////////////////////////////////////////////////////////////////
'' Global variables

' irrlicht objects
Global Billboard:Int
Global BillboardTexture:Int
Global Camera:Int
Global zone:Int
Global x:Int
Global z:Int
Global n:Int


'' ////////////////////////////////////////////////////////////////////////////

' -----------------------------------------------------------------------------
' start the irrlicht interface
iIrr3D( 1024, 768, 32, False )

' send the window caption
iAppTitle( "Example 56: Zone Management Bounding Boxes" )

' Load the texture resource For the billboard
BillboardTexture = iLoadTexture( "./media/BlitzLogo_Big.jpg" )

' add the billboard To the scene, the first two parameters are the size of the
' billboard in this instance they match the pixel size of the bitmap To give
' the correct aspect ratio. the last three parameters are the position of the
' billboard Object
For x = -15 To 15
    For z = -15 To 15
        zone = iCreateZoneMgr(0,600)
        iZoneMgrBndBox( zone, 0, 0, 0,  100, 100, 100 )
        iZoneMgrProperties( zone, 0, 600, 1 )
        iPositionNode( zone, x*100, 0, z*100 )
        iDebugNode( zone, $FFFF )

        For n = 0 To 5
            Billboard = iCreateBillBoard( 5.0, 5.0, 0, 0, 0 )
            iNodeTexture( Billboard, BillboardTexture, 0 )
            iNodeMaterialFlag( Billboard, IRR_EMF_LIGHTING, False )
            iPositionNode( Billboard, Rnd(50), Rnd(50), Rnd(50) )
            iNodeParent( Billboard, zone )
        Next
    Next
Next

' add a first person perspective camera into the scene so we can move around
' the billboard And see how it reacts
Camera = iCreateFPSCamera(0,100.0,0.5,-1,0,0,0,0.0)

' hide the mouse pointer
iHideMouse()

' -----------------------------------------------------------------------------
' While the irrlicht environment is still running
While iRun() And (Not iKeyHit( KEY_ESCAPE ))

    ' begin the scene, erasing the canvas
    iBeginScene()

    ' draw the scene
    iDrawScene()

    ' End drawing the scene And render it
    iEndScene()
Wend

' -----------------------------------------------------------------------------
' Stop the irrlicht engine And Release resources
iEndIrr3D()


End