; -------------------------------------------------------
;  UnitTest for the IrrlichtWrapper
; -------------------------------------------------------
;
;  Testing the FileSystem-Functions of the IrrlichtWrapper (Irrlicht)

;#PB_Compiler_Home + 
XIncludeFile "T:\Dev\PB4\Includes\IrrlichtWrapper_Include.pbi"

;

; Test in normal + unicode mode only.
; Thread tests are not needed as the ObjectManager library takes care of all
; thread issues and there are no further global datastructures in this library.
;
PureUnitOptions()

; -------------------------------------------------------
;- Setup
; -------------------------------------------------------


;We should start with initialising Irrlicht

ProcedureUnitStartup startup()

  
  Assert( IrrStart( #IRR_EDT_DIRECT3D9, 640, 480, #IRR_WINDOWED, #IRR_NO_SHADOWS, #True) )

EndProcedureUnit


ProcedureUnitShutdown shutdown()


;   ; -----------------------------------------------------------------------------
;   ; while the irrlicht environment is still running
;   While IrrRunning()
;       ; begin the scene, erasing the canvas with sky-blue before rendering
;       IrrBeginScene( 240, 255, 255 )
;   
;       ; draw the scene
;       IrrDrawScene()
;   
;       ; end drawing the scene and render it
;       IrrEndScene()
;   Wend
  
  ; -----------------------------------------------------------------------------
  ; Stop the irrlicht engine and release resources
  
  Assert( IrrStop() )  

EndProcedureUnit

;Testing load of some Meshes/Formats
ProcedureUnit Test_IrrGetMesh()
  Assert( IrrGetMesh("..\media\blockland2.obj" ), "Loading OBJ-File")
  Assert( IrrGetMesh("..\media\candle.ms3d" ), "Loading MS3D-File")
  Assert( IrrGetMesh("..\media\cone.3DS" ), "Loading 3DS-File")
  Assert( IrrGetMesh("..\media\cube.x" ), "Loading X-File")
  Assert( IrrGetMesh("..\media\faerie.md2" ), "Loading MD2-File")
  Assert( IrrGetMesh("..\media\mikesbox.b3d" ), "Loading B3D-File")
  Assert( IrrGetMesh("..\media\mikebox.dmf" ), "Loading DMF-File")    
EndProcedureUnit


ProcedureUnit Test_IrrGetStaticFromMesh()
  *mesh = IrrGetMesh("..\media\candle.ms3d" )
  Assert( *mesh, "Loading MS3D-File")
  
  *static_mesh = IrrGetStaticFromMesh(*mesh,0)
  Assert( *static_mesh)
  
EndProcedureUnit

ProcedureUnit Test_IrrGetMeshIndexCount()
  *mesh = IrrGetMesh("..\media\candle.ms3d" )
  Assert( *mesh, "Loading MS3D-File")
    
  idx_count = IrrGetMeshIndexCount(*mesh,0)
  
  Assert ( idx_count = 432, "Wrong Count of indices")
     
EndProcedureUnit


ProcedureUnit Test_IrrAddMeshToScene()
  *mesh = IrrGetMesh("..\media\candle.ms3d" )
  Assert( *mesh, "Loading MS3D-File")       
  Assert ( IrrAddMeshToScene(*mesh) )
     
EndProcedureUnit

;Wee need a static format - in this case a dmf-file
ProcedureUnit Test_IrrAddMeshToSceneAsOcttree()
  *mesh = IrrGetMesh("..\media\mikebox.dmf" )
  Assert( *mesh, "Loading DMF-File")       
  Assert ( IrrAddMeshToSceneAsOcttree(*mesh) )
     
EndProcedureUnit


ProcedureUnit Test_IrrAddBillBoardToScene()
  Assert ( IrrAddBillBoardToScene(20,20, 100.0, 100.0, 100.0) )     
EndProcedureUnit

ProcedureUnit Test_IrrAddCubeSceneNode()
  Assert ( IrrAddCubeSceneNode(20) )     
EndProcedureUnit

ProcedureUnit Test_IrrAddDiamondSceneNode()
  Assert ( IrrAddDiamondSceneNode() )     
EndProcedureUnit

ProcedureUnit Test_IrrAddEmptySceneNode()
  Assert ( IrrAddEmptySceneNode() )     
EndProcedureUnit

ProcedureUnit Test_IrrAddLensFlareSceneNode()
  Assert ( IrrAddLensFlareSceneNode() )     
EndProcedureUnit

ProcedureUnit Test_IrrAddSphereSceneNode()
  Assert ( IrrAddSphereSceneNode(100,32) )     
EndProcedureUnit

ProcedureUnit Test_IrrAddCylinderSceneNode()
  Assert ( IrrAddCylinderSceneNode(25, 25, 1.0) )     
EndProcedureUnit

ProcedureUnit Test_IrrAddConeSceneNode()
  Assert ( IrrAddConeSceneNode(25, 25, 1.0) )     
EndProcedureUnit


ProcedureUnit Test_IrrAddPlaneSceneNode()
  Assert ( IrrAddPlaneSceneNode("TestPlane", 100.0, 100.0, 25, 25, 10, 10) )     
EndProcedureUnit

 ProcedureUnit Test_IrrAddHillPlaneSceneNode()
  UnitDebug("Problems with IrrAddHillPlaneSceneNode !!")
;   Assert ( IrrAddHillPlaneSceneNode("TestHillPlane", 100.0, 100.0, 25, 25, 10, 10, 100, 20) )     
 EndProcedureUnit

ProcedureUnit Test_IrrAddHillPlaneMesh()
  Assert ( IrrAddHillPlaneMesh("TestHillPlaneMesh", 100.0, 100.0, 25, 25, 10, 10, 100, 20) )     
EndProcedureUnit

ProcedureUnit Test_IrrAddWaterSceneNode()
  *mesh = IrrAddHillPlaneMesh("TestHillPlaneMesh2", 100.0, 100.0, 25, 25, 10, 10, 100, 20)
  Assert(*mesh)
  Assert ( IrrAddWaterSceneNode(*mesh,2.0,100.0,30.0) )     
EndProcedureUnit


ProcedureUnit Test_IrrAddParticleSystemToScene()
  Assert ( IrrAddParticleSystemToScene(#False) )       
EndProcedureUnit

ProcedureUnit Test_IrrAddParticleSystemToSceneTrue()
  Assert ( IrrAddParticleSystemToScene(#True) )       
EndProcedureUnit

ProcedureUnit Test_IrrAddSkyBoxToScene()
 Dim *textures.irr_texture(6)
  *textures(0) = IrrGetTexture("..\media\irrlicht2_up.jpg")
  *textures(1) = IrrGetTexture("..\media\irrlicht2_dn.jpg")
  *textures(2) = IrrGetTexture("..\media\irrlicht2_rt.jpg")
  *textures(3) = IrrGetTexture("..\media\irrlicht2_lf.jpg")
  *textures(4) = IrrGetTexture("..\media\irrlicht2_ft.jpg")
  *textures(5) = IrrGetTexture("..\media\irrlicht2_bk.jpg")

  For i = 0 To 5
    Assert( *textures(i)<>#Null, "Problem Skybox-Texture No. "+Str(i))
  Next
  
  Assert ( IrrAddSkyBoxToScene( *textures(0),*textures(1),*textures(2),*textures(3),*textures(4),*textures(5)) )       
  
EndProcedureUnit


ProcedureUnit Test_IrrAddTextSceneNode()
  *font = IrrGetBuitInFont()  
  Assert(*font)
  Assert ( IrrAddTextSceneNode(*font.l, "TestTextFürSceneNode") )
EndProcedureUnit
  

  
  
  
;     IrrAddSkyDomeToScene(*texture.l, horiRes.l, vertRes.l, texturePercentage.d, spherePercentage.d )
;     IrrSetShadowColor(alpha.l, red.l, green.l, blue.l )


;     IrrMakePlanarTextureMapping(*mesh.l, resolution.f = 0.001)
;     

;     IrrGetMeshFromMemory(*memoryadress.l, size.l, name.p-ascii, deleteMemoryWhenDropped.l )

;     IrrCreateMesh(name.p-ascii, vertexCount, *vertices.l, indicesCount.l, *indices.l )
;     IrrRemoveMesh(*mesh.l)
;     IrrGetMeshIndices(*mesh.l, Frame.l, *memory.l)
;     IrrSetMeshIndices(*mesh.l, Frame.l, *memory.l)
;     IrrGetMeshVertexCount(*mesh.l, Frame.l)
;     IrrGetMeshVertices(*mesh.l, Frame.l, *memory.IRR_VERT)
;     IrrSetMeshVertices(*mesh.l, Frame.l, *memory.IRR_VERT)

; 
;     IrrAddTextSceneNode(*font.l, text.p-unicode)
;     IrrAddSkyDomeToScene(*texture.l, horiRes.l, vertRes.l, texturePercentage.d, spherePercentage.d )
;     IrrSetShadowColor(alpha.l, red.l, green.l, blue.l )
;     IrrSetFog(alpha.l, red.l, green.l, blue.l , fogType.l, fogStart.f, fogEnd.f, fogDensity.f, pixelFog.l = #False,rangeFog.l=#False)
;     IrrGetSceneNodeFromName(nodeName.p-ascii)
;     IrrGetSceneNodeFromId(nodeId.l)
;     IrrGetRootSceneNode()
;     IrrLoadScene(sceneFile.p-ascii)
;     IrrSaveScene(sceneFile.p-ascii)



;    IrrGetNodeParent(*node.l)
;     IrrGetNodeID(*node.l)
;     IrrSetNodeID(*node.l, id.l)
;     IrrGetNodeName(*node.l)
;     IrrSetNodeName(*node.l, nodeName.p-ascii)
;     IrrDebugDataVisible(*node.l, bVisible.l)
;     IrrSetNodeMaterialTexture(*node, *texture, index.l)
;     IrrSetNodeMaterialFlag(*node.l, flag.l, bEnable.l)
;     IrrSetNodeMaterialType(*node.l, type.l)
;     IrrSetNodePosition(*node.l, x.f, y.f, z.f)
;     IrrSetNodeRotation(*node.l, x.f, y.f, z.f)
;     IrrSetNodeScale(*node.l, x.f, y.f, z.f)
;     IrrGetNodeScale(*node.l, *x.f, *y.f, *z.f)
;     IrrGetNodePosition(*node.l, *x.f, *y.f, *z.f)
;     IrrGetNodeRotation(*node.l, *x.f, *y.f, *z.f)
;     IrrGetNodeAbsolutePosition(*node.l, *x.f, *y.f, *z.f)
;     IrrGetMS3DJointNode(*node.l, JointName.p-ascii)
;     IrrGetDirectXJointNode(*node.l, JointName.p-ascii)
;     IrrGetB3DJointNode(*node.l, JointName.p-ascii)
;     IrrAddChildToParent(*nodeChild.l, *nodeParent)
;     IrrAddNodeShadow(*node.l, bZfailmethod.l=#False, infinity.f=10000.00)
;     IrrSetNodeVisibility(*node.l, bVisible.l)
;     IrrGetNodeVisibility(*node.l)
;     IrrRemoveNode(*node.l)
;     IrrSetNodeMaterialShininess(*node.l,materialID.l, shininess.f)
;     IrrGetNodeMaterial(*node.l,materialID.l)
;     IrrGetNodeMaterialCount(*node.l)
;     IrrGetToTargetPitchRoll(*sourceNode.l, *targetNode.l, *x.f, *y.f, *z.f)
;     IrrMoveNodeForward(*node.l, speed.f)
;     IrrMoveNodeRight(*node.l, speed.f)
;     IrrMoveNodeUp(*node.l, speed.f)
;     IrrSetNodeAutomaticCulling(*node.l, bCull.l)
;     IrrSetNodeDebugData(*node.l, bDebug.l)
;     IrrIsNodeDebugData(*node.l)
;     IrrSetNodeAllMaterialShininess(*node.l, shininess.f)
;     IrrSetNodeAllMaterialDiffuseColor(*node.l, alpha.l, red.l, green.l, blue.l)
;     IrrSetNodeAllMaterialSpecularColor(*node.l, alpha.l, red.l, green.l, blue.l)
;     IrrSetNodeAllMaterialEmissiveColor(*node.l, alpha.l, red.l, green.l, blue.l)
;     IrrSetNodeAllMaterialAmbientColor(*node.l, alpha.l, red.l, green.l, blue.l)
;     IrrGetNodeCenter(*node.l, *x.f,*y.f,*z.f)
;     IrrGetNodeCenterTransformed(*node.l, *x.f,*y.f,*z.f)
;     IrrGetNodeExtent(*node.l, *x.f,*y.f,*z.f)
;     IrrGetNodeExtentTransformed(*node.l, *x.f,*y.f,*z.f)
;     IrrRemoveAllChilds(*node.l)
;     IrrGetNodeChildCount(*node.l)
;     IrrGetNodeChildAt(*node.l, index.l)
;     IrrSetNodeVertexColors(*node.l, alpha.l,red.l,green.l,blue.l)
;     IrrRotateNodeByCenter(*node.l, mode.l, degrees.d, x.f,y.f,z.f)
;     IrrRotateNodeByNode(*node.l, mode.l, degrees.d, *rotNode.l)
; IDE Options = PureBasic 4.10 Beta 3 (Windows - x86)
; CursorPosition = 190
; FirstLine = 160
; Folding = -
; CompileSourceDirectory