FIX: AseLoader is no stateless and can thus be called repeatedly.
Shut up gcc in LWOMaterial.cpp by adding an assertion, not all enumeration values handled. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@625 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
c58dcee5b9
commit
63d6ca8669
|
@ -194,8 +194,9 @@ void ASEImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Copy all scene graph nodes - lights, cameras, dummies and meshes
|
// Copy all scene graph nodes - lights, cameras, dummies and meshes
|
||||||
// into one large array. FIXME: do this during parsing ...
|
// into one huge list.
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
std::vector<BaseNode*> nodes;
|
||||||
nodes.reserve(mParser->m_vMeshes.size() +mParser->m_vLights.size()
|
nodes.reserve(mParser->m_vMeshes.size() +mParser->m_vLights.size()
|
||||||
+ mParser->m_vCameras.size() + mParser->m_vDummies.size());
|
+ mParser->m_vCameras.size() + mParser->m_vDummies.size());
|
||||||
|
|
||||||
|
@ -213,10 +214,10 @@ void ASEImporter::InternReadFile( const std::string& pFile,
|
||||||
end = mParser->m_vDummies.end();it != end; ++it)nodes.push_back(&(*it));
|
end = mParser->m_vDummies.end();it != end; ++it)nodes.push_back(&(*it));
|
||||||
|
|
||||||
// build the final node graph
|
// build the final node graph
|
||||||
BuildNodes();
|
BuildNodes(nodes);
|
||||||
|
|
||||||
// build output animations
|
// build output animations
|
||||||
BuildAnimations();
|
BuildAnimations(nodes);
|
||||||
|
|
||||||
// build output cameras
|
// build output cameras
|
||||||
BuildCameras();
|
BuildCameras();
|
||||||
|
@ -261,10 +262,10 @@ void ASEImporter::GenerateDefaultMaterial()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void ASEImporter::BuildAnimations()
|
void ASEImporter::BuildAnimations(const std::vector<BaseNode*>& nodes)
|
||||||
{
|
{
|
||||||
// check whether we have at least one mesh which has animations
|
// check whether we have at least one mesh which has animations
|
||||||
std::vector<ASE::BaseNode*>::iterator i = nodes.begin();
|
std::vector<ASE::BaseNode*>::const_iterator i = nodes.begin();
|
||||||
unsigned int iNum = 0;
|
unsigned int iNum = 0;
|
||||||
for (;i != nodes.end();++i) {
|
for (;i != nodes.end();++i) {
|
||||||
|
|
||||||
|
@ -425,8 +426,7 @@ void ASEImporter::BuildLights()
|
||||||
pcScene->mNumLights = (unsigned int)mParser->m_vLights.size();
|
pcScene->mNumLights = (unsigned int)mParser->m_vLights.size();
|
||||||
pcScene->mLights = new aiLight*[pcScene->mNumLights];
|
pcScene->mLights = new aiLight*[pcScene->mNumLights];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pcScene->mNumLights;++i)
|
for (unsigned int i = 0; i < pcScene->mNumLights;++i) {
|
||||||
{
|
|
||||||
aiLight* out = pcScene->mLights[i] = new aiLight();
|
aiLight* out = pcScene->mLights[i] = new aiLight();
|
||||||
ASE::Light& in = mParser->m_vLights[i];
|
ASE::Light& in = mParser->m_vLights[i];
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ void ASEImporter::BuildLights()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void ASEImporter::AddNodes(std::vector<BaseNode*>& nodes,
|
void ASEImporter::AddNodes(const std::vector<BaseNode*>& nodes,
|
||||||
aiNode* pcParent,const char* szName)
|
aiNode* pcParent,const char* szName)
|
||||||
{
|
{
|
||||||
aiMatrix4x4 m;
|
aiMatrix4x4 m;
|
||||||
|
@ -521,7 +521,7 @@ void ASEImporter::AddMeshes(const ASE::BaseNode* snode,aiNode* node)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Add child nodes to a given parent node
|
// Add child nodes to a given parent node
|
||||||
void ASEImporter::AddNodes (std::vector<BaseNode*>& nodes,
|
void ASEImporter::AddNodes (const std::vector<BaseNode*>& nodes,
|
||||||
aiNode* pcParent, const char* szName,
|
aiNode* pcParent, const char* szName,
|
||||||
const aiMatrix4x4& mat)
|
const aiMatrix4x4& mat)
|
||||||
{
|
{
|
||||||
|
@ -617,7 +617,7 @@ void ASEImporter::AddNodes (std::vector<BaseNode*>& nodes,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Build the output node graph
|
// Build the output node graph
|
||||||
void ASEImporter::BuildNodes() {
|
void ASEImporter::BuildNodes(std::vector<BaseNode*>& nodes) {
|
||||||
ai_assert(NULL != pcScene);
|
ai_assert(NULL != pcScene);
|
||||||
|
|
||||||
// allocate the one and only root node
|
// allocate the one and only root node
|
||||||
|
@ -1294,7 +1294,7 @@ bool ASEImporter::GenerateNormals(ASE::Mesh& mesh) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The array <EFBFBD>s reused
|
// The array is reused.
|
||||||
ComputeNormalsWithSmoothingsGroups<ASE::Face>(mesh);
|
ComputeNormalsWithSmoothingsGroups<ASE::Face>(mesh);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,15 +53,11 @@ struct aiNode;
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
class MaterialHelper;
|
class MaterialHelper;
|
||||||
|
|
||||||
using namespace ASE;
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
/** Importer class for the 3DS ASE ASCII format
|
/** Importer class for the 3DS ASE ASCII format.
|
||||||
*
|
*
|
||||||
* fixme: consider code cleanup
|
|
||||||
*/
|
*/
|
||||||
class ASEImporter : public BaseImporter
|
class ASEImporter : public BaseImporter {
|
||||||
{
|
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -88,6 +84,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
void GetExtensionList(std::set<std::string>& extensions);
|
void GetExtensionList(std::set<std::string>& extensions);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Imports the given file into the given scene structure.
|
/** Imports the given file into the given scene structure.
|
||||||
* See BaseImporter::InternReadFile() for details
|
* See BaseImporter::InternReadFile() for details
|
||||||
|
@ -95,6 +92,7 @@ protected:
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||||
IOSystem* pIOHandler);
|
IOSystem* pIOHandler);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Called prior to ReadFile().
|
/** Called prior to ReadFile().
|
||||||
* The function is a request to the importer to update its configuration
|
* The function is a request to the importer to update its configuration
|
||||||
|
@ -102,6 +100,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
void SetupProperties(const Importer* pImp);
|
void SetupProperties(const Importer* pImp);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Generate normal vectors basing on smoothing groups
|
/** Generate normal vectors basing on smoothing groups
|
||||||
* (in some cases the normal are already contained in the file)
|
* (in some cases the normal are already contained in the file)
|
||||||
|
@ -110,6 +111,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
bool GenerateNormals(ASE::Mesh& mesh);
|
bool GenerateNormals(ASE::Mesh& mesh);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Create valid vertex/normal/UV/color/face lists.
|
/** Create valid vertex/normal/UV/color/face lists.
|
||||||
* All elements are unique, faces have only one set of indices
|
* All elements are unique, faces have only one set of indices
|
||||||
|
@ -118,42 +120,50 @@ protected:
|
||||||
*/
|
*/
|
||||||
void BuildUniqueRepresentation(ASE::Mesh& mesh);
|
void BuildUniqueRepresentation(ASE::Mesh& mesh);
|
||||||
|
|
||||||
|
|
||||||
/** Create one-material-per-mesh meshes ;-)
|
/** Create one-material-per-mesh meshes ;-)
|
||||||
* \param mesh Mesh to work with
|
* \param mesh Mesh to work with
|
||||||
* \param Receives the list of all created meshes
|
* \param Receives the list of all created meshes
|
||||||
*/
|
*/
|
||||||
void ConvertMeshes(ASE::Mesh& mesh, std::vector<aiMesh*>& avOut);
|
void ConvertMeshes(ASE::Mesh& mesh, std::vector<aiMesh*>& avOut);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Convert a material to a MaterialHelper object
|
/** Convert a material to a MaterialHelper object
|
||||||
* \param mat Input material
|
* \param mat Input material
|
||||||
*/
|
*/
|
||||||
void ConvertMaterial(ASE::Material& mat);
|
void ConvertMaterial(ASE::Material& mat);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Setup the final material indices for each mesh
|
/** Setup the final material indices for each mesh
|
||||||
*/
|
*/
|
||||||
void BuildMaterialIndices();
|
void BuildMaterialIndices();
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Build the node graph
|
/** Build the node graph
|
||||||
*/
|
*/
|
||||||
void BuildNodes();
|
void BuildNodes(std::vector<ASE::BaseNode*>& nodes);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Build output cameras
|
/** Build output cameras
|
||||||
*/
|
*/
|
||||||
void BuildCameras();
|
void BuildCameras();
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Build output lights
|
/** Build output lights
|
||||||
*/
|
*/
|
||||||
void BuildLights();
|
void BuildLights();
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Build output animations
|
/** Build output animations
|
||||||
*/
|
*/
|
||||||
void BuildAnimations();
|
void BuildAnimations(const std::vector<ASE::BaseNode*>& nodes);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Add sub nodes to a node
|
/** Add sub nodes to a node
|
||||||
|
@ -161,10 +171,10 @@ protected:
|
||||||
* \param szName Name of the parent node
|
* \param szName Name of the parent node
|
||||||
* \param matrix Current transform
|
* \param matrix Current transform
|
||||||
*/
|
*/
|
||||||
void AddNodes(std::vector<BaseNode*>& nodes,
|
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
|
||||||
aiNode* pcParent,const char* szName);
|
aiNode* pcParent,const char* szName);
|
||||||
|
|
||||||
void AddNodes(std::vector<BaseNode*>& nodes,
|
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
|
||||||
aiNode* pcParent,const char* szName,
|
aiNode* pcParent,const char* szName,
|
||||||
const aiMatrix4x4& matrix);
|
const aiMatrix4x4& matrix);
|
||||||
|
|
||||||
|
@ -188,8 +198,6 @@ protected:
|
||||||
/** Scene to be filled */
|
/** Scene to be filled */
|
||||||
aiScene* pcScene;
|
aiScene* pcScene;
|
||||||
|
|
||||||
std::vector<BaseNode*> nodes;
|
|
||||||
|
|
||||||
/** Config options: Recompute the normals in every case - WA
|
/** Config options: Recompute the normals in every case - WA
|
||||||
for 3DS Max broken ASE normal export */
|
for 3DS Max broken ASE normal export */
|
||||||
bool configRecomputeNormals;
|
bool configRecomputeNormals;
|
||||||
|
|
|
@ -132,6 +132,8 @@ bool LWOImporter::HandleTextures(MaterialHelper* pcMat, const TextureList& in, a
|
||||||
mapping = aiTextureMapping_UV;
|
mapping = aiTextureMapping_UV;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
ai_assert(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mapping != aiTextureMapping_UV) {
|
if (mapping != aiTextureMapping_UV) {
|
||||||
|
|
Loading…
Reference in New Issue