- move importer and postprocessing step construction chain to separate files to make them available to the exporter part.

+ introduce aiScene::mPrivate. This is a potentially breaking API change. The new member is added at the end of the structure though, so serious regressions are not to be expected.
+ add a mPreprocessing parameter to all Export API calls. Allow exporters to specify further PP steps to be executed prior to handing control to them. The entire export API now operates on a copy of the scene that the user passed in.
- mass refactoring: all constructors of BaseProcess/BaseImporter inherited classes are public now and Importer will perhaps feel a bit sad after having loft all of its friends.
# fix const correctness in SceneCombiner


git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1060 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/2/head
aramis_acg 2011-08-01 20:58:31 +00:00
parent 967e87d625
commit 665f73861e
83 changed files with 5621 additions and 2209 deletions

View File

@ -61,13 +61,9 @@ using namespace D3DS;
*/
class Discreet3DSImporter : public BaseImporter
{
friend class Importer;
public:
protected:
/** Constructor to be privately used by Importer */
Discreet3DSImporter();
/** Destructor, private as well */
~Discreet3DSImporter();
public:

View File

@ -56,16 +56,12 @@ namespace Assimp {
*/
class AC3DImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
AC3DImporter();
/** Destructor, private as well */
~AC3DImporter();
// Represents an AC3D material
struct Material
{

View File

@ -58,15 +58,11 @@ class MaterialHelper;
*
*/
class ASEImporter : public BaseImporter {
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
ASEImporter();
/** Destructor, private as well */
~ASEImporter();
public:
// -------------------------------------------------------------------

View File

@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "GenericProperty.h"
#include "CInterfaceIOWrapper.h"
#include "Importer.h"
// ------------------------------------------------------------------------------------------------
#ifdef AI_C_THREADSAFE

View File

@ -65,29 +65,29 @@ ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex
// ------------------------------------------------------------------------------------------------
ASSIMP_API aiReturn aiExportScene( const aiScene* pScene, const char* pFormatId, const char* pFileName )
ASSIMP_API aiReturn aiExportScene( const aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing )
{
return ::aiExportSceneEx(pScene,pFormatId,pFileName,NULL);
return ::aiExportSceneEx(pScene,pFormatId,pFileName,NULL,pPreprocessing);
}
// ------------------------------------------------------------------------------------------------
ASSIMP_API aiReturn aiExportSceneEx( const aiScene* pScene, const char* pFormatId, const char* pFileName, aiFileIO* pIO)
ASSIMP_API aiReturn aiExportSceneEx( const aiScene* pScene, const char* pFormatId, const char* pFileName, aiFileIO* pIO, unsigned int pPreprocessing )
{
Exporter exp;
if (pIO) {
exp.SetIOHandler(new CIOSystemWrapper(pIO));
}
return exp.Export(pScene,pFormatId,pFileName);
return exp.Export(pScene,pFormatId,pFileName,pPreprocessing);
}
// ------------------------------------------------------------------------------------------------
ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const aiScene* pScene, const char* pFormatId )
ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing )
{
Exporter exp;
if (!exp.ExportToBlob(pScene,pFormatId)) {
if (!exp.ExportToBlob(pScene,pFormatId,pPreprocessing)) {
return NULL;
}
const aiExportDataBlob* blob = exp.GetOrphanedBlob();

View File

@ -68,3 +68,65 @@ ASSIMP_API unsigned int aiGetVersionRevision ()
return SVNRevision;
}
// ------------------------------------------------------------------------------------------------
aiScene::aiScene()
: mFlags()
, mRootNode()
, mNumMeshes()
, mMeshes()
, mNumMaterials()
, mMaterials()
, mNumAnimations()
, mAnimations()
, mNumTextures()
, mTextures()
, mNumLights()
, mLights()
, mNumCameras()
, mCameras()
, mPrivate(new Assimp::ScenePrivateData())
{
}
// ------------------------------------------------------------------------------------------------
aiScene::~aiScene()
{
// delete all sub-objects recursively
delete mRootNode;
// To make sure we won't crash if the data is invalid it's
// much better to check whether both mNumXXX and mXXX are
// valid instead of relying on just one of them.
if (mNumMeshes && mMeshes)
for( unsigned int a = 0; a < mNumMeshes; a++)
delete mMeshes[a];
delete [] mMeshes;
if (mNumMaterials && mMaterials)
for( unsigned int a = 0; a < mNumMaterials; a++)
delete mMaterials[a];
delete [] mMaterials;
if (mNumAnimations && mAnimations)
for( unsigned int a = 0; a < mNumAnimations; a++)
delete mAnimations[a];
delete [] mAnimations;
if (mNumTextures && mTextures)
for( unsigned int a = 0; a < mNumTextures; a++)
delete mTextures[a];
delete [] mTextures;
if (mNumLights && mLights)
for( unsigned int a = 0; a < mNumLights; a++)
delete mLights[a];
delete [] mLights;
if (mNumCameras && mCameras)
for( unsigned int a = 0; a < mNumCameras; a++)
delete mCameras[a];
delete [] mCameras;
delete static_cast<Assimp::ScenePrivateData*>( mPrivate );
}

View File

@ -145,6 +145,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "StringComparison.h"
#include "StreamReader.h"
#include "qnan.h"
#include "ScenePrivate.h"
// We need those constants, workaround for any platforms where nobody defined them yet

View File

@ -61,7 +61,6 @@ namespace Assimp
*/
class BVHLoader : public BaseImporter
{
friend class Importer;
/** Possible animation channels for which the motion data holds the values */
enum ChannelType
@ -85,11 +84,9 @@ class BVHLoader : public BaseImporter
Node( const aiNode* pNode) : mNode( pNode) { }
};
protected:
/** Constructor to be privately used by Importer */
BVHLoader();
public:
/** Destructor, private as well */
BVHLoader();
~BVHLoader();
public:

View File

@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BaseImporter.h"
#include "FileSystemFilter.h"
#include "Importer.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------

View File

@ -94,66 +94,7 @@ private:
bool mdismiss;
};
//! @cond never
// ---------------------------------------------------------------------------
/** @brief Internal PIMPL implementation for Assimp::Importer
*
* Using this idiom here allows us to drop the dependency from
* std::vector and std::map in the public headers. Furthermore we are dropping
* any STL interface problems caused by mismatching STL settings. All
* size calculation are now done by us, not the app heap. */
class ASSIMP_API ImporterPimpl
{
public:
// Data type to store the key hash
typedef unsigned int KeyType;
// typedefs for our three configuration maps.
// We don't need more, so there is no need for a generic solution
typedef std::map<KeyType, int> IntPropertyMap;
typedef std::map<KeyType, float> FloatPropertyMap;
typedef std::map<KeyType, std::string> StringPropertyMap;
public:
/** IO handler to use for all file accesses. */
IOSystem* mIOHandler;
bool mIsDefaultHandler;
/** Progress handler for feedback. */
ProgressHandler* mProgressHandler;
bool mIsDefaultProgressHandler;
/** Format-specific importer worker objects - one for each format we can read.*/
std::vector<BaseImporter*> mImporter;
/** Post processing steps we can apply at the imported data. */
std::vector<BaseProcess*> mPostProcessingSteps;
/** The imported data, if ReadFile() was successful, NULL otherwise. */
aiScene* mScene;
/** The error description, if there was one. */
std::string mErrorString;
/** List of integer properties */
IntPropertyMap mIntProperties;
/** List of floating-point properties */
FloatPropertyMap mFloatProperties;
/** List of string properties */
StringPropertyMap mStringProperties;
/** Used for testing - extra verbose mode causes the ValidateDataStructure-Step
* to be executed before and after every single postprocess step */
bool bExtraVerbose;
/** Used by post-process steps to share data */
SharedPostProcessInfo* mPPShared;
};
//! @endcond
// ---------------------------------------------------------------------------
/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface
@ -169,7 +110,7 @@ class ASSIMP_API BaseImporter
{
friend class Importer;
protected:
public:
/** Constructor to be privately used by #Importer */
BaseImporter();
@ -407,92 +348,7 @@ protected:
ProgressHandler* progress;
};
struct BatchData;
// ---------------------------------------------------------------------------
/** FOR IMPORTER PLUGINS ONLY: A helper class for the pleasure of importers
* which need to load many extern meshes recursively.
*
* The class uses several threads to load these meshes (or at least it
* could, this has not yet been implemented at the moment).
*
* @note The class may not be used by more than one thread*/
class ASSIMP_API BatchLoader
{
// friend of Importer
public:
//! @cond never
// -------------------------------------------------------------------
/** Wraps a full list of configuration properties for an importer.
* Properties can be set using SetGenericProperty */
struct PropertyMap
{
ImporterPimpl::IntPropertyMap ints;
ImporterPimpl::FloatPropertyMap floats;
ImporterPimpl::StringPropertyMap strings;
bool operator == (const PropertyMap& prop) const {
// fixme: really isocpp? gcc complains
return ints == prop.ints && floats == prop.floats && strings == prop.strings;
}
bool empty () const {
return ints.empty() && floats.empty() && strings.empty();
}
};
//! @endcond
public:
// -------------------------------------------------------------------
/** Construct a batch loader from a given IO system to be used
* to acess external files */
BatchLoader(IOSystem* pIO);
~BatchLoader();
// -------------------------------------------------------------------
/** Add a new file to the list of files to be loaded.
* @param file File to be loaded
* @param steps Post-processing steps to be executed on the file
* @param map Optional configuration properties
* @return 'Load request channel' - an unique ID that can later
* be used to access the imported file data.
* @see GetImport */
unsigned int AddLoadRequest (
const std::string& file,
unsigned int steps = 0,
const PropertyMap* map = NULL
);
// -------------------------------------------------------------------
/** Get an imported scene.
* This polls the import from the internal request list.
* If an import is requested several times, this function
* can be called several times, too.
*
* @param which LRWC returned by AddLoadRequest().
* @return NULL if there is no scene with this file name
* in the queue of the scene hasn't been loaded yet. */
aiScene* GetImport(
unsigned int which
);
// -------------------------------------------------------------------
/** Waits until all scenes have been loaded. This returns
* immediately if no scenes are queued.*/
void LoadAll();
private:
// No need to have that in the public API ...
BatchData* data;
};
} // end of namespace Assimp

View File

@ -45,6 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BaseImporter.h"
#include "BaseProcess.h"
#include "Importer.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------

View File

@ -120,16 +120,11 @@ struct aiLoaderDesc
// -------------------------------------------------------------------------------------------
class BlenderImporter : public BaseImporter, public LogFunctions<BlenderImporter>
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
BlenderImporter();
/** Destructor, private as well */
~BlenderImporter();
public:
// --------------------

View File

@ -95,6 +95,10 @@ SET( Common_SRCS
BaseImporter.h
BaseProcess.cpp
BaseProcess.h
Importer.h
ScenePrivate.h
PostStepRegistry.cpp
ImporterRegistry.cpp
ByteSwap.h
DefaultProgressHandler.h
DefaultIOStream.cpp

View File

@ -68,16 +68,11 @@ namespace Assimp {
// -------------------------------------------------------------------------------------------
class COBImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
COBImporter();
/** Destructor, private as well */
~COBImporter();
public:
// --------------------

View File

@ -56,14 +56,11 @@ namespace Assimp {
*/
class CSMImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
CSMImporter();
/** Destructor, private as well */
~CSMImporter();
public:
// -------------------------------------------------------------------
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,

View File

@ -59,13 +59,9 @@ namespace Assimp
*/
class ASSIMP_API CalcTangentsProcess : public BaseProcess
{
friend class Importer;
public:
protected:
/** Constructor to be privately used by Importer */
CalcTangentsProcess();
/** Destructor, private as well */
~CalcTangentsProcess();
public:

View File

@ -78,15 +78,11 @@ struct ColladaMeshIndex
*/
class ColladaLoader : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
ColladaLoader();
/** Destructor, private as well */
~ColladaLoader();
public:
/** Returns whether the class can handle the format of the given file.
* See BaseImporter::CanRead() for details. */

View File

@ -56,17 +56,12 @@ namespace Assimp
*/
class ASSIMP_API ComputeUVMappingProcess : public BaseProcess
{
friend class Importer;
friend class ::ComputeUVMappingTest; // grant the unit test full access to us
protected:
/** Constructor to be privately used by Importer */
public:
ComputeUVMappingProcess();
/** Destructor, private as well */
~ComputeUVMappingProcess();
public:
// -------------------------------------------------------------------
/** Returns whether the processing step is present in the given flag field.
* @param pFlags The processing flags the importer was called with. A bitwise

View File

@ -69,13 +69,10 @@ namespace Assimp {
*/
class ASSIMP_API MakeLeftHandedProcess : public BaseProcess
{
friend class Importer;
public:
/** Constructor to be privately used by Importer */
MakeLeftHandedProcess();
/** Destructor, private as well */
~MakeLeftHandedProcess();
// -------------------------------------------------------------------

View File

@ -65,16 +65,12 @@ namespace Assimp {
*/
class DXFImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
DXFImporter();
/** Destructor, private as well */
~DXFImporter();
public:
// -------------------------------------------------------------------

View File

@ -66,14 +66,9 @@ namespace Assimp
*/
class ASSIMP_API DeboneProcess : public BaseProcess
{
friend class Importer;
friend class ::DeboneTest;
public:
protected:
/** Constructor to be privately used by Importer */
DeboneProcess();
/** Destructor, private as well */
~DeboneProcess();
public:

View File

@ -56,9 +56,15 @@ Here we implement only the C++ interface (Assimp::Exporter).
#include "DefaultIOSystem.h"
#include "BlobIOSystem.h"
#include "SceneCombiner.h"
#include "BaseProcess.h"
#include "Importer.h" // need this for GetPostProcessingStepInstanceList()
namespace Assimp {
// PostStepRegistry.cpp
void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out);
// ------------------------------------------------------------------------------------------------
// Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype
void ExportSceneCollada(const char*,IOSystem*, const aiScene*);
@ -78,13 +84,17 @@ struct ExportFormatEntry
// Worker function to do the actual exporting
fpExportFunc mExportFunction;
// Postprocessing steps to be executed PRIOR to calling mExportFunction
unsigned int mEnforcePP;
// Constructor to fill all entries
ExportFormatEntry( const char* pId, const char* pDesc, const char* pExtension, fpExportFunc pFunction)
ExportFormatEntry( const char* pId, const char* pDesc, const char* pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u)
{
mDescription.id = pId;
mDescription.description = pDesc;
mDescription.fileExtension = pExtension;
mExportFunction = pFunction;
mEnforcePP = pEnforcePP;
}
};
@ -114,12 +124,17 @@ public:
, mIOSystem(new Assimp::DefaultIOSystem())
, mIsDefaultIOHandler(true)
{
GetPostProcessingStepInstanceList(mPostProcessingSteps);
}
~ExporterPimpl()
{
delete blob;
// Delete all post-processing plug-ins
for( unsigned int a = 0; a < mPostProcessingSteps.size(); a++) {
delete mPostProcessingSteps[a];
}
}
public:
@ -127,6 +142,9 @@ public:
aiExportDataBlob* blob;
boost::shared_ptr< Assimp::IOSystem > mIOSystem;
bool mIsDefaultIOHandler;
/** Post processing steps we can apply at the imported data. */
std::vector< BaseProcess* > mPostProcessingSteps;
};
#define ASSIMP_NUM_EXPORTERS (sizeof(gExporters)/sizeof(gExporters[0]))
@ -177,7 +195,7 @@ bool Exporter :: IsDefaultIOHandler() const
// ------------------------------------------------------------------------------------------------
const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const char* pFormatId )
const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing )
{
if (pimpl->blob) {
delete pimpl->blob;
@ -203,14 +221,33 @@ const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const
// ------------------------------------------------------------------------------------------------
aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const char* pPath )
aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing )
{
ASSIMP_BEGIN_EXCEPTION_REGION();
for (size_t i = 0; i < ASSIMP_NUM_EXPORTERS; ++i) {
if (!strcmp(gExporters[i].mDescription.id,pFormatId)) {
try {
gExporters[i].mExportFunction(pPath,pimpl->mIOSystem.get(),pScene);
// Always create a full copy of the scene. We might optimize this one day,
// but for now it is the most pragmatic way.
aiScene* scenecopy_tmp;
SceneCombiner::CopyScene(&scenecopy_tmp,pScene);
std::auto_ptr<aiScene> scenecopy(scenecopy_tmp);
const unsigned int pp = (gExporters[i].mEnforcePP | pPreprocessing);
if (pp) {
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
BaseProcess* const p = pimpl->mPostProcessingSteps[a];
if (p->IsActive(pp)) {
p->Execute(scenecopy.get());
}
}
}
gExporters[i].mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get());
}
catch (DeadlyExportError& err) {
// XXX what to do with the error message? Maybe introduce extra member to hold it, similar to Assimp.Importer

View File

@ -55,14 +55,9 @@ namespace Assimp {
*/
class ASSIMP_API FindDegeneratesProcess : public BaseProcess
{
friend class Importer;
friend class ::FindDegeneratesProcessTest; // grant the unit test full access to us
public:
protected:
/** Constructor to be privately used by Importer */
FindDegeneratesProcess();
/** Destructor, private as well */
~FindDegeneratesProcess();
public:

View File

@ -54,7 +54,7 @@ namespace Assimp {
/** @brief Get a pseudo(!)-hash representing a mesh.
*
* The hash is built from number of vertices, faces, primitive types,
* .... but *not* from the real mesh data. It isn't absolutely unique.
* .... but *not* from the real mesh data. The funcction is not a perfect hash.
* @param in Input mesh
* @return Hash.
*/
@ -107,14 +107,9 @@ inline bool CompareArrays(const aiColor4D* first, const aiColor4D* second,
*/
class ASSIMP_API FindInstancesProcess : public BaseProcess
{
friend class Importer;
friend class ::FindInstancesProcessTest;
public:
protected:
/** Constructor to be privately used by Importer */
FindInstancesProcess();
/** Destructor, private as well */
~FindInstancesProcess();
public:

View File

@ -59,15 +59,9 @@ namespace Assimp {
class ASSIMP_API FindInvalidDataProcess
: public BaseProcess
{
friend class Importer;
friend class ::FindInvalidDataProcessTest;
public:
protected:
/** Constructor to be privately used by Importer */
FindInvalidDataProcess();
/** Destructor, private as well */
~FindInvalidDataProcess();
public:

View File

@ -55,15 +55,11 @@ namespace Assimp
* vectors of an object are facing inwards. In this case they will be
* flipped.
*/
class ASSIMP_API FixInfacingNormalsProcess : public BaseProcess
class ASSIMP_API FixInfacingNormalsProcess : public BaseProcess
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
FixInfacingNormalsProcess();
/** Destructor, private as well */
~FixInfacingNormalsProcess();
public:

View File

@ -53,13 +53,9 @@ namespace Assimp
*/
class ASSIMP_API GenFaceNormalsProcess : public BaseProcess
{
friend class Importer;
public:
protected:
/** Constructor to be privately used by Importer */
GenFaceNormalsProcess();
/** Destructor, private as well */
~GenFaceNormalsProcess();
public:

View File

@ -55,14 +55,9 @@ namespace Assimp {
*/
class ASSIMP_API GenVertexNormalsProcess : public BaseProcess
{
friend class Importer;
friend class ::GenNormalsTest;
public:
protected:
/** Constructor to be privately used by Importer */
GenVertexNormalsProcess();
/** Destructor, private as well */
~GenVertexNormalsProcess();
public:

View File

@ -62,15 +62,11 @@ using namespace HMP;
*/
class HMPImporter : public MDLImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
HMPImporter();
/** Destructor, private as well */
~HMPImporter();
public:
// -------------------------------------------------------------------

View File

@ -69,16 +69,11 @@ namespace Assimp {
// -------------------------------------------------------------------------------------------
class IFCImporter : public BaseImporter, public LogFunctions<IFCImporter>
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
IFCImporter();
/** Destructor, private as well */
~IFCImporter();
public:
// --------------------

View File

@ -52,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SceneCombiner.h"
#include "StandardShapes.h"
#include "Importer.h"
// We need boost::common_factor to compute the lcm/gcd of a number
#include <boost/math/common_factor_rt.hpp>

View File

@ -61,15 +61,11 @@ namespace Assimp {
*/
class IRRImporter : public BaseImporter, public IrrlichtBase
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
IRRImporter();
/** Destructor, private as well */
~IRRImporter();
public:
// -------------------------------------------------------------------

View File

@ -59,15 +59,11 @@ namespace Assimp {
*/
class IRRMeshImporter : public BaseImporter, public IrrlichtBase
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
IRRMeshImporter();
/** Destructor, private as well */
~IRRMeshImporter();
public:
// -------------------------------------------------------------------

View File

@ -61,8 +61,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ------------------------------------------------------------------------------------------------
// Internal headers
// ------------------------------------------------------------------------------------------------
#include "BaseImporter.h"
#include "Importer.h"
#include "BaseProcess.h"
#include "DefaultIOStream.h"
#include "DefaultIOSystem.h"
#include "DefaultProgressHandler.h"
@ -73,197 +74,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Profiler.h"
#include "TinyFormatter.h"
using namespace Assimp::Profiling;
using namespace Assimp::Formatter;
// ------------------------------------------------------------------------------------------------
// Importers
// (include_new_importers_here)
// ------------------------------------------------------------------------------------------------
#ifndef ASSIMP_BUILD_NO_X_IMPORTER
# include "XFileImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
# include "3DSLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
# include "MD3Loader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MDL_IMPORTER
# include "MDLLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
# include "MD2Loader.h"
#endif
#ifndef ASSIMP_BUILD_NO_PLY_IMPORTER
# include "PlyLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_ASE_IMPORTER
# include "ASELoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
# include "ObjFileImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_HMP_IMPORTER
# include "HMPLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_SMD_IMPORTER
# include "SMDLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MDC_IMPORTER
# include "MDCLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MD5_IMPORTER
# include "MD5Loader.h"
#endif
#ifndef ASSIMP_BUILD_NO_STL_IMPORTER
# include "STLLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_LWO_IMPORTER
# include "LWOLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
# include "DXFLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_NFF_IMPORTER
# include "NFFLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
# include "RawLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
# include "OFFLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_AC_IMPORTER
# include "ACLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_BVH_IMPORTER
# include "BVHLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_IRRMESH_IMPORTER
# include "IRRMeshLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_IRR_IMPORTER
# include "IRRLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER
# include "Q3DLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
# include "B3DImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
# include "ColladaLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
# include "TerragenLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
# include "CSMLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
# include "UnrealLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_LWS_IMPORTER
# include "LWSLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER
# include "OgreImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_MS3D_IMPORTER
# include "MS3DLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_COB_IMPORTER
# include "COBLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
# include "BlenderLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
# include "Q3BSPFileImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
# include "NDOLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
# include "IFCLoader.h"
#endif
// ------------------------------------------------------------------------------------------------
// Post processing-Steps
// ------------------------------------------------------------------------------------------------
#ifndef ASSIMP_BUILD_NO_CALCTANGENTS_PROCESS
# include "CalcTangentsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_JOINVERTICES_PROCESS
# include "JoinVerticesProcess.h"
#endif
#if !(defined ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS && defined ASSIMP_BUILD_NO_FLIPUVS_PROCESS && defined ASSIMP_BUILD_NO_FLIPWINDINGORDER_PROCESS)
# include "ConvertToLHProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_TRIANGULATE_PROCESS
# include "TriangulateProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_GENFACENORMALS_PROCESS
# include "GenFaceNormalsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_GENVERTEXNORMALS_PROCESS
# include "GenVertexNormalsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_REMOVEVC_PROCESS
# include "RemoveVCProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_SPLITLARGEMESHES_PROCESS
# include "SplitLargeMeshes.h"
#endif
#ifndef ASSIMP_BUILD_NO_PRETRANSFORMVERTICES_PROCESS
# include "PretransformVertices.h"
#endif
#ifndef ASSIMP_BUILD_NO_LIMITBONEWEIGHTS_PROCESS
# include "LimitBoneWeightsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
# include "ValidateDataStructure.h"
#endif
#ifndef ASSIMP_BUILD_NO_IMPROVECACHELOCALITY_PROCESS
# include "ImproveCacheLocality.h"
#endif
#ifndef ASSIMP_BUILD_NO_FIXINFACINGNORMALS_PROCESS
# include "FixNormalsStep.h"
#endif
#ifndef ASSIMP_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS
# include "RemoveRedundantMaterials.h"
#endif
#ifndef ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS
# include "FindInvalidDataProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS
# include "FindDegenerates.h"
#endif
#ifndef ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS
# include "SortByPTypeProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS
# include "ComputeUVMappingProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_TRANSFORMTEXCOORDS_PROCESS
# include "TextureTransform.h"
#endif
#ifndef ASSIMP_BUILD_NO_FINDINSTANCES_PROCESS
# include "FindInstancesProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_OPTIMIZEMESHES_PROCESS
# include "OptimizeMeshes.h"
#endif
#ifndef ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS
# include "OptimizeGraph.h"
#endif
#ifndef ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS
# include "SplitByBoneCountProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_DEBONE_PROCESS
# include "DeboneProcess.h"
#endif
using namespace Assimp::Profiling;
using namespace Assimp::Formatter;
namespace Assimp {
// ImporterRegistry.cpp
void GetImporterInstanceList(std::vector< BaseImporter* >& out);
// PostStepRegistry.cpp
void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out);
}
using namespace Assimp;
using namespace Assimp::Intern;
@ -326,215 +149,8 @@ Importer::Importer()
pimpl->mProgressHandler = new DefaultProgressHandler();
pimpl->mIsDefaultProgressHandler = true;
// ----------------------------------------------------------------------------
// Add an instance of each worker class here
// (register_new_importers_here)
// ----------------------------------------------------------------------------
pimpl->mImporter.reserve(64);
#if (!defined ASSIMP_BUILD_NO_X_IMPORTER)
pimpl->mImporter.push_back( new XFileImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_OBJ_IMPORTER)
pimpl->mImporter.push_back( new ObjFileImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
pimpl->mImporter.push_back( new Discreet3DSImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
pimpl->mImporter.push_back( new MD3Importer());
#endif
#if (!defined ASSIMP_BUILD_NO_MD2_IMPORTER)
pimpl->mImporter.push_back( new MD2Importer());
#endif
#if (!defined ASSIMP_BUILD_NO_PLY_IMPORTER)
pimpl->mImporter.push_back( new PLYImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MDL_IMPORTER)
pimpl->mImporter.push_back( new MDLImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_ASE_IMPORTER)
pimpl->mImporter.push_back( new ASEImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_HMP_IMPORTER)
pimpl->mImporter.push_back( new HMPImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_SMD_IMPORTER)
pimpl->mImporter.push_back( new SMDImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MDC_IMPORTER)
pimpl->mImporter.push_back( new MDCImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MD5_IMPORTER)
pimpl->mImporter.push_back( new MD5Importer());
#endif
#if (!defined ASSIMP_BUILD_NO_STL_IMPORTER)
pimpl->mImporter.push_back( new STLImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_LWO_IMPORTER)
pimpl->mImporter.push_back( new LWOImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_DXF_IMPORTER)
pimpl->mImporter.push_back( new DXFImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_NFF_IMPORTER)
pimpl->mImporter.push_back( new NFFImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_RAW_IMPORTER)
pimpl->mImporter.push_back( new RAWImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_OFF_IMPORTER)
pimpl->mImporter.push_back( new OFFImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_AC_IMPORTER)
pimpl->mImporter.push_back( new AC3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_BVH_IMPORTER)
pimpl->mImporter.push_back( new BVHLoader());
#endif
#if (!defined ASSIMP_BUILD_NO_IRRMESH_IMPORTER)
pimpl->mImporter.push_back( new IRRMeshImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_IRR_IMPORTER)
pimpl->mImporter.push_back( new IRRImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_Q3D_IMPORTER)
pimpl->mImporter.push_back( new Q3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_B3D_IMPORTER)
pimpl->mImporter.push_back( new B3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_COLLADA_IMPORTER)
pimpl->mImporter.push_back( new ColladaLoader());
#endif
#if (!defined ASSIMP_BUILD_NO_TERRAGEN_IMPORTER)
pimpl->mImporter.push_back( new TerragenImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_CSM_IMPORTER)
pimpl->mImporter.push_back( new CSMImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_3D_IMPORTER)
pimpl->mImporter.push_back( new UnrealImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_LWS_IMPORTER)
pimpl->mImporter.push_back( new LWSImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_OGRE_IMPORTER)
pimpl->mImporter.push_back( new Ogre::OgreImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MS3D_IMPORTER)
pimpl->mImporter.push_back( new MS3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_COB_IMPORTER)
pimpl->mImporter.push_back( new COBImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_BLEND_IMPORTER)
pimpl->mImporter.push_back( new BlenderImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_Q3BSP_IMPORTER)
pimpl->mImporter.push_back( new Q3BSPFileImporter() );
#endif
#if (!defined ASSIMP_BUILD_NO_NDO_IMPORTER)
pimpl->mImporter.push_back( new NDOImporter() );
#endif
#if (!defined ASSIMP_BUILD_NO_IFC_IMPORTER)
pimpl->mImporter.push_back( new IFCImporter() );
#endif
// ----------------------------------------------------------------------------
// Add an instance of each post processing step here in the order
// of sequence it is executed. Steps that are added here are not
// validated - as RegisterPPStep() does - all dependencies must be given.
// ----------------------------------------------------------------------------
pimpl->mPostProcessingSteps.reserve(25);
#if (!defined ASSIMP_BUILD_NO_REMOVEVC_PROCESS)
pimpl->mPostProcessingSteps.push_back( new RemoveVCProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS)
pimpl->mPostProcessingSteps.push_back( new RemoveRedundantMatsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FINDINSTANCES_PROCESS)
pimpl->mPostProcessingSteps.push_back( new FindInstancesProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
pimpl->mPostProcessingSteps.push_back( new OptimizeGraphProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEMESHES_PROCESS)
pimpl->mPostProcessingSteps.push_back( new OptimizeMeshesProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS)
pimpl->mPostProcessingSteps.push_back( new FindDegeneratesProcess());
#endif
#ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS
pimpl->mPostProcessingSteps.push_back( new ComputeUVMappingProcess());
#endif
#ifndef ASSIMP_BUILD_NO_TRANSFORMTEXCOORDS_PROCESS
pimpl->mPostProcessingSteps.push_back( new TextureTransformStep());
#endif
#if (!defined ASSIMP_BUILD_NO_PRETRANSFORMVERTICES_PROCESS)
pimpl->mPostProcessingSteps.push_back( new PretransformVertices());
#endif
#if (!defined ASSIMP_BUILD_NO_TRIANGULATE_PROCESS)
pimpl->mPostProcessingSteps.push_back( new TriangulateProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS)
pimpl->mPostProcessingSteps.push_back( new SortByPTypeProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS)
pimpl->mPostProcessingSteps.push_back( new FindInvalidDataProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FIXINFACINGNORMALS_PROCESS)
pimpl->mPostProcessingSteps.push_back( new FixInfacingNormalsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS)
pimpl->mPostProcessingSteps.push_back( new SplitByBoneCountProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_SPLITLARGEMESHES_PROCESS)
pimpl->mPostProcessingSteps.push_back( new SplitLargeMeshesProcess_Triangle());
#endif
#if (!defined ASSIMP_BUILD_NO_GENFACENORMALS_PROCESS)
pimpl->mPostProcessingSteps.push_back( new GenFaceNormalsProcess());
#endif
// .........................................................................
// DON'T change the order of these five!
pimpl->mPostProcessingSteps.push_back( new ComputeSpatialSortProcess());
// .........................................................................
#if (!defined ASSIMP_BUILD_NO_GENVERTEXNORMALS_PROCESS)
pimpl->mPostProcessingSteps.push_back( new GenVertexNormalsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_CALCTANGENTS_PROCESS)
pimpl->mPostProcessingSteps.push_back( new CalcTangentsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_JOINVERTICES_PROCESS)
pimpl->mPostProcessingSteps.push_back( new JoinVerticesProcess());
#endif
// .........................................................................
pimpl->mPostProcessingSteps.push_back( new DestroySpatialSortProcess());
// .........................................................................
#if (!defined ASSIMP_BUILD_NO_SPLITLARGEMESHES_PROCESS)
pimpl->mPostProcessingSteps.push_back( new SplitLargeMeshesProcess_Vertex());
#endif
#if (!defined ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS)
pimpl->mPostProcessingSteps.push_back( new MakeLeftHandedProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FLIPUVS_PROCESS)
pimpl->mPostProcessingSteps.push_back( new FlipUVsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FLIPWINDINGORDER_PROCESS)
pimpl->mPostProcessingSteps.push_back( new FlipWindingOrderProcess());
#endif
#if (!defined ASSIMP_BUILD_DEBONE_PROCESS)
pimpl->mPostProcessingSteps.push_back( new DeboneProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_LIMITBONEWEIGHTS_PROCESS)
pimpl->mPostProcessingSteps.push_back( new LimitBoneWeightsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_IMPROVECACHELOCALITY_PROCESS)
pimpl->mPostProcessingSteps.push_back( new ImproveCacheLocalityProcess());
#endif
GetImporterInstanceList(pimpl->mImporter);
GetPostProcessingStepInstanceList(pimpl->mPostProcessingSteps);
// Allocate a SharedPostProcessInfo object and store pointers to it in all post-process steps in the list.
pimpl->mPPShared = new SharedPostProcessInfo();
@ -1179,6 +795,9 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
#endif // ! DEBUG
}
// update private scene flags
ScenePriv(pimpl->mScene)->mPPStepsApplied |= pFlags;
// clear any data allocated by post-process steps
pimpl->mPPShared->Clean();
DefaultLogger::get()->info("Leaving post processing pipeline");

204
code/Importer.h 100644
View File

@ -0,0 +1,204 @@
/*
Open Asset Import Library (ASSIMP)
----------------------------------------------------------------------
Copyright (c) 2006-2010, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file Importer.h mostly internal stuff for use by #Assimp::Importer */
#ifndef INCLUDED_AI_IMPORTER_H
#define INCLUDED_AI_IMPORTER_H
namespace Assimp {
class BaseImporter;
class BaseProcess;
//! @cond never
// ---------------------------------------------------------------------------
/** @brief Internal PIMPL implementation for Assimp::Importer
*
* Using this idiom here allows us to drop the dependency from
* std::vector and std::map in the public headers. Furthermore we are dropping
* any STL interface problems caused by mismatching STL settings. All
* size calculation are now done by us, not the app heap. */
class ASSIMP_API ImporterPimpl
{
public:
// Data type to store the key hash
typedef unsigned int KeyType;
// typedefs for our three configuration maps.
// We don't need more, so there is no need for a generic solution
typedef std::map<KeyType, int> IntPropertyMap;
typedef std::map<KeyType, float> FloatPropertyMap;
typedef std::map<KeyType, std::string> StringPropertyMap;
public:
/** IO handler to use for all file accesses. */
IOSystem* mIOHandler;
bool mIsDefaultHandler;
/** Progress handler for feedback. */
ProgressHandler* mProgressHandler;
bool mIsDefaultProgressHandler;
/** Format-specific importer worker objects - one for each format we can read.*/
std::vector< BaseImporter* > mImporter;
/** Post processing steps we can apply at the imported data. */
std::vector< BaseProcess* > mPostProcessingSteps;
/** The imported data, if ReadFile() was successful, NULL otherwise. */
aiScene* mScene;
/** The error description, if there was one. */
std::string mErrorString;
/** List of integer properties */
IntPropertyMap mIntProperties;
/** List of floating-point properties */
FloatPropertyMap mFloatProperties;
/** List of string properties */
StringPropertyMap mStringProperties;
/** Used for testing - extra verbose mode causes the ValidateDataStructure-Step
* to be executed before and after every single postprocess step */
bool bExtraVerbose;
/** Used by post-process steps to share data */
SharedPostProcessInfo* mPPShared;
};
//! @endcond
struct BatchData;
// ---------------------------------------------------------------------------
/** FOR IMPORTER PLUGINS ONLY: A helper class to the pleasure of importers
* that need to load many external meshes recursively.
*
* The class uses several threads to load these meshes (or at least it
* could, this has not yet been implemented at the moment).
*
* @note The class may not be used by more than one thread*/
class ASSIMP_API BatchLoader
{
// friend of Importer
public:
//! @cond never
// -------------------------------------------------------------------
/** Wraps a full list of configuration properties for an importer.
* Properties can be set using SetGenericProperty */
struct PropertyMap
{
ImporterPimpl::IntPropertyMap ints;
ImporterPimpl::FloatPropertyMap floats;
ImporterPimpl::StringPropertyMap strings;
bool operator == (const PropertyMap& prop) const {
// fixme: really isocpp? gcc complains
return ints == prop.ints && floats == prop.floats && strings == prop.strings;
}
bool empty () const {
return ints.empty() && floats.empty() && strings.empty();
}
};
//! @endcond
public:
// -------------------------------------------------------------------
/** Construct a batch loader from a given IO system to be used
* to acess external files */
BatchLoader(IOSystem* pIO);
~BatchLoader();
// -------------------------------------------------------------------
/** Add a new file to the list of files to be loaded.
* @param file File to be loaded
* @param steps Post-processing steps to be executed on the file
* @param map Optional configuration properties
* @return 'Load request channel' - an unique ID that can later
* be used to access the imported file data.
* @see GetImport */
unsigned int AddLoadRequest (
const std::string& file,
unsigned int steps = 0,
const PropertyMap* map = NULL
);
// -------------------------------------------------------------------
/** Get an imported scene.
* This polls the import from the internal request list.
* If an import is requested several times, this function
* can be called several times, too.
*
* @param which LRWC returned by AddLoadRequest().
* @return NULL if there is no scene with this file name
* in the queue of the scene hasn't been loaded yet. */
aiScene* GetImport(
unsigned int which
);
// -------------------------------------------------------------------
/** Waits until all scenes have been loaded. This returns
* immediately if no scenes are queued.*/
void LoadAll();
private:
// No need to have that in the public API ...
BatchData* data;
};
}
#endif

View File

@ -0,0 +1,284 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2010, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file ImporterRegistry.cpp
Central registry for all importers available. Do not edit this file
directly (unless you are adding new loaders), instead use the
corresponding preprocessor flag to selectively disable formats.
*/
#include "AssimpPCH.h"
// ------------------------------------------------------------------------------------------------
// Importers
// (include_new_importers_here)
// ------------------------------------------------------------------------------------------------
#ifndef ASSIMP_BUILD_NO_X_IMPORTER
# include "XFileImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
# include "3DSLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
# include "MD3Loader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MDL_IMPORTER
# include "MDLLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
# include "MD2Loader.h"
#endif
#ifndef ASSIMP_BUILD_NO_PLY_IMPORTER
# include "PlyLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_ASE_IMPORTER
# include "ASELoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
# include "ObjFileImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_HMP_IMPORTER
# include "HMPLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_SMD_IMPORTER
# include "SMDLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MDC_IMPORTER
# include "MDCLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_MD5_IMPORTER
# include "MD5Loader.h"
#endif
#ifndef ASSIMP_BUILD_NO_STL_IMPORTER
# include "STLLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_LWO_IMPORTER
# include "LWOLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
# include "DXFLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_NFF_IMPORTER
# include "NFFLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
# include "RawLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
# include "OFFLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_AC_IMPORTER
# include "ACLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_BVH_IMPORTER
# include "BVHLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_IRRMESH_IMPORTER
# include "IRRMeshLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_IRR_IMPORTER
# include "IRRLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER
# include "Q3DLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
# include "B3DImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
# include "ColladaLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
# include "TerragenLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
# include "CSMLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
# include "UnrealLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_LWS_IMPORTER
# include "LWSLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER
# include "OgreImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_MS3D_IMPORTER
# include "MS3DLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_COB_IMPORTER
# include "COBLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
# include "BlenderLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
# include "Q3BSPFileImporter.h"
#endif
#ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
# include "NDOLoader.h"
#endif
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
# include "IFCLoader.h"
#endif
namespace Assimp {
// ------------------------------------------------------------------------------------------------
void GetImporterInstanceList(std::vector< BaseImporter* >& out)
{
// ----------------------------------------------------------------------------
// Add an instance of each worker class here
// (register_new_importers_here)
// ----------------------------------------------------------------------------
out.reserve(64);
#if (!defined ASSIMP_BUILD_NO_X_IMPORTER)
out.push_back( new XFileImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_OBJ_IMPORTER)
out.push_back( new ObjFileImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
out.push_back( new Discreet3DSImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
out.push_back( new MD3Importer());
#endif
#if (!defined ASSIMP_BUILD_NO_MD2_IMPORTER)
out.push_back( new MD2Importer());
#endif
#if (!defined ASSIMP_BUILD_NO_PLY_IMPORTER)
out.push_back( new PLYImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MDL_IMPORTER)
out.push_back( new MDLImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_ASE_IMPORTER)
out.push_back( new ASEImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_HMP_IMPORTER)
out.push_back( new HMPImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_SMD_IMPORTER)
out.push_back( new SMDImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MDC_IMPORTER)
out.push_back( new MDCImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MD5_IMPORTER)
out.push_back( new MD5Importer());
#endif
#if (!defined ASSIMP_BUILD_NO_STL_IMPORTER)
out.push_back( new STLImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_LWO_IMPORTER)
out.push_back( new LWOImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_DXF_IMPORTER)
out.push_back( new DXFImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_NFF_IMPORTER)
out.push_back( new NFFImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_RAW_IMPORTER)
out.push_back( new RAWImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_OFF_IMPORTER)
out.push_back( new OFFImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_AC_IMPORTER)
out.push_back( new AC3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_BVH_IMPORTER)
out.push_back( new BVHLoader());
#endif
#if (!defined ASSIMP_BUILD_NO_IRRMESH_IMPORTER)
out.push_back( new IRRMeshImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_IRR_IMPORTER)
out.push_back( new IRRImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_Q3D_IMPORTER)
out.push_back( new Q3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_B3D_IMPORTER)
out.push_back( new B3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_COLLADA_IMPORTER)
out.push_back( new ColladaLoader());
#endif
#if (!defined ASSIMP_BUILD_NO_TERRAGEN_IMPORTER)
out.push_back( new TerragenImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_CSM_IMPORTER)
out.push_back( new CSMImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_3D_IMPORTER)
out.push_back( new UnrealImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_LWS_IMPORTER)
out.push_back( new LWSImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_OGRE_IMPORTER)
out.push_back( new Ogre::OgreImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_MS3D_IMPORTER)
out.push_back( new MS3DImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_COB_IMPORTER)
out.push_back( new COBImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_BLEND_IMPORTER)
out.push_back( new BlenderImporter());
#endif
#if (!defined ASSIMP_BUILD_NO_Q3BSP_IMPORTER)
out.push_back( new Q3BSPFileImporter() );
#endif
#if (!defined ASSIMP_BUILD_NO_NDO_IMPORTER)
out.push_back( new NDOImporter() );
#endif
#if (!defined ASSIMP_BUILD_NO_IFC_IMPORTER)
out.push_back( new IFCImporter() );
#endif
}
}

View File

@ -60,13 +60,9 @@ namespace Assimp
*/
class ASSIMP_API ImproveCacheLocalityProcess : public BaseProcess
{
friend class Importer;
public:
protected:
/** Constructor to be privately used by Importer */
ImproveCacheLocalityProcess();
/** Destructor, private as well */
~ImproveCacheLocalityProcess();
public:

View File

@ -63,14 +63,9 @@ class JoinVerticesTest;
*/
class ASSIMP_API JoinVerticesProcess : public BaseProcess
{
friend class Importer;
friend class JoinVerticesTest;
public:
protected:
/** Constructor to be privately used by Importer */
JoinVerticesProcess();
/** Destructor, private as well */
~JoinVerticesProcess();
public:

View File

@ -67,16 +67,11 @@ using namespace LWO;
// ---------------------------------------------------------------------------
class LWOImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
LWOImporter();
/** Destructor, private as well */
~LWOImporter();
public:
// -------------------------------------------------------------------

View File

@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "GenericProperty.h"
#include "SkeletonMeshBuilder.h"
#include "ConvertToLHProcess.h"
#include "Importer.h"
using namespace Assimp;

View File

@ -166,15 +166,11 @@ struct NodeDesc
*/
class LWSImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
LWSImporter();
/** Destructor, private as well */
~LWSImporter();
public:
// -------------------------------------------------------------------

View File

@ -71,14 +71,9 @@ namespace Assimp
*/
class ASSIMP_API LimitBoneWeightsProcess : public BaseProcess
{
friend class Importer;
friend class ::LimitBoneWeightsTest;
public:
protected:
/** Constructor to be privately used by Importer */
LimitBoneWeightsProcess();
/** Destructor, private as well */
~LimitBoneWeightsProcess();
public:

View File

@ -60,15 +60,11 @@ using namespace MD2;
*/
class MD2Importer : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
MD2Importer();
/** Destructor, private as well */
~MD2Importer();
public:
// -------------------------------------------------------------------

View File

@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "GenericProperty.h"
#include "RemoveComments.h"
#include "ParsingUtils.h"
#include "Importer.h"
using namespace Assimp;

View File

@ -211,15 +211,11 @@ bool LoadSkin(SkinData& fill, const std::string& file,IOSystem* io);
*/
class MD3Importer : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
MD3Importer();
/** Destructor, private as well */
~MD3Importer();
public:
// -------------------------------------------------------------------

View File

@ -61,15 +61,11 @@ using namespace Assimp::MD5;
*/
class MD5Importer : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
MD5Importer();
/** Destructor, private as well */
~MD5Importer();
public:
// -------------------------------------------------------------------

View File

@ -58,15 +58,11 @@ using namespace MDC;
*/
class MDCImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
MDCImporter();
/** Destructor, private as well */
~MDCImporter();
public:
// -------------------------------------------------------------------

View File

@ -82,15 +82,11 @@ using namespace MDL;
*/
class MDLImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
MDLImporter();
/** Destructor, private as well */
~MDLImporter();
public:
// -------------------------------------------------------------------

View File

@ -53,9 +53,8 @@ namespace Assimp {
class MS3DImporter
: public BaseImporter
{
friend class Importer;
protected:
public:
MS3DImporter();
~MS3DImporter();

View File

@ -53,14 +53,11 @@ namespace Assimp {
*/
class NDOImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
NDOImporter();
/** Destructor, private as well */
~NDOImporter();
public:
//! Represents a single edge

View File

@ -60,15 +60,11 @@ namespace Assimp {
*/
class NFFImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
NFFImporter();
/** Destructor, private as well */
~NFFImporter();
public:
// -------------------------------------------------------------------

View File

@ -55,15 +55,11 @@ namespace Assimp {
*/
class OFFImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
OFFImporter();
/** Destructor, private as well */
~OFFImporter();
public:
// -------------------------------------------------------------------

View File

@ -61,12 +61,9 @@ struct Model;
/// \class ObjFileImporter
/// \brief Imports a waveform obj file
// ------------------------------------------------------------------------------------------------
class ObjFileImporter :
BaseImporter
class ObjFileImporter : public BaseImporter
{
friend class Importer;
protected:
public:
/// \brief Default constructor
ObjFileImporter();

View File

@ -63,14 +63,9 @@ namespace Assimp {
*/
class ASSIMP_API OptimizeGraphProcess : public BaseProcess
{
friend class Importer;
friend class ::OptimizeGraphProcessTest;
public:
protected:
/** Constructor to be privately used by Importer */
OptimizeGraphProcess();
/** Destructor, private as well */
~OptimizeGraphProcess();
public:

View File

@ -61,14 +61,9 @@ namespace Assimp {
*/
class ASSIMP_API OptimizeMeshesProcess : public BaseProcess
{
friend class Importer;
friend class ::OptimizeMeshesProcessTest;
public:
protected:
/** Constructor to be privately used by Importer */
OptimizeMeshesProcess();
/** Destructor, private as well */
~OptimizeMeshesProcess();

View File

@ -61,15 +61,11 @@ using namespace PLY;
*/
class PLYImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
PLYImporter();
/** Destructor, private as well */
~PLYImporter();
public:
// -------------------------------------------------------------------

View File

@ -47,7 +47,7 @@ namespace Assimp {
// -------------------------------------------------------------------------------
/** Test if a given point p2 is on the left side of the line formed by p0-p1.
* The function accepts an unconstrained template parameter for use with
* The function accepts an unconstrained template parameter for use with
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
template <typename T>
inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2)
@ -57,7 +57,7 @@ inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2)
// -------------------------------------------------------------------------------
/** Test if a given point is inside a given triangle in R2.
* The function accepts an unconstrained template parameter for use with
* The function accepts an unconstrained template parameter for use with
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
template <typename T>
inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp)
@ -80,15 +80,15 @@ inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp)
return (dot11 > 0) && (dot00 > 0) && (dot11 + dot00 < 1);
}
// -------------------------------------------------------------------------------
/** Compute the signed area of a triangle.
* The function accepts an unconstrained template parameter for use with
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
template <typename T>
inline double GetArea2D(const T& v1, const T& v2, const T& v3)
{
return 0.5 * (v1.x * ((double)v3.y - v2.y) + v2.x * ((double)v1.y - v3.y) + v3.x * ((double)v2.y - v1.y));
// -------------------------------------------------------------------------------
/** Compute the signed area of a triangle.
* The function accepts an unconstrained template parameter for use with
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
template <typename T>
inline double GetArea2D(const T& v1, const T& v2, const T& v3)
{
return 0.5 * (v1.x * ((double)v3.y - v2.y) + v2.x * ((double)v1.y - v3.y) + v3.x * ((double)v2.y - v1.y));
}
@ -100,70 +100,70 @@ inline double GetArea2D(const T& v1, const T& v2, const T& v3)
* @note Code taken from http://cgm.cs.mcgill.ca/~godfried/teaching/cg-projects/97/Ian/applet1.html and translated to C++
*/
template <typename T>
inline bool IsCCW(T* in, size_t npoints) {
double aa, bb, cc, b, c, theta;
double convex_turn;
double convex_sum = 0;
for (int i = 0; i < npoints - 2; i++) {
aa = ((in[i+2].x - in[i].x) * (in[i+2].x - in[i].x)) +
((-in[i+2].y + in[i].y) * (-in[i+2].y + in[i].y));
bb = ((in[i+1].x - in[i].x) * (in[i+1].x - in[i].x)) +
((-in[i+1].y + in[i].y) * (-in[i+1].y + in[i].y));
cc = ((in[i+2].x - in[i+1].x) *
(in[i+2].x - in[i+1].x)) +
((-in[i+2].y + in[i+1].y) *
(-in[i+2].y + in[i+1].y));
b = sqrt(bb);
c = sqrt(cc);
theta = acos((bb + cc - aa) / (2 * b * c));
if (OnLeftSideOfLine2D(in[i],in[i+2],in[i+1])) {
// if (convex(in[i].x, in[i].y,
// in[i+1].x, in[i+1].y,
// in[i+2].x, in[i+2].y)) {
convex_turn = AI_MATH_PI_F - theta;
convex_sum += convex_turn;
}
else {
convex_sum -= AI_MATH_PI_F - theta;
}
}
aa = ((in[1].x - in[npoints-2].x) *
(in[1].x - in[npoints-2].x)) +
((-in[1].y + in[npoints-2].y) *
(-in[1].y + in[npoints-2].y));
bb = ((in[0].x - in[npoints-2].x) *
(in[0].x - in[npoints-2].x)) +
((-in[0].y + in[npoints-2].y) *
(-in[0].y + in[npoints-2].y));
cc = ((in[1].x - in[0].x) * (in[1].x - in[0].x)) +
((-in[1].y + in[0].y) * (-in[1].y + in[0].y));
b = sqrt(bb);
c = sqrt(cc);
theta = acos((bb + cc - aa) / (2 * b * c));
//if (convex(in[npoints-2].x, in[npoints-2].y,
// in[0].x, in[0].y,
// in[1].x, in[1].y)) {
if (OnLeftSideOfLine2D(in[npoints-2],in[1],in[0])) {
convex_turn = AI_MATH_PI_F - theta;
convex_sum += convex_turn;
}
else {
convex_sum -= AI_MATH_PI_F - theta;
}
return convex_sum >= (2 * AI_MATH_PI_F);
}
inline bool IsCCW(T* in, size_t npoints) {
double aa, bb, cc, b, c, theta;
double convex_turn;
double convex_sum = 0;
for (int i = 0; i < npoints - 2; i++) {
aa = ((in[i+2].x - in[i].x) * (in[i+2].x - in[i].x)) +
((-in[i+2].y + in[i].y) * (-in[i+2].y + in[i].y));
bb = ((in[i+1].x - in[i].x) * (in[i+1].x - in[i].x)) +
((-in[i+1].y + in[i].y) * (-in[i+1].y + in[i].y));
cc = ((in[i+2].x - in[i+1].x) *
(in[i+2].x - in[i+1].x)) +
((-in[i+2].y + in[i+1].y) *
(-in[i+2].y + in[i+1].y));
b = sqrt(bb);
c = sqrt(cc);
theta = acos((bb + cc - aa) / (2 * b * c));
if (OnLeftSideOfLine2D(in[i],in[i+2],in[i+1])) {
// if (convex(in[i].x, in[i].y,
// in[i+1].x, in[i+1].y,
// in[i+2].x, in[i+2].y)) {
convex_turn = AI_MATH_PI_F - theta;
convex_sum += convex_turn;
}
else {
convex_sum -= AI_MATH_PI_F - theta;
}
}
aa = ((in[1].x - in[npoints-2].x) *
(in[1].x - in[npoints-2].x)) +
((-in[1].y + in[npoints-2].y) *
(-in[1].y + in[npoints-2].y));
bb = ((in[0].x - in[npoints-2].x) *
(in[0].x - in[npoints-2].x)) +
((-in[0].y + in[npoints-2].y) *
(-in[0].y + in[npoints-2].y));
cc = ((in[1].x - in[0].x) * (in[1].x - in[0].x)) +
((-in[1].y + in[0].y) * (-in[1].y + in[0].y));
b = sqrt(bb);
c = sqrt(cc);
theta = acos((bb + cc - aa) / (2 * b * c));
//if (convex(in[npoints-2].x, in[npoints-2].y,
// in[0].x, in[0].y,
// in[1].x, in[1].y)) {
if (OnLeftSideOfLine2D(in[npoints-2],in[1],in[0])) {
convex_turn = AI_MATH_PI_F - theta;
convex_sum += convex_turn;
}
else {
convex_sum -= AI_MATH_PI_F - theta;
}
return convex_sum >= (2 * AI_MATH_PI_F);
}
// -------------------------------------------------------------------------------
/** Compute the normal of an arbitrary polygon in R3.
*

View File

@ -0,0 +1,229 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2010, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file ImporterRegistry.cpp
Central registry for all postprocessing steps available. Do not edit this file
directly (unless you are adding new steps), instead use the
corresponding preprocessor flag to selectively disable steps.
*/
#include "AssimpPCH.h"
#ifndef ASSIMP_BUILD_NO_CALCTANGENTS_PROCESS
# include "CalcTangentsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_JOINVERTICES_PROCESS
# include "JoinVerticesProcess.h"
#endif
#if !(defined ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS && defined ASSIMP_BUILD_NO_FLIPUVS_PROCESS && defined ASSIMP_BUILD_NO_FLIPWINDINGORDER_PROCESS)
# include "ConvertToLHProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_TRIANGULATE_PROCESS
# include "TriangulateProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_GENFACENORMALS_PROCESS
# include "GenFaceNormalsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_GENVERTEXNORMALS_PROCESS
# include "GenVertexNormalsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_REMOVEVC_PROCESS
# include "RemoveVCProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_SPLITLARGEMESHES_PROCESS
# include "SplitLargeMeshes.h"
#endif
#ifndef ASSIMP_BUILD_NO_PRETRANSFORMVERTICES_PROCESS
# include "PretransformVertices.h"
#endif
#ifndef ASSIMP_BUILD_NO_LIMITBONEWEIGHTS_PROCESS
# include "LimitBoneWeightsProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
# include "ValidateDataStructure.h"
#endif
#ifndef ASSIMP_BUILD_NO_IMPROVECACHELOCALITY_PROCESS
# include "ImproveCacheLocality.h"
#endif
#ifndef ASSIMP_BUILD_NO_FIXINFACINGNORMALS_PROCESS
# include "FixNormalsStep.h"
#endif
#ifndef ASSIMP_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS
# include "RemoveRedundantMaterials.h"
#endif
#ifndef ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS
# include "FindInvalidDataProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS
# include "FindDegenerates.h"
#endif
#ifndef ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS
# include "SortByPTypeProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS
# include "ComputeUVMappingProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_TRANSFORMTEXCOORDS_PROCESS
# include "TextureTransform.h"
#endif
#ifndef ASSIMP_BUILD_NO_FINDINSTANCES_PROCESS
# include "FindInstancesProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_OPTIMIZEMESHES_PROCESS
# include "OptimizeMeshes.h"
#endif
#ifndef ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS
# include "OptimizeGraph.h"
#endif
#ifndef ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS
# include "SplitByBoneCountProcess.h"
#endif
#ifndef ASSIMP_BUILD_NO_DEBONE_PROCESS
# include "DeboneProcess.h"
#endif
namespace Assimp {
// ------------------------------------------------------------------------------------------------
void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
{
// ----------------------------------------------------------------------------
// Add an instance of each post processing step here in the order
// of sequence it is executed. Steps that are added here are not
// validated - as RegisterPPStep() does - all dependencies must be given.
// ----------------------------------------------------------------------------
out.reserve(25);
#if (!defined ASSIMP_BUILD_NO_REMOVEVC_PROCESS)
out.push_back( new RemoveVCProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS)
out.push_back( new RemoveRedundantMatsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FINDINSTANCES_PROCESS)
out.push_back( new FindInstancesProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
out.push_back( new OptimizeGraphProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEMESHES_PROCESS)
out.push_back( new OptimizeMeshesProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS)
out.push_back( new FindDegeneratesProcess());
#endif
#ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS
out.push_back( new ComputeUVMappingProcess());
#endif
#ifndef ASSIMP_BUILD_NO_TRANSFORMTEXCOORDS_PROCESS
out.push_back( new TextureTransformStep());
#endif
#if (!defined ASSIMP_BUILD_NO_PRETRANSFORMVERTICES_PROCESS)
out.push_back( new PretransformVertices());
#endif
#if (!defined ASSIMP_BUILD_NO_TRIANGULATE_PROCESS)
out.push_back( new TriangulateProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS)
out.push_back( new SortByPTypeProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS)
out.push_back( new FindInvalidDataProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FIXINFACINGNORMALS_PROCESS)
out.push_back( new FixInfacingNormalsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS)
out.push_back( new SplitByBoneCountProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_SPLITLARGEMESHES_PROCESS)
out.push_back( new SplitLargeMeshesProcess_Triangle());
#endif
#if (!defined ASSIMP_BUILD_NO_GENFACENORMALS_PROCESS)
out.push_back( new GenFaceNormalsProcess());
#endif
// .........................................................................
// DON'T change the order of these five ..
// XXX this is actually a design weakness that dates back to the time
// when Importer would maintain the postprocessing step list exclusively.
// Now that others access it too, we need a better solution.
out.push_back( new ComputeSpatialSortProcess());
// .........................................................................
#if (!defined ASSIMP_BUILD_NO_GENVERTEXNORMALS_PROCESS)
out.push_back( new GenVertexNormalsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_CALCTANGENTS_PROCESS)
out.push_back( new CalcTangentsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_JOINVERTICES_PROCESS)
out.push_back( new JoinVerticesProcess());
#endif
// .........................................................................
out.push_back( new DestroySpatialSortProcess());
// .........................................................................
#if (!defined ASSIMP_BUILD_NO_SPLITLARGEMESHES_PROCESS)
out.push_back( new SplitLargeMeshesProcess_Vertex());
#endif
#if (!defined ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS)
out.push_back( new MakeLeftHandedProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FLIPUVS_PROCESS)
out.push_back( new FlipUVsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FLIPWINDINGORDER_PROCESS)
out.push_back( new FlipWindingOrderProcess());
#endif
#if (!defined ASSIMP_BUILD_DEBONE_PROCESS)
out.push_back( new DeboneProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_LIMITBONEWEIGHTS_PROCESS)
out.push_back( new LimitBoneWeightsProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_IMPROVECACHELOCALITY_PROCESS)
out.push_back( new ImproveCacheLocalityProcess());
#endif
}
}

View File

@ -58,14 +58,9 @@ namespace Assimp {
*/
class ASSIMP_API PretransformVertices : public BaseProcess
{
friend class Importer;
friend class ::PretransformVerticesTest;
public:
protected:
/** Constructor to be privately used by Importer */
PretransformVertices ();
/** Destructor, private as well */
~PretransformVertices ();
public:

View File

@ -58,11 +58,10 @@ struct sQ3BSPFace;
/** Loader to import BSP-levels from a PK3 archive or from a unpacked BSP-level.
*/
// ------------------------------------------------------------------------------------------------
class Q3BSPFileImporter : BaseImporter
class Q3BSPFileImporter : public BaseImporter
{
friend class Importer;
public:
protected:
/// @brief Default constructor.
Q3BSPFileImporter();

View File

@ -55,15 +55,11 @@ namespace Assimp {
*/
class Q3DImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
Q3DImporter();
/** Destructor, private as well */
~Q3DImporter();
public:
// -------------------------------------------------------------------

View File

@ -55,15 +55,11 @@ namespace Assimp {
*/
class RAWImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
RAWImporter();
/** Destructor, private as well */
~RAWImporter();
public:
// -------------------------------------------------------------------

View File

@ -56,14 +56,9 @@ namespace Assimp {
*/
class ASSIMP_API RemoveRedundantMatsProcess : public BaseProcess
{
friend class Importer;
friend class ::RemoveRedundantMatsTest; // grant the unit test full access to us
public:
protected:
/** Constructor to be privately used by Importer */
RemoveRedundantMatsProcess();
/** Destructor, private as well */
~RemoveRedundantMatsProcess();
public:

View File

@ -54,14 +54,9 @@ namespace Assimp {
*/
class ASSIMP_API RemoveVCProcess : public BaseProcess
{
friend class Importer;
friend class ::RemoveVCProcessTest;
public:
protected:
/** Constructor to be privately used by Importer */
RemoveVCProcess();
/** Destructor, private as well */
~RemoveVCProcess();
public:

View File

@ -172,15 +172,11 @@ struct Bone
*/
class SMDImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
SMDImporter();
/** Destructor, private as well */
~SMDImporter();
public:
// -------------------------------------------------------------------

View File

@ -54,15 +54,11 @@ namespace Assimp {
*/
class STLImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
STLImporter();
/** Destructor, private as well */
~STLImporter();
public:
// -------------------------------------------------------------------

View File

@ -882,7 +882,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
// ------------------------------------------------------------------------------------------------
template <typename Type>
inline void CopyPtrArray (Type**& dest, Type** src, unsigned int num)
inline void CopyPtrArray (Type**& dest, const Type* const * src, unsigned int num)
{
if (!num)
{
@ -890,8 +890,9 @@ inline void CopyPtrArray (Type**& dest, Type** src, unsigned int num)
return;
}
dest = new Type*[num];
for (unsigned int i = 0; i < num;++i)
for (unsigned int i = 0; i < num;++i) {
SceneCombiner::Copy(&dest[i],src[i]);
}
}
// ------------------------------------------------------------------------------------------------
@ -906,7 +907,7 @@ inline void GetArrayCopy (Type*& dest, unsigned int num )
}
// ------------------------------------------------------------------------------------------------
void SceneCombiner::CopySceneFlat(aiScene** _dest,aiScene* src)
void SceneCombiner::CopySceneFlat(aiScene** _dest,const aiScene* src)
{
// reuse the old scene or allocate a new?
if (*_dest)(*_dest)->~aiScene();
@ -916,7 +917,7 @@ void SceneCombiner::CopySceneFlat(aiScene** _dest,aiScene* src)
}
// ------------------------------------------------------------------------------------------------
void SceneCombiner::CopyScene(aiScene** _dest,aiScene* src)
void SceneCombiner::CopyScene(aiScene** _dest,const aiScene* src)
{
ai_assert(NULL != _dest && NULL != src);

View File

@ -303,7 +303,7 @@ public:
* @param dest Receives a pointer to the destination scene
* @param src Source scene - remains unmodified.
*/
static void CopyScene(aiScene** dest,aiScene* source);
static void CopyScene(aiScene** dest,const aiScene* source);
// -------------------------------------------------------------------
@ -316,7 +316,7 @@ public:
* @param dest Receives a pointer to the destination scene
* @param src Source scene - remains unmodified.
*/
static void CopySceneFlat(aiScene** dest,aiScene* source);
static void CopySceneFlat(aiScene** dest,const aiScene* source);
// -------------------------------------------------------------------

View File

@ -0,0 +1,70 @@
/*
Open Asset Import Library (ASSIMP)
----------------------------------------------------------------------
Copyright (c) 2006-2010, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file Stuff to deal with aiScene::mPrivate
*/
#ifndef AI_SCENEPRIVATE_H_INCLUDED
#define AI_SCENEPRIVATE_H_INCLUDED
namespace Assimp {
struct ScenePrivateData {
ScenePrivateData()
: mPPStepsApplied()
{}
// List of postprocessing steps already applied to the scene.
unsigned int mPPStepsApplied;
};
// Access private data stored in the scene
inline ScenePrivateData* ScenePriv(aiScene* in) {
return static_cast<ScenePrivateData*>(in->mPrivate);
}
inline const ScenePrivateData* ScenePriv(const aiScene* in) {
return static_cast<const ScenePrivateData*>(in->mPrivate);
}
}
#endif

View File

@ -57,14 +57,9 @@ namespace Assimp {
*/
class ASSIMP_API SortByPTypeProcess : public BaseProcess
{
friend class Importer;
friend class ::SortByPTypeProcessTest; // grant the unit test full access to us
public:
protected:
/** Constructor to be privately used by Importer */
SortByPTypeProcess();
/** Destructor, private as well */
~SortByPTypeProcess();
public:

View File

@ -61,13 +61,9 @@ namespace Assimp
*/
class ASSIMP_API SplitByBoneCountProcess : public BaseProcess
{
friend class Importer;
public:
protected:
/** Constructor to be privately used by Importer */
SplitByBoneCountProcess();
/** Destructor, private as well */
~SplitByBoneCountProcess();
public:

View File

@ -83,15 +83,11 @@ class SplitLargeMeshesProcess_Vertex;
*/
class ASSIMP_API SplitLargeMeshesProcess_Triangle : public BaseProcess
{
friend class Importer;
friend class SplitLargeMeshesProcess_Vertex;
friend class ::SplitLargeMeshesTest;
protected:
/** Constructor to be privately used by Importer */
public:
SplitLargeMeshesProcess_Triangle();
/** Destructor, private as well */
~SplitLargeMeshesProcess_Triangle();
public:
@ -155,14 +151,9 @@ public:
*/
class ASSIMP_API SplitLargeMeshesProcess_Vertex : public BaseProcess
{
friend class Importer;
friend class ::SplitLargeMeshesTest;
public:
protected:
/** Constructor to be privately used by Importer */
SplitLargeMeshesProcess_Vertex();
/** Destructor, private as well */
~SplitLargeMeshesProcess_Vertex();
public:

View File

@ -69,15 +69,11 @@ namespace Assimp {
*/
class TerragenImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
TerragenImporter();
/** Destructor, private as well */
~TerragenImporter();
public:
// -------------------------------------------------------------------

View File

@ -195,6 +195,8 @@ public:
TextureTransformStep();
~TextureTransformStep();
public:
// -------------------------------------------------------------------
bool IsActive( unsigned int pFlags) const;

View File

@ -59,14 +59,9 @@ namespace Assimp
*/
class ASSIMP_API TriangulateProcess : public BaseProcess
{
friend class Importer;
friend class ::TriangulateProcessTest; // grant the unit test full access to us
public:
protected:
/** Constructor to be privately used by Importer */
TriangulateProcess();
/** Destructor, private as well */
~TriangulateProcess();
public:

View File

@ -145,15 +145,11 @@ inline void DecompressVertex(aiVector3D& v, int32_t in)
*/
class UnrealImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
UnrealImporter();
/** Destructor, private as well */
~UnrealImporter();
public:
// -------------------------------------------------------------------

View File

@ -64,13 +64,9 @@ namespace Assimp {
// --------------------------------------------------------------------------------------
class ASSIMP_API ValidateDSProcess : public BaseProcess
{
friend class Importer;
public:
protected:
/** Constructor to be privately used by Importer */
ValidateDSProcess();
/** Destructor, private as well */
~ValidateDSProcess();
public:

View File

@ -66,15 +66,11 @@ struct Node;
*/
class XFileImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
public:
XFileImporter();
/** Destructor, private as well */
~XFileImporter();
public:
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.

File diff suppressed because it is too large Load Diff

View File

@ -327,59 +327,11 @@ struct aiScene
#ifdef __cplusplus
//! Default constructor
aiScene()
{
// set all members to zero by default
mRootNode = NULL;
mNumMeshes = 0; mMeshes = NULL;
mNumMaterials = 0; mMaterials = NULL;
mNumAnimations = 0; mAnimations = NULL;
mNumTextures = 0; mTextures = NULL;
mNumCameras = 0; mCameras = NULL;
mNumLights = 0; mLights = NULL;
mFlags = 0;
}
//! Default constructor - set everything to 0/NULL
aiScene();
//! Destructor
~aiScene()
{
// delete all sub-objects recursively
delete mRootNode;
// To make sure we won't crash if the data is invalid it's
// much better to check whether both mNumXXX and mXXX are
// valid instead of relying on just one of them.
if (mNumMeshes && mMeshes)
for( unsigned int a = 0; a < mNumMeshes; a++)
delete mMeshes[a];
delete [] mMeshes;
if (mNumMaterials && mMaterials)
for( unsigned int a = 0; a < mNumMaterials; a++)
delete mMaterials[a];
delete [] mMaterials;
if (mNumAnimations && mAnimations)
for( unsigned int a = 0; a < mNumAnimations; a++)
delete mAnimations[a];
delete [] mAnimations;
if (mNumTextures && mTextures)
for( unsigned int a = 0; a < mNumTextures; a++)
delete mTextures[a];
delete [] mTextures;
if (mNumLights && mLights)
for( unsigned int a = 0; a < mNumLights; a++)
delete mLights[a];
delete [] mLights;
if (mNumCameras && mCameras)
for( unsigned int a = 0; a < mNumCameras; a++)
delete mCameras[a];
delete [] mCameras;
}
~aiScene();
//! Check whether the scene contains meshes
//! Unless no special scene flags are set this will always be true.
@ -408,6 +360,15 @@ struct aiScene
{ return mAnimations != NULL && mNumAnimations > 0; }
#endif // __cplusplus
// internal scene data, do not touch
#ifdef __cplusplus
void* mPrivate;
#else
char* mPrivate;
#endif
};
#ifdef __cplusplus

View File

@ -136,15 +136,38 @@ struct aiExportDataBlob
// --------------------------------------------------------------------------------
/** Exports the given scene to a chosen file format and writes the result file(s) to disk.
* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function.
* The scene is expected to conform to Assimp's Importer output format as specified
* in the @link data Data Structures Page @endlink. In short, this means the model data
* should use a right-handed coordinate systems, face winding should be counter-clockwise
* and the UV coordinate origin is assumed to be in the upper left. If your input data
* uses different conventions, have a look at the last parameter.
* @param pFormatId ID string to specify to which format you want to export to. Use
* aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available.
* @param pFileName Output file to write
* @param pIO custom IO implementation to be used. Use this if you use your own storage methods.
* If none is supplied, a default implementation using standard file IO is used. Note that
* #aiExportSceneToBlob is provided as convienience function to export to memory buffers.
* #aiExportSceneToBlob is provided as convenience function to export to memory buffers.
* @param pPreprocessing Accepts any choice of the #aiPostProcessing enumerated
* flags, but in reality only a subset of them makes sense here. Specifying
* 'preprocessing' flags is useful if the input scene does not conform to
* Assimp's default conventions as specified in the @link data Data Structures Page @endlink.
* In short, this means the geometry data should use a right-handed coordinate systems, face
* winding should be counter-clockwise and the UV coordinate origin is assumed to be in
* the upper left. The #aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and
* #aiProcess_FlipWindingOrder flags are used in the import side to allow users
* to have those defaults automatically adapted to their conventions. Specifying those flags
* for exporting has the opposite effect, respectively. Some other of the
* #aiPostProcessSteps enumerated values may be useful as well, but you'll need
* to try out what their effect on the exported file is. Many formats impose
* their own restrictions on the structure of the geometry stored therein,
* so some preprocessing may have little or no effect at all, or may be
* redundant as exporters would apply them anyhow. A good example
* is triangulation - whilst you can enforce it by specifying
* the #aiProcess_Triangulate flag, most export formats support only
* triangulate data so they would run the step even if it wasn't requested.
* @return a status code indicating the result of the export
*/
ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, const char* pFormatId, const char* pFileName);
ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing);
// --------------------------------------------------------------------------------
@ -156,9 +179,10 @@ ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, const char* p
* @param pIO custom IO implementation to be used. Use this if you use your own storage methods.
* If none is supplied, a default implementation using standard file IO is used. Note that
* #aiExportSceneToBlob is provided as convienience function to export to memory buffers.
* @param pPreprocessing Please see the documentation for #aiExportScene
* @return a status code indicating the result of the export
*/
ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene, const char* pFormatId, const char* pFileName, C_STRUCT aiFileIO* pIO );
ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene, const char* pFormatId, const char* pFileName, C_STRUCT aiFileIO* pIO, unsigned int pPreprocessing );
// --------------------------------------------------------------------------------
/** Exports the given scene to a chosen file format. Returns the exported data as a binary blob which
@ -167,9 +191,10 @@ ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene, const char*
* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function.
* @param pFormatId ID string to specify to which format you want to export to. Use
* aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available.
* @param pPreprocessing Please see the documentation for #aiExportScene
* @return the exported data or NULL in case of error
*/
ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT aiScene* pScene, const char* pFormatId );
ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing );

View File

@ -134,12 +134,13 @@ public:
* export to. Use
* #GetExportFormatCount / #GetExportFormatDescription to learn which
* export formats are available.
* @param pPreprocessing See the documentation for #Export
* @return the exported data or NULL in case of error.
* @note If the Exporter instance did already hold a blob from
* a previous call to #ExportToBlob, it will be disposed.
* Any IO handlers set via #SetIOHandler are ignored here.*/
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId );
inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId );
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u );
inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u );
// -------------------------------------------------------------------
@ -148,9 +149,27 @@ public:
* about the output data flow of the export process.
* @param pBlob A data blob obtained from a previous call to #aiExportScene. Must not be NULL.
* @param pPath Full target file name. Target must be accessible.
* @param pPreprocessing Accepts any choice of the #aiPostProcessing enumerated
* flags, but in reality only a subset of them makes sense here. Specifying
* 'preprocessing' flags is useful if the input scene does not conform to
* Assimp's default conventions as specified in the @link data Data Structures Page @endlink.
* In short, this means the geometry data should use a right-handed coordinate systems, face
* winding should be counter-clockwise and the UV coordinate origin is assumed to be in
* the upper left. The #aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and
* #aiProcess_FlipWindingOrder flags are used in the import side to allow users
* to have those defaults automatically adapted to their conventions. Specifying those flags
* for exporting has the opposite effect, respectively. Some other of the
* #aiPostProcessSteps enumerated values may be useful as well, but you'll need
* to try out what their effect on the exported file is. Many formats impose
* their own restrictions on the structure of the geometry stored therein,
* so some preprocessing may have little or no effect at all, or may be
* redundant as exporters would apply them anyhow. A good example
* is triangulation - whilst you can enforce it by specifying
* the #aiProcess_Triangulate flag, most export formats support only
* triangulate data so they would run the step even if it wasn't requested.
* @return AI_SUCCESS if everything was fine. */
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath );
inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath );
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u);
inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u);
@ -192,15 +211,15 @@ protected:
// ----------------------------------------------------------------------------------
inline const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const std::string& pFormatId )
inline const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const std::string& pFormatId,unsigned int pPreprocessing )
{
return ExportToBlob(pScene,pFormatId.c_str());
return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing);
}
// ----------------------------------------------------------------------------------
inline aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath )
inline aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing )
{
return Export(pScene,pFormatId.c_str(),pPath.c_str());
return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing);
}
} // namespace Assimp

File diff suppressed because it is too large Load Diff