\r
const io::path mediaPath = getExampleMediaPath();\r
\r
- scene::IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "coolguy_opt.x");\r
+ auto mesh_file = device->getFileSystem()->createAndOpenFile(mediaPath + "coolguy_opt.x");\r
+ check(mesh_file, "mesh file loading");\r
+ scene::IAnimatedMesh* mesh = smgr->getMesh(mesh_file);\r
check(mesh, "mesh loading");\r
+ if (mesh_file)\r
+ mesh_file->drop();\r
if (mesh)\r
{\r
video::ITexture* tex = driver->getTexture(mediaPath + "cooltexture.png");\r
* \endcode\r
* If you would like to implement and add your own file format loader to Irrlicht,\r
* see addExternalMeshLoader().\r
- * \param filename: Filename of the mesh to load.\r
- * \param alternativeCacheName: In case you want to have the mesh under another name in the cache (to create real copies)\r
+ * \param file File handle of the mesh to load.\r
* \return Null if failed, otherwise pointer to the mesh.\r
* This pointer should not be dropped. See IReferenceCounted::drop() for more information.\r
**/\r
- virtual IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName=io::path("")) = 0;\r
-\r
- //! Get pointer to an animateable mesh. Loads the file if not loaded already.\r
- /** Works just as getMesh(const char* filename). If you want to\r
- remove a loaded mesh from the cache again, use removeMesh().\r
- \param file File handle of the mesh to load.\r
- \return NULL if failed and pointer to the mesh if successful.\r
- This pointer should not be dropped. See\r
- IReferenceCounted::drop() for more information. */\r
virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0;\r
\r
//! Get interface to the mesh cache which is shared between all existing scene managers.\r
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */\r
virtual video::IVideoDriver* getVideoDriver() = 0;\r
\r
- //! Get the active FileSystem\r
- /** \return Pointer to the FileSystem\r
- This pointer should not be dropped. See IReferenceCounted::drop() for more information. */\r
- virtual io::IFileSystem* getFileSystem() = 0;\r
-\r
//! Adds a scene node for rendering an animated mesh model.\r
/** \param mesh: Pointer to the loaded animated mesh to be displayed.\r
\param parent: Parent of the scene node. Can be NULL if no parent.\r
GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator);\r
\r
// create Scene manager\r
- SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl);\r
+ SceneManager = scene::createSceneManager(VideoDriver, CursorControl);\r
\r
setEventReceiver(UserReceiver);\r
}\r
\r
namespace scene\r
{\r
- ISceneManager* createSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, gui::ICursorControl* cc);\r
+ ISceneManager* createSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cc);\r
}\r
\r
namespace io\r
{\r
\r
//! constructor\r
-CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,\r
+CSceneManager::CSceneManager(video::IVideoDriver* driver,\r
gui::ICursorControl* cursorControl, IMeshCache* cache)\r
-: ISceneNode(0, 0), Driver(driver), FileSystem(fs),\r
+: ISceneNode(0, 0), Driver(driver),\r
CursorControl(cursorControl),\r
ActiveCamera(0), ShadowColor(150,0,0,0), AmbientLight(0,0,0,0), Parameters(0),\r
MeshCache(cache), CurrentRenderPass(ESNRP_NONE)\r
if (Driver)\r
Driver->grab();\r
\r
- if (FileSystem)\r
- FileSystem->grab();\r
-\r
if (CursorControl)\r
CursorControl->grab();\r
\r
if (Driver)\r
Driver->removeAllHardwareBuffers();\r
\r
- if (FileSystem)\r
- FileSystem->drop();\r
-\r
if (CursorControl)\r
CursorControl->drop();\r
\r
}\r
\r
\r
-//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.\r
-IAnimatedMesh* CSceneManager::getMesh(const io::path& filename, const io::path& alternativeCacheName)\r
-{\r
- io::path cacheName = alternativeCacheName.empty() ? filename : alternativeCacheName;\r
- IAnimatedMesh* msh = MeshCache->getMeshByName(cacheName);\r
- if (msh)\r
- return msh;\r
-\r
- io::IReadFile* file = FileSystem->createAndOpenFile(filename);\r
- if (!file)\r
- {\r
- os::Printer::log("Could not load mesh, because file could not be opened: ", filename, ELL_ERROR);\r
- return 0;\r
- }\r
-\r
- msh = getUncachedMesh(file, filename, cacheName);\r
-\r
- file->drop();\r
-\r
- return msh;\r
-}\r
-\r
-\r
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.\r
IAnimatedMesh* CSceneManager::getMesh(io::IReadFile* file)\r
{\r
}\r
\r
\r
-//! Get the active FileSystem\r
-/** \return Pointer to the FileSystem\r
-This pointer should not be dropped. See IReferenceCounted::drop() for more information. */\r
-io::IFileSystem* CSceneManager::getFileSystem()\r
-{\r
- return FileSystem;\r
-}\r
-\r
-\r
//! adds a scene node for rendering a static mesh\r
//! the returned pointer must not be dropped.\r
IMeshSceneNode* CSceneManager::addMeshSceneNode(IMesh* mesh, ISceneNode* parent, s32 id,\r
//! Creates a new scene manager.\r
ISceneManager* CSceneManager::createNewSceneManager(bool cloneContent)\r
{\r
- CSceneManager* manager = new CSceneManager(Driver, FileSystem, CursorControl, MeshCache);\r
+ CSceneManager* manager = new CSceneManager(Driver, CursorControl, MeshCache);\r
\r
if (cloneContent)\r
manager->cloneMembers(this, manager);\r
\r
\r
// creates a scenemanager\r
-ISceneManager* createSceneManager(video::IVideoDriver* driver,\r
- io::IFileSystem* fs, gui::ICursorControl* cursorcontrol)\r
+ISceneManager* createSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cursorcontrol)\r
{\r
- return new CSceneManager(driver, fs, cursorcontrol, nullptr);\r
+ return new CSceneManager(driver, cursorcontrol, nullptr);\r
}\r
\r
\r
public:\r
\r
//! constructor\r
- CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,\r
- gui::ICursorControl* cursorControl, IMeshCache* cache = nullptr);\r
+ CSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cursorControl, IMeshCache* cache = 0);\r
\r
//! destructor\r
virtual ~CSceneManager();\r
\r
- //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.\r
- IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName) override;\r
-\r
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.\r
IAnimatedMesh* getMesh(io::IReadFile* file) override;\r
\r
//! returns the video driver\r
video::IVideoDriver* getVideoDriver() override;\r
\r
- //! return the filesystem\r
- io::IFileSystem* getFileSystem() override;\r
-\r
//! adds a scene node for rendering an animated mesh model\r
virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1,\r
const core::vector3df& position = core::vector3df(0,0,0),\r
//! video driver\r
video::IVideoDriver* Driver;\r
\r
- //! file system\r
- io::IFileSystem* FileSystem;\r
-\r
//! cursor control\r
gui::ICursorControl* CursorControl;\r
\r