Refactoring ... added documentation, simplified some parts of the code and migrated some class declarations in separate files.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@100 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2008-08-08 18:34:14 +00:00
parent 333f0c805e
commit 6fe8c867e8
18 changed files with 285 additions and 167 deletions

View File

@ -473,7 +473,7 @@ void ASEImporter::BuildNodes()
aiNode* pcNode = new aiNode(); aiNode* pcNode = new aiNode();
pcNode->mParent = pcScene->mRootNode; pcNode->mParent = pcScene->mRootNode;
pcNode->mName.Set(szMyName[1]); pcNode->mName.Set(szMyName[1]);
this->AddNodes(pcScene,pcNode,pcNode->mName.data); this->AddNodes(pcNode,pcNode->mName.data);
apcNodes.push_back(pcNode); apcNodes.push_back(pcNode);
} }
pcScene->mRootNode->mChildren = new aiNode*[apcNodes.size()]; pcScene->mRootNode->mChildren = new aiNode*[apcNodes.size()];

View File

@ -184,7 +184,7 @@ void aiGetExtensionList(aiString* szOut)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn, void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
C_STRUCT aiMemoryInfo* in); C_STRUCT aiMemoryInfo* in)
{ {
// lock the mutex // lock the mutex
#if (defined AI_C_THREADSAFE) #if (defined AI_C_THREADSAFE)
@ -198,7 +198,7 @@ void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
{ {
DefaultLogger::get()->error("Unable to find the Importer instance for this scene. " DefaultLogger::get()->error("Unable to find the Importer instance for this scene. "
"Are you sure it has been created by aiImportFile(ex)(...)?"); "Are you sure it has been created by aiImportFile(ex)(...)?");
return 0; return;
} }
// get memory statistics // get memory statistics
it->second->GetMemoryRequirements(*in); it->second->GetMemoryRequirements(*in);

View File

@ -39,9 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
/** @file Implementation of the few default functions of the base importer class */ /** @file Implementation of BaseImporter */
#include "BaseImporter.h" #include "BaseImporter.h"
#include "BaseProcess.h"
#include "../include/DefaultLogger.h" #include "../include/DefaultLogger.h"
#include "../include/aiScene.h" #include "../include/aiScene.h"
@ -68,7 +67,7 @@ BaseImporter::~BaseImporter()
aiScene* BaseImporter::ReadFile( const std::string& pFile, IOSystem* pIOHandler) aiScene* BaseImporter::ReadFile( const std::string& pFile, IOSystem* pIOHandler)
{ {
// create a scene object to hold the data // create a scene object to hold the data
aiScene* scene = new aiScene; aiScene* scene = new aiScene();
// dispatch importing // dispatch importing
try try
@ -93,26 +92,8 @@ aiScene* BaseImporter::ReadFile( const std::string& pFile, IOSystem* pIOHandler)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void BaseProcess::ExecuteOnScene( Importer* pImp) void BaseImporter::SetupProperties(const Importer* pImp)
{ {
ai_assert(NULL != pImp && NULL != pImp->mScene); // the default implementation does nothing
// catch exceptions thrown inside the PostProcess-Step
try
{
this->Execute(pImp->mScene);
} catch( ImportErrorException* exception)
{
// extract error description
pImp->mErrorString = exception->GetErrorText();
DefaultLogger::get()->error(pImp->mErrorString);
delete exception;
// and kill the partially imported data
delete pImp->mScene;
pImp->mScene = NULL;
}
} }

View File

@ -137,6 +137,14 @@ public:
inline const std::string& GetErrorText() const inline const std::string& GetErrorText() const
{ return mErrorText; } { return mErrorText; }
// -------------------------------------------------------------------
/** Called prior to ReadFile().
* The function is a request to the importer to update its configuration
* basing on the Importer's configuration property list.
*/
virtual void SetupProperties(const Importer* pImp);
protected: protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------

View File

@ -0,0 +1,94 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, 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 Implementation of BaseProcess */
#include "BaseImporter.h"
#include "BaseProcess.h"
#include "../include/DefaultLogger.h"
#include "../include/aiScene.h"
#include "../include/aiAssert.h"
#include "../include/assimp.hpp"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
BaseProcess::BaseProcess()
{
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
BaseProcess::~BaseProcess()
{
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
void BaseProcess::ExecuteOnScene( Importer* pImp)
{
ai_assert(NULL != pImp && NULL != pImp->mScene);
// catch exceptions thrown inside the PostProcess-Step
try
{
this->Execute(pImp->mScene);
} catch( ImportErrorException* exception)
{
// extract error description
pImp->mErrorString = exception->GetErrorText();
DefaultLogger::get()->error(pImp->mErrorString);
delete exception;
// and kill the partially imported data
delete pImp->mScene;
pImp->mScene = NULL;
}
}
// ------------------------------------------------------------------------------------------------
void BaseProcess::SetupProperties(const Importer* pImp)
{
// the default implementation does nothing
}

View File

@ -53,17 +53,19 @@ namespace Assimp
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** The BaseProcess defines a common interface for all post processing steps. /** The BaseProcess defines a common interface for all post processing steps.
* A post processing step is run after a successful import if the caller * A post processing step is run after a successful import if the caller
* specified the corresponding flag when calling ReadFile(). Enum #aiPostProcessSteps * specified the corresponding flag when calling ReadFile().
* defines which flags are available. * Enum #aiPostProcessSteps defines which flags are available.
* After a successful import the Importer iterates over its internal array of processes * After a successful import the Importer iterates over its internal array
* and calls IsActive() on each process to evaluate if the step should be executed. * of processes and calls IsActive() on each process to evaluate if the step
* If the function returns true, the class' Execute() function is called subsequently. * should be executed. If the function returns true, the class' Execute()
* function is called subsequently.
*/ */
class ASSIMP_API BaseProcess class ASSIMP_API BaseProcess
{ {
friend class Importer; friend class Importer;
public: public:
/** Constructor to be privately used by Importer */ /** Constructor to be privately used by Importer */
BaseProcess(); BaseProcess();
@ -71,11 +73,13 @@ public:
virtual ~BaseProcess(); virtual ~BaseProcess();
public: public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns whether the processing step is present in the given flag field. /** Returns whether the processing step is present in the given flag.
* @param pFlags The processing flags the importer was called with. A bitwise * @param pFlags The processing flags the importer was called with. A
* combination of #aiPostProcessSteps. * bitwise combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not. * @return true if the process is present in this flag fields,
* false if not.
*/ */
virtual bool IsActive( unsigned int pFlags) const = 0; virtual bool IsActive( unsigned int pFlags) const = 0;
@ -87,6 +91,13 @@ public:
*/ */
void ExecuteOnScene( Importer* pImp); void ExecuteOnScene( Importer* pImp);
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
virtual void SetupProperties(const Importer* pImp);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Executes the post processing step on the given imported data. /** Executes the post processing step on the given imported data.
* A process should throw an ImportErrorException* if it fails. * A process should throw an ImportErrorException* if it fails.
@ -96,15 +107,6 @@ public:
virtual void Execute( aiScene* pScene) = 0; virtual void Execute( aiScene* pScene) = 0;
}; };
/** Constructor, dummy implementation to keep the compiler from complaining */
inline BaseProcess::BaseProcess()
{
}
/** Destructor */
inline BaseProcess::~BaseProcess()
{
}
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -100,9 +100,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if (!defined AI_BUILD_NO_MD5_IMPORTER) #if (!defined AI_BUILD_NO_MD5_IMPORTER)
# include "MD5Loader.h" # include "MD5Loader.h"
#endif #endif
#if (!defined AI_BUILD_NO_MD5_IMPORTER)
# include "MD5Loader.h"
#endif
#if (!defined AI_BUILD_NO_STL_IMPORTER) #if (!defined AI_BUILD_NO_STL_IMPORTER)
# include "STLLoader.h" # include "STLLoader.h"
#endif #endif
@ -266,21 +263,6 @@ Importer::Importer() :
#if (!defined AI_BUILD_NO_IMPROVECACHELOCALITY_PROCESS) #if (!defined AI_BUILD_NO_IMPROVECACHELOCALITY_PROCESS)
mPostProcessingSteps.push_back( new ImproveCacheLocalityProcess()); mPostProcessingSteps.push_back( new ImproveCacheLocalityProcess());
#endif #endif
//// store the *this* pointer in all BaseImporter instances
//for (std::vector<BaseImporter*>::iterator
// i = mImporter.begin();
// i != mImporter.end();++i)
//{
// (**i).mImporter = this;
//}
//// store the *this* pointer in all BaseProcess instances
//for (std::vector<BaseProcess*>::iterator
// i = mPostProcessingSteps.begin();
// i != mPostProcessingSteps.end();++i)
//{
// (**i).mImporter = this;
//}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -327,6 +309,7 @@ bool Importer::IsDefaultIOHandler()
{ {
return mIsDefaultHandler; return mIsDefaultHandler;
} }
#ifdef _DEBUG
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Validate post process step flags // Validate post process step flags
bool ValidateFlags(unsigned int pFlags) bool ValidateFlags(unsigned int pFlags)
@ -341,6 +324,7 @@ bool ValidateFlags(unsigned int pFlags)
return true; return true;
} }
#endif // ! DEBUG
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Reads the given file and returns its contents if successful. // Reads the given file and returns its contents if successful.
const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags) const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags)
@ -384,11 +368,13 @@ const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags
} }
// dispatch the reading to the worker class for this format // dispatch the reading to the worker class for this format
imp->SetupProperties( this );
mScene = imp->ReadFile( pFile, mIOHandler); mScene = imp->ReadFile( pFile, mIOHandler);
// if successful, apply all active post processing steps to the imported data // if successful, apply all active post processing steps to the imported data
if( mScene) if( mScene)
{ {
#ifdef _DEBUG
if (bExtraVerbose) if (bExtraVerbose)
{ {
pFlags |= aiProcess_ValidateDataStructure; pFlags |= aiProcess_ValidateDataStructure;
@ -397,15 +383,17 @@ const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags
// TODO: temporary solution, clean up later // TODO: temporary solution, clean up later
mScene->mFlags |= 0x80000000; mScene->mFlags |= 0x80000000;
} }
#endif // ! DEBUG
for( unsigned int a = 0; a < mPostProcessingSteps.size(); a++) for( unsigned int a = 0; a < mPostProcessingSteps.size(); a++)
{ {
BaseProcess* process = mPostProcessingSteps[a]; BaseProcess* process = mPostProcessingSteps[a];
if( process->IsActive( pFlags)) if( process->IsActive( pFlags))
{ {
process->SetupProperties( this );
process->ExecuteOnScene ( this ); process->ExecuteOnScene ( this );
} }
if( !mScene)break; // error string has already been set ... if( !mScene)break;
#ifdef _DEBUG
// if the extra verbose mode is active execute the // if the extra verbose mode is active execute the
// VaidateDataStructureStep again after each step // VaidateDataStructureStep again after each step
if (bExtraVerbose && a) if (bExtraVerbose && a)
@ -415,18 +403,18 @@ const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags
if( !mScene) if( !mScene)
{ {
DefaultLogger::get()->error("Extra verbose: failed to revalidate data structures"); DefaultLogger::get()->error("Extra verbose: failed to revalidate data structures");
break; // error string has already been set ... break;
} }
} }
#endif // ! DEBUG
} }
#ifdef _DEBUG
if (bExtraVerbose)mScene->mFlags &= ~0x80000000; if (bExtraVerbose)mScene->mFlags &= ~0x80000000;
#endif // ! DEBUG
} }
// if failed, extract the error string // if failed, extract the error string
else if( !mScene) else if( !mScene)mErrorString = imp->GetErrorText();
{
mErrorString = imp->GetErrorText();
}
// either successful or failure - the pointer expresses it anyways // either successful or failure - the pointer expresses it anyways
return mScene; return mScene;
@ -497,7 +485,7 @@ int Importer::SetProperty(const char* szName, int iValue)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Get a configuration property // Get a configuration property
int Importer::GetProperty(const char* szName, int Importer::GetProperty(const char* szName,
int iErrorReturn /*= 0xffffffff*/) int iErrorReturn /*= 0xffffffff*/) const
{ {
ai_assert(NULL != szName); ai_assert(NULL != szName);

View File

@ -49,29 +49,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/aiMesh.h" #include "../include/aiMesh.h"
#include "../include/aiScene.h" #include "../include/aiScene.h"
#include "../include/aiAssert.h" #include "../include/aiAssert.h"
#include "../include/assimp.hpp"
#include "../include/DefaultLogger.h" #include "../include/DefaultLogger.h"
using namespace Assimp; using namespace Assimp;
/*static*/ unsigned int LimitBoneWeightsProcess::mMaxWeights = AI_LMW_MAX_WEIGHTS;
extern "C" {
// ------------------------------------------------------------------------------------------------
aiReturn aiSetBoneWeightLimit(unsigned int pLimit)
{
if (0 == pLimit)
{
LimitBoneWeightsProcess::mMaxWeights = 0xFFFFFFFF;
return AI_FAILURE;
}
LimitBoneWeightsProcess::mMaxWeights = pLimit;
DefaultLogger::get()->debug("aiSetBoneWeightLimit() - bone weight limit was changed");
return AI_SUCCESS;
}
};
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
LimitBoneWeightsProcess::LimitBoneWeightsProcess() LimitBoneWeightsProcess::LimitBoneWeightsProcess()
@ -100,6 +83,18 @@ void LimitBoneWeightsProcess::Execute( aiScene* pScene)
ProcessMesh( pScene->mMeshes[a]); ProcessMesh( pScene->mMeshes[a]);
} }
// ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data.
void LimitBoneWeightsProcess::SetupProperties(const Importer* pImp)
{
// get the current value of the property
if(0xffffffff == (this->mMaxWeights = pImp->GetProperty(
AI_CONFIG_PP_LBW_MAX_WEIGHTS,0xffffffff)))
{
this->mMaxWeights = AI_LMW_MAX_WEIGHTS;
}
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Unites identical vertices in the given mesh // Unites identical vertices in the given mesh
void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh) void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh)

