2012-09-30 16:38:54 -07:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
2009-07-30 00:58:33 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __I_MESH_LOADER_H_INCLUDED__
|
|
|
|
#define __I_MESH_LOADER_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IReferenceCounted.h"
|
2009-08-24 02:12:27 -07:00
|
|
|
#include "path.h"
|
Add IMeshTextureLoader interface and replace texture-loading algorithms in most meshloaders.
Previously each meshloader had implemented texture loading independendly. This had caused a lot of redundant codes and behaviour
between different meshloaders was often different. So we have now one common interface which should be used by all meshloaders.
This also allows deprecating TEXTURE_PATH attributes as those paths can now be set by that interface and for all meshloaders using it.
I have replaced the codes for the 3DS, B3D, CSM, Collada, DMF, LMTS, LWO, MY3D, OBJ, OCT, Ogre, SMF and X meshloader.
Not changed (just using old code) are: MS3D (I forgot that one), CIrrMeshFileLoader (haven't figured out how it works yet).
STL and PLY both don't load textures and need no changes.
MDL, MD3, MD2 and BSP all work a little different (the textureloading there isn't implemented inside the meshloaders). Those could maybe still be adapted.
Stuff still needs a lot more test (unfortunately I don't have test-models for most formats...), but wanted to check it in already to get some feedback.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4703 dfc29bdd-3216-0410-991c-e03cc46cb475
2014-03-01 16:56:46 -08:00
|
|
|
#include "IMeshTextureLoader.h"
|
2009-07-30 00:58:33 -07:00
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
class IReadFile;
|
|
|
|
} // end namespace io
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
class IAnimatedMesh;
|
|
|
|
|
|
|
|
//! Class which is able to load an animated mesh from a file.
|
|
|
|
/** If you want Irrlicht be able to load meshes of
|
|
|
|
currently unsupported file formats (e.g. .cob), then implement
|
|
|
|
this and add your new Meshloader with
|
|
|
|
ISceneManager::addExternalMeshLoader() to the engine. */
|
|
|
|
class IMeshLoader : public virtual IReferenceCounted
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
Add IMeshTextureLoader interface and replace texture-loading algorithms in most meshloaders.
Previously each meshloader had implemented texture loading independendly. This had caused a lot of redundant codes and behaviour
between different meshloaders was often different. So we have now one common interface which should be used by all meshloaders.
This also allows deprecating TEXTURE_PATH attributes as those paths can now be set by that interface and for all meshloaders using it.
I have replaced the codes for the 3DS, B3D, CSM, Collada, DMF, LMTS, LWO, MY3D, OBJ, OCT, Ogre, SMF and X meshloader.
Not changed (just using old code) are: MS3D (I forgot that one), CIrrMeshFileLoader (haven't figured out how it works yet).
STL and PLY both don't load textures and need no changes.
MDL, MD3, MD2 and BSP all work a little different (the textureloading there isn't implemented inside the meshloaders). Those could maybe still be adapted.
Stuff still needs a lot more test (unfortunately I don't have test-models for most formats...), but wanted to check it in already to get some feedback.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4703 dfc29bdd-3216-0410-991c-e03cc46cb475
2014-03-01 16:56:46 -08:00
|
|
|
//! Constructor
|
|
|
|
IMeshLoader() : TextureLoader(0) {}
|
|
|
|
|
2009-07-30 00:58:33 -07:00
|
|
|
//! Destructor
|
Add IMeshTextureLoader interface and replace texture-loading algorithms in most meshloaders.
Previously each meshloader had implemented texture loading independendly. This had caused a lot of redundant codes and behaviour
between different meshloaders was often different. So we have now one common interface which should be used by all meshloaders.
This also allows deprecating TEXTURE_PATH attributes as those paths can now be set by that interface and for all meshloaders using it.
I have replaced the codes for the 3DS, B3D, CSM, Collada, DMF, LMTS, LWO, MY3D, OBJ, OCT, Ogre, SMF and X meshloader.
Not changed (just using old code) are: MS3D (I forgot that one), CIrrMeshFileLoader (haven't figured out how it works yet).
STL and PLY both don't load textures and need no changes.
MDL, MD3, MD2 and BSP all work a little different (the textureloading there isn't implemented inside the meshloaders). Those could maybe still be adapted.
Stuff still needs a lot more test (unfortunately I don't have test-models for most formats...), but wanted to check it in already to get some feedback.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4703 dfc29bdd-3216-0410-991c-e03cc46cb475
2014-03-01 16:56:46 -08:00
|
|
|
virtual ~IMeshLoader()
|
|
|
|
{
|
|
|
|
if ( TextureLoader )
|
|
|
|
TextureLoader->drop();
|
|
|
|
}
|
2009-07-30 00:58:33 -07:00
|
|
|
|
|
|
|
//! Returns true if the file might be loaded by this class.
|
|
|
|
/** This decision should be based on the file extension (e.g. ".cob")
|
|
|
|
only.
|
2009-10-23 11:06:57 -07:00
|
|
|
\param filename Name of the file to test.
|
2009-07-30 00:58:33 -07:00
|
|
|
\return True if the file might be loaded by this class. */
|
2009-08-24 02:12:27 -07:00
|
|
|
virtual bool isALoadableFileExtension(const io::path& filename) const = 0;
|
2009-07-30 00:58:33 -07:00
|
|
|
|
|
|
|
//! Creates/loads an animated mesh from the file.
|
|
|
|
/** \param file File handler to load the file from.
|
|
|
|
\return Pointer to the created mesh. Returns 0 if loading failed.
|
|
|
|
If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
|
|
|
See IReferenceCounted::drop() for more information. */
|
|
|
|
virtual IAnimatedMesh* createMesh(io::IReadFile* file) = 0;
|
Add IMeshTextureLoader interface and replace texture-loading algorithms in most meshloaders.
Previously each meshloader had implemented texture loading independendly. This had caused a lot of redundant codes and behaviour
between different meshloaders was often different. So we have now one common interface which should be used by all meshloaders.
This also allows deprecating TEXTURE_PATH attributes as those paths can now be set by that interface and for all meshloaders using it.
I have replaced the codes for the 3DS, B3D, CSM, Collada, DMF, LMTS, LWO, MY3D, OBJ, OCT, Ogre, SMF and X meshloader.
Not changed (just using old code) are: MS3D (I forgot that one), CIrrMeshFileLoader (haven't figured out how it works yet).
STL and PLY both don't load textures and need no changes.
MDL, MD3, MD2 and BSP all work a little different (the textureloading there isn't implemented inside the meshloaders). Those could maybe still be adapted.
Stuff still needs a lot more test (unfortunately I don't have test-models for most formats...), but wanted to check it in already to get some feedback.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4703 dfc29bdd-3216-0410-991c-e03cc46cb475
2014-03-01 16:56:46 -08:00
|
|
|
|
|
|
|
//! Set a new texture loader which this meshloader can use when searching for textures.
|
2014-03-03 05:57:08 -08:00
|
|
|
/** NOTE: Not all meshloaders do support this interface. Meshloaders which
|
|
|
|
support it will return a non-null value in getMeshTextureLoader from the start. Setting a
|
|
|
|
texture-loader to a meshloader which doesn't support it won't help.
|
|
|
|
\param textureLoader The textureloader to use. When set to NULL the mesh will not load any textures.
|
Add IMeshTextureLoader interface and replace texture-loading algorithms in most meshloaders.
Previously each meshloader had implemented texture loading independendly. This had caused a lot of redundant codes and behaviour
between different meshloaders was often different. So we have now one common interface which should be used by all meshloaders.
This also allows deprecating TEXTURE_PATH attributes as those paths can now be set by that interface and for all meshloaders using it.
I have replaced the codes for the 3DS, B3D, CSM, Collada, DMF, LMTS, LWO, MY3D, OBJ, OCT, Ogre, SMF and X meshloader.
Not changed (just using old code) are: MS3D (I forgot that one), CIrrMeshFileLoader (haven't figured out how it works yet).
STL and PLY both don't load textures and need no changes.
MDL, MD3, MD2 and BSP all work a little different (the textureloading there isn't implemented inside the meshloaders). Those could maybe still be adapted.
Stuff still needs a lot more test (unfortunately I don't have test-models for most formats...), but wanted to check it in already to get some feedback.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4703 dfc29bdd-3216-0410-991c-e03cc46cb475
2014-03-01 16:56:46 -08:00
|
|
|
*/
|
|
|
|
virtual void setMeshTextureLoader(IMeshTextureLoader* textureLoader)
|
|
|
|
{
|
|
|
|
if ( textureLoader != TextureLoader )
|
|
|
|
{
|
|
|
|
if ( textureLoader )
|
|
|
|
textureLoader->grab();
|
|
|
|
if ( TextureLoader )
|
|
|
|
TextureLoader->drop();
|
|
|
|
TextureLoader = textureLoader;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-13 05:50:06 -07:00
|
|
|
//! Get the texture loader used when this meshloader searches for textures.
|
2014-03-03 05:57:08 -08:00
|
|
|
/** NOTE: not all meshloaders support this interface so this can return NULL.
|
|
|
|
*/
|
Add IMeshTextureLoader interface and replace texture-loading algorithms in most meshloaders.
Previously each meshloader had implemented texture loading independendly. This had caused a lot of redundant codes and behaviour
between different meshloaders was often different. So we have now one common interface which should be used by all meshloaders.
This also allows deprecating TEXTURE_PATH attributes as those paths can now be set by that interface and for all meshloaders using it.
I have replaced the codes for the 3DS, B3D, CSM, Collada, DMF, LMTS, LWO, MY3D, OBJ, OCT, Ogre, SMF and X meshloader.
Not changed (just using old code) are: MS3D (I forgot that one), CIrrMeshFileLoader (haven't figured out how it works yet).
STL and PLY both don't load textures and need no changes.
MDL, MD3, MD2 and BSP all work a little different (the textureloading there isn't implemented inside the meshloaders). Those could maybe still be adapted.
Stuff still needs a lot more test (unfortunately I don't have test-models for most formats...), but wanted to check it in already to get some feedback.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4703 dfc29bdd-3216-0410-991c-e03cc46cb475
2014-03-01 16:56:46 -08:00
|
|
|
virtual IMeshTextureLoader* getMeshTextureLoader() const
|
|
|
|
{
|
|
|
|
return TextureLoader;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
IMeshTextureLoader* TextureLoader;
|
2009-07-30 00:58:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|