// ----------------------------------------------------------------------------
// Blitz-Irrlicht 1.8.3 Wrapper by Ed Musolino 2015
// Based off of Frank Dodd's Irrlicht 1.7 Freebasic Wrapper (2006-2010)
// ----------------------------------------------------------------------------

//  This software is provided 'as-is', without any express Or implied
//  warranty.  In no event will the authors be held liable For any damages
//  arising from the use of this software.

//  Permission is granted To anyone To use this software For any purpose,
//  including commercial applications, And To alter it And redistribute it
//  freely, subject To the following restrictions:

//  1. The Origin of this software must Not be misrepresented; you must not
//     claim that you wrote the original software. If you use this software
//     in a product, an acknowledgement in the product documentation would be
//     appreciated but is Not required.
//  2. Altered source versions must be clearly marked as such, And must Not be
//     misrepresented as being the original software.
//  3. This notice may Not be removed Or altered from any source distribution.
//
// /////////////////////////////////////////////////////////////////////////////

#include "bIrrlicht.h"


extern IrrlichtDevice*		device;
extern IVideoDriver*		driver;
extern ISceneManager*		smgr;
extern IGUIEnvironment*		guienv;




extern "C"
{

/* ----------------------------------------------------------------------------
add zip archive to the filing system allowing you to load files straight out of
the zip file.
*/
DLL_EXPORT int* BBCALL iAddZipFile( const char *cptrFile, bool boIgnoreCase, bool boIgnorePaths,
								   const char *password = NULL  ) //E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN
{
	irr::io::IFileArchive* file = 0;
    device->getFileSystem()->addFileArchive( cptrFile, boIgnoreCase, boIgnorePaths, EFAT_UNKNOWN, password, &file );//, (const irr::core::stringc)password );
	return (int*)file;
}

DLL_EXPORT void BBCALL iFreeZipFile( int archive )
{
    device->getFileSystem()->removeFileArchive( archive );
}

/* ----------------------------------------------------------------------------
set irrlicht current working directory
*/
DLL_EXPORT void BBCALL iChangeWorkingDirectory( const char *cptrPath )
{
    // Changes the current Working Directory to the overgiven string.
    device->getFileSystem()->changeWorkingDirectoryTo( cptrPath );
}

/* ----------------------------------------------------------------------------
get irrlicht current working directory
*/
DLL_EXPORT const char * BBCALL iGetWorkingDirectory( void )
{
    // Returns the string of the current working directory.
    return device->getFileSystem()->getWorkingDirectory().c_str();
}

DLL_EXPORT int * BBCALL iLoadOctreeMesh( const char *cptrFile )		//  ED MUSOLINO
{
    /* load a mesh and add it to the scene */
	IAnimatedMesh* mesh = smgr->getMesh( cptrFile );

	return (int *)mesh;
}

/* ----------------------------------------------------------------------------
add the supplied mesh object to the scene as an octtree node
*/
DLL_EXPORT int * BBCALL iAddOctreeMeshNode( void *vptrMesh )
{
    // add the mesh to the scene as an octtree
    return (int *)smgr->addOctreeSceneNode((IAnimatedMesh*)vptrMesh);
}






}