View File

@ -91,35 +91,53 @@ public:
bool IsActive( unsigned int pFlags) const; bool IsActive( unsigned int pFlags) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Executes the post processing step on the given imported data. /** Called prior to ExecuteOnScene().
* At the moment a process is not supposed to fail. * The function is a request to the process to update its configuration
* @param pScene The imported data to work at. * basing on the Importer's configuration property list.
*/ */
void Execute( aiScene* pScene); virtual void SetupProperties(const Importer* pImp);
protected: protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Limits the bone weight count for all vertices in the given mesh. /** Limits the bone weight count for all vertices in the given mesh.
* @param pMesh The mesh to process. * @param pMesh The mesh to process.
*/ */
void ProcessMesh( aiMesh* pMesh); void ProcessMesh( aiMesh* pMesh);
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
protected: protected:
// -------------------------------------------------------------------
/** Describes a bone weight on a vertex */ /** Describes a bone weight on a vertex */
struct Weight struct Weight
{ {
unsigned int mBone; ///< Index of the bone unsigned int mBone; ///< Index of the bone
float mWeight; ///< Weight of that bone on this vertex float mWeight; ///< Weight of that bone on this vertex
Weight() { } Weight() { }
Weight( unsigned int pBone, float pWeight) { mBone = pBone; mWeight = pWeight; } Weight( unsigned int pBone, float pWeight)
{
mBone = pBone;
mWeight = pWeight;
}
/** Comparision operator to sort bone weights by descending weight */ /** Comparision operator to sort bone weights by descending weight */
bool operator < (const Weight& pWeight) const { return mWeight > pWeight.mWeight; } bool operator < (const Weight& pWeight) const
{
return mWeight > pWeight.mWeight;
}
}; };
public: public:
/** Maximum number of bones influencing any single vertex. */ /** Maximum number of bones influencing any single vertex. */
static unsigned int mMaxWeights; unsigned int mMaxWeights;
}; };
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -105,6 +105,18 @@ bool SMDImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
return true; return true;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Setup configuration properties
void SMDImporter::SetupProperties(const Importer* pImp)
{
// The AI_CONFIG_IMPORT_SMD_KEYFRAME option overrides the
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
if(0xffffffff == (this->configFrameID = pImp->GetProperty(
AI_CONFIG_IMPORT_SMD_KEYFRAME,0xffffffff)))
{
this->configFrameID = pImp->GetProperty(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
}
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure. // Imports the given file into the given scene structure.
void SMDImporter::InternReadFile( void SMDImporter::InternReadFile(
const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
@ -139,15 +151,6 @@ void SMDImporter::InternReadFile(
// reserve enough space for ... hm ... 20 bones // reserve enough space for ... hm ... 20 bones
this->asBones.reserve(20); this->asBones.reserve(20);
// The AI_CONFIG_IMPORT_SMD_KEYFRAME option overrides the
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
if(0xffffffff == (this->configFrameID = this->mImporter->GetProperty(
AI_CONFIG_IMPORT_SMD_KEYFRAME,0xffffffff)))
{
this->configFrameID = this->mImporter->GetProperty(
AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
}
try try
{ {
// parse the file ... // parse the file ...

View File

@ -189,6 +189,13 @@ public:
* See BaseImporter::CanRead() for details. */ * See BaseImporter::CanRead() for details. */
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const; bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
// -------------------------------------------------------------------
/** Called prior to ReadFile().
* The function is a request to the importer to update its configuration
* basing on the Importer's configuration property list.
*/
void SetupProperties(const Importer* pImp);
protected: protected:

View File

@ -46,41 +46,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/aiPostProcess.h" #include "../include/aiPostProcess.h"
#include "../include/aiMesh.h" #include "../include/aiMesh.h"
#include "../include/aiScene.h" #include "../include/aiScene.h"
#include "../include/assimp.hpp"
using namespace Assimp; using namespace Assimp;
/*static*/ unsigned int SplitLargeMeshesProcess_Triangle::LIMIT = AI_SLM_DEFAULT_MAX_TRIANGLES;
/*static*/ unsigned int SplitLargeMeshesProcess_Vertex::LIMIT = AI_SLM_DEFAULT_MAX_VERTICES;
extern "C" {
// ------------------------------------------------------------------------------------------------
aiReturn aiSetVertexSplitLimit(unsigned int pLimit)
{
if (0 == pLimit)
{
SplitLargeMeshesProcess_Vertex::LIMIT = 0xFFFFFFFF;
return AI_FAILURE;
}
SplitLargeMeshesProcess_Vertex::LIMIT = pLimit;
DefaultLogger::get()->debug("aiSetVertexSplitLimit() - vertex split limit was changed");
return AI_SUCCESS;
}
// ------------------------------------------------------------------------------------------------
aiReturn aiSetTriangleSplitLimit(unsigned int pLimit)
{
if (0 == pLimit)
{
SplitLargeMeshesProcess_Triangle::LIMIT = 0xFFFFFFFF;
return AI_FAILURE;
}
SplitLargeMeshesProcess_Triangle::LIMIT = pLimit;
DefaultLogger::get()->debug("aiSetTriangleSplitLimit() - triangle split limit was changed");
return AI_SUCCESS;
}
}; //! extern "C"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
SplitLargeMeshesProcess_Triangle::SplitLargeMeshesProcess_Triangle() SplitLargeMeshesProcess_Triangle::SplitLargeMeshesProcess_Triangle()
@ -96,12 +66,14 @@ SplitLargeMeshesProcess_Triangle::~SplitLargeMeshesProcess_Triangle()
// Returns whether the processing step is present in the given flag field. // Returns whether the processing step is present in the given flag field.
bool SplitLargeMeshesProcess_Triangle::IsActive( unsigned int pFlags) const bool SplitLargeMeshesProcess_Triangle::IsActive( unsigned int pFlags) const
{ {
return (pFlags & aiProcess_SplitLargeMeshes) != 0 && (0xFFFFFFFF != LIMIT); return (pFlags & aiProcess_SplitLargeMeshes) != 0;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data. // Executes the post processing step on the given imported data.
void SplitLargeMeshesProcess_Triangle::Execute( aiScene* pScene) void SplitLargeMeshesProcess_Triangle::Execute( aiScene* pScene)
{ {
if (0xffffffff == this->LIMIT)return;
DefaultLogger::get()->debug("SplitLargeMeshesProcess_Triangle begin"); DefaultLogger::get()->debug("SplitLargeMeshesProcess_Triangle begin");
std::vector<std::pair<aiMesh*, unsigned int> > avList; std::vector<std::pair<aiMesh*, unsigned int> > avList;
@ -126,6 +98,17 @@ void SplitLargeMeshesProcess_Triangle::Execute( aiScene* pScene)
return; return;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Setup properties
void SplitLargeMeshesProcess_Triangle::SetupProperties( const Importer* pImp)
{
// get the current value of the split property
if(0xcdcdcdcd == (this->LIMIT = pImp->GetProperty(
AI_CONFIG_PP_SLM_TRIANGLE_LIMIT,0xcdcdcdcd)))
{
this->LIMIT = AI_SLM_DEFAULT_MAX_TRIANGLES;
}
}
// ------------------------------------------------------------------------------------------------
// Update a node after some meshes have been split // Update a node after some meshes have been split
void SplitLargeMeshesProcess_Triangle::UpdateNode(aiNode* pcNode, void SplitLargeMeshesProcess_Triangle::UpdateNode(aiNode* pcNode,
const std::vector<std::pair<aiMesh*, unsigned int> >& avList) const std::vector<std::pair<aiMesh*, unsigned int> >& avList)
@ -368,7 +351,7 @@ SplitLargeMeshesProcess_Vertex::~SplitLargeMeshesProcess_Vertex()
// Returns whether the processing step is present in the given flag field. // Returns whether the processing step is present in the given flag field.
bool SplitLargeMeshesProcess_Vertex::IsActive( unsigned int pFlags) const bool SplitLargeMeshesProcess_Vertex::IsActive( unsigned int pFlags) const
{ {
return (pFlags & aiProcess_SplitLargeMeshes) != 0 && (0xFFFFFFFF != LIMIT); return (pFlags & aiProcess_SplitLargeMeshes) != 0;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data. // Executes the post processing step on the given imported data.
@ -376,6 +359,8 @@ void SplitLargeMeshesProcess_Vertex::Execute( aiScene* pScene)
{ {
std::vector<std::pair<aiMesh*, unsigned int> > avList; std::vector<std::pair<aiMesh*, unsigned int> > avList;
if (0xffffffff == this->LIMIT)return;
DefaultLogger::get()->debug("SplitLargeMeshesProcess_Vertex begin"); DefaultLogger::get()->debug("SplitLargeMeshesProcess_Vertex begin");
for( unsigned int a = 0; a < pScene->mNumMeshes; a++) for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
this->SplitMesh(a, pScene->mMeshes[a],avList); this->SplitMesh(a, pScene->mMeshes[a],avList);
@ -398,6 +383,17 @@ void SplitLargeMeshesProcess_Vertex::Execute( aiScene* pScene)
return; return;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Setup properties
void SplitLargeMeshesProcess_Vertex::SetupProperties( const Importer* pImp)
{
// get the current value of the split property
if(0xcdcdcdcd == (this->LIMIT = pImp->GetProperty(
AI_CONFIG_PP_SLM_VERTEX_LIMIT,0xcdcdcdcd)))
{
this->LIMIT = AI_SLM_DEFAULT_MAX_VERTICES;
}
}
// ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data. // Executes the post processing step on the given imported data.
void SplitLargeMeshesProcess_Vertex::SplitMesh( void SplitLargeMeshesProcess_Vertex::SplitMesh(
unsigned int a, unsigned int a,

View File

@ -96,13 +96,25 @@ protected:
public: public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns whether the processing step is present in the given flag field. /** Returns whether the processing step is present in the given flag.
* @param pFlags The processing flags the importer was called with. A bitwise * @param pFlags The processing flags the importer was called with. A
* combination of #aiPostProcessSteps. * bitwise combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not. * @return true if the process is present in this flag fields,
* false if not.
*/ */
bool IsActive( unsigned int pFlags) const; bool IsActive( unsigned int pFlags) const;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
virtual void SetupProperties(const Importer* pImp);
protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Executes the post processing step on the given imported data. /** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail. * At the moment a process is not supposed to fail.
@ -110,20 +122,20 @@ public:
*/ */
void Execute( aiScene* pScene); void Execute( aiScene* pScene);
// -------------------------------------------------------------------
private:
//! Apply the algorithm to a given mesh //! Apply the algorithm to a given mesh
void SplitMesh (unsigned int a, aiMesh* pcMesh, void SplitMesh (unsigned int a, aiMesh* pcMesh,
std::vector<std::pair<aiMesh*, unsigned int> >& avList); std::vector<std::pair<aiMesh*, unsigned int> >& avList);
//! Update a node in the asset after a few of its meshes have been split // -------------------------------------------------------------------
//! Update a node in the asset after a few of its meshes
//! have been split
static void UpdateNode(aiNode* pcNode, static void UpdateNode(aiNode* pcNode,
const std::vector<std::pair<aiMesh*, unsigned int> >& avList); const std::vector<std::pair<aiMesh*, unsigned int> >& avList);
public: public:
//! Triangle limit set via aiSetTriangleSplitLimit() //! Triangle limit
static unsigned int LIMIT; unsigned int LIMIT;
}; };
@ -154,6 +166,15 @@ public:
*/ */
bool IsActive( unsigned int pFlags) const; bool IsActive( unsigned int pFlags) const;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
virtual void SetupProperties(const Importer* pImp);
protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Executes the post processing step on the given imported data. /** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail. * At the moment a process is not supposed to fail.
@ -161,8 +182,7 @@ public:
*/ */
void Execute( aiScene* pScene); void Execute( aiScene* pScene);
private: // -------------------------------------------------------------------
//! Apply the algorithm to a given mesh //! Apply the algorithm to a given mesh
void SplitMesh (unsigned int a, aiMesh* pcMesh, void SplitMesh (unsigned int a, aiMesh* pcMesh,
std::vector<std::pair<aiMesh*, unsigned int> >& avList); std::vector<std::pair<aiMesh*, unsigned int> >& avList);
@ -170,8 +190,8 @@ private:
// NOTE: Reuse SplitLargeMeshesProcess_Triangle::UpdateNode() // NOTE: Reuse SplitLargeMeshesProcess_Triangle::UpdateNode()
public: public:
//! Triangle limit set via aiSetTriangleSplitLimit() //! Triangle limit
static unsigned int LIMIT; unsigned int LIMIT;
}; };
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -154,7 +154,7 @@ public:
* for the requested property is returned! * for the requested property is returned!
* @return Current value of the property * @return Current value of the property
*/ */
int GetProperty(const char* szName, int iErrorReturn = 0xffffffff); int GetProperty(const char* szName, int iErrorReturn = 0xffffffff) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
<attribute name="URI" value="/" /> <attribute name="URI" value="/" />
</containerElement> </containerElement>
</containerInfo> </containerInfo>
<setting name="jarPath" value="J:\Programmieren\ASSIMP\assimp\port\jAssimp\assimp.jar" /> <setting name="jarPath" value="J:\Programmieren\ASSIMP\assimp3\port\jAssimp\assimp.jar" />
<setting name="buildJar" value="true" /> <setting name="buildJar" value="true" />
<setting name="mainClass" value="" /> <setting name="mainClass" value="" />
</component> </component>

View File

@ -52,16 +52,18 @@ package assimp;
*/ */
public class ShadingMode { public class ShadingMode {
private ShadingMode() {}
/** /**
* Flat shading. Shading is done on per-face base, * Flat shading. Shading is done on per-face base,
* diffuse only. * diffuse only.
*/ */
int Flat = 0x1; public static final int Flat = 0x1;
/** /**
* Diffuse gouraud shading. Shading on per-vertex base * Diffuse gouraud shading. Shading on per-vertex base
*/ */
int Gouraud = 0x2; public static final int Gouraud = 0x2;
/** /**
* Diffuse/Specular Phong-Shading * Diffuse/Specular Phong-Shading
@ -69,7 +71,7 @@ public class ShadingMode {
* Shading is applied on per-pixel base. This is the * Shading is applied on per-pixel base. This is the
* slowest algorithm, but generates the best results. * slowest algorithm, but generates the best results.
*/ */
int Phong = 0x3; public static final int Phong = 0x3;
/** /**
* Diffuse/Specular Phong-Blinn-Shading * Diffuse/Specular Phong-Blinn-Shading
@ -78,7 +80,7 @@ public class ShadingMode {
* bit faster than phong and in some cases even * bit faster than phong and in some cases even
* more realistic * more realistic
*/ */
int Blinn = 0x4; public static final int Blinn = 0x4;
/** /**
* Toon-Shading per pixel * Toon-Shading per pixel
@ -86,7 +88,7 @@ public class ShadingMode {
* Shading is applied on per-pixel base. The output looks * Shading is applied on per-pixel base. The output looks
* like a comic. Often combined with edge detection. * like a comic. Often combined with edge detection.
*/ */
int Toon = 0x5; public static final int Toon = 0x5;
/** /**
* OrenNayar-Shading per pixel * OrenNayar-Shading per pixel
@ -94,7 +96,7 @@ public class ShadingMode {
* Extension to standard lambertian shading, taking the * Extension to standard lambertian shading, taking the
* roughness of the material into account * roughness of the material into account
*/ */
int OrenNayar = 0x6; public static final int OrenNayar = 0x6;
/** /**
* Minnaert-Shading per pixel * Minnaert-Shading per pixel
@ -102,15 +104,15 @@ public class ShadingMode {
* Extension to standard lambertian shading, taking the * Extension to standard lambertian shading, taking the
* "darkness" of the material into account * "darkness" of the material into account
*/ */
int Minnaert = 0x7; public static final int Minnaert = 0x7;
/** /**
* CookTorrance-Shading per pixel * CookTorrance-Shading per pixel
*/ */
int CookTorrance = 0x8; public static final int CookTorrance = 0x8;
/** /**
* No shading at all * No shading at all
*/ */
int NoShading = 0x8; public static final int NoShading = 0x8;
} }

View File

@ -49,7 +49,7 @@
<option name="MAXIMUM_HEAP_SIZE" value="128" /> <option name="MAXIMUM_HEAP_SIZE" value="128" />
</component> </component>
<component name="JavadocGenerationManager"> <component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" value="J:/Programmieren/ASSIMP/assimp/doc/javadoc" /> <option name="OUTPUT_DIRECTORY" value="J:/Programmieren/ASSIMP3/assimp/doc/javadoc" />
<option name="OPTION_SCOPE" value="package" /> <option name="OPTION_SCOPE" value="package" />
<option name="OPTION_HIERARCHY" value="true" /> <option name="OPTION_HIERARCHY" value="true" />
<option name="OPTION_NAVIGATOR" value="true" /> <option name="OPTION_NAVIGATOR" value="true" />
@ -178,7 +178,7 @@
</component> </component>
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://J:/Programmieren/ASSIMP/ASSIMP/port/jAssimp/assimp.iml" filepath="J:/Programmieren/ASSIMP/ASSIMP/port/jAssimp/assimp.iml" /> <module fileurl="file://J:/Programmieren/ASSIMP/ASSIMP3/port/jAssimp/assimp.iml" filepath="J:/Programmieren/ASSIMP/ASSIMP3/port/jAssimp/assimp.iml" />
</modules> </modules>
</component> </component>
<component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" /> <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" />

View File

@ -1046,6 +1046,10 @@
RelativePath="..\..\code\BaseImporter.cpp" RelativePath="..\..\code\BaseImporter.cpp"
> >
</File> </File>
<File
RelativePath="..\..\code\BaseProcess.cpp"
>
</File>
<File <File
RelativePath="..\..\code\CalcTangentsProcess.cpp" RelativePath="..\..\code\CalcTangentsProcess.cpp"
> >