'' ----------------------------------------------------------------------------
'' Irrlicht Wrapper For Imperative Languages - Freebasic Examples
'' Frank Dodd (2006)
'' ----------------------------------------------------------------------------
'' Blitz-Irrlicht 1.8.3 Interface by Ed Musolino (AquaLung 2015)
'' ----------------------------------------------------------------------------
'' Example 105: Billboard Propertuies
'' This example demonstrates the modification of Billboard properties To a
'' billboard that has been created in a scene
'' ----------------------------------------------------------------------------

'' ////////////////////////////////////////////////////////////////////////////
'' Includes For extension libraries
Framework usr.birrlicht

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

' irrlicht objects
Global Billboard:Int
Global BillboardTexture:Int
Global Camera:Int
Global BillboardWidth:Float = 200

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

' send the window caption
iAppTitle( "Example 105: Billboard Properties" )

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

' 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
Billboard = iCreateBillBoard( 200.0,102, 0.0,0.0,100.0 )

' now we apply the loaded texture To the billboard using node material index 0
iNodeTexture( Billboard, BillboardTexture, 0 )

' rather than have the billboard lit by light sources in the scene we can
' switch off lighting effects on the model And have it render as If it were
' Self illuminating
iNodeMaterialFlag( Billboard, IRR_EMF_LIGHTING, False )

' 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 )
iPositionNode(  Camera, -60, 0, 0 )

' hide the mouse pointer
iHideMouse()

' erase the canvas with sky-blue before rendering
iCameraCLSColor( 140, 255, 255 )

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

        ' begin the scene
        iBeginScene()
    
        ' draw the scene
        iDrawScene
        
        ' Change billboard properties
        ' the first parameter is the billboard node
        ' the second parameter is the RGBA color of the top of the billboard
        ' the third parameter is the RGBA color of the bottom of the billboard
        iBillBoardColor( Billboard, iMakeARGB( 255, BillboardWidth, BillboardWidth, 255 ), iMakeARGB( 255, BillboardWidth, BillboardWidth, 255 ))

        ' change the size of the billboard
        iBillBoardSize( Billboard, BillboardWidth, 100.0 )

        ' Animate the width property
        If BillboardWidth > 1.0 Then BillboardWidth = BillboardWidth - 0.02

        ' End drawing the scene And render it
        iEndScene()

Wend 

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


End