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
|
||||
// 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()
|
||||
+ 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));
|
||||
|
||||
// build the final node graph
|
||||
BuildNodes();
|
||||
BuildNodes(nodes);
|
||||
|
||||
// build output animations
|
||||
BuildAnimations();
|
||||
BuildAnimations(nodes);
|
||||
|
||||
// build output cameras
|
||||
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
|
||||
std::vector<ASE::BaseNode*>::iterator i = nodes.begin();
|
||||
std::vector<ASE::BaseNode*>::const_iterator i = nodes.begin();
|
||||
unsigned int iNum = 0;
|
||||
for (;i != nodes.end();++i) {
|
||||
|
||||
|
@ -331,13 +332,13 @@ void ASEImporter::BuildAnimations()
|
|||
|
||||
// Allocate the key array and fill it
|
||||
nd->mNumPositionKeys = (unsigned int) me->mTargetAnim.akeyPositions.size();
|
||||
nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys];
|
||||
nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys];
|
||||
|
||||
::memcpy(nd->mPositionKeys,&me->mTargetAnim.akeyPositions[0],
|
||||
nd->mNumPositionKeys * sizeof(aiVectorKey));
|
||||
}
|
||||
|
||||
if (me->mAnim.akeyPositions.size() > 1 || me->mAnim.akeyRotations.size() > 1 || me->mAnim.akeyScaling.size() > 1) {
|
||||
if (me->mAnim.akeyPositions.size() > 1 || me->mAnim.akeyRotations.size() > 1 || me->mAnim.akeyScaling.size() > 1) {
|
||||
// Begin a new node animation channel for this node
|
||||
aiNodeAnim* nd = pcAnim->mChannels[iNum++] = new aiNodeAnim();
|
||||
nd->mNodeName.Set(me->mName);
|
||||
|
@ -347,7 +348,7 @@ void ASEImporter::BuildAnimations()
|
|||
{
|
||||
// Allocate the key array and fill it
|
||||
nd->mNumPositionKeys = (unsigned int) me->mAnim.akeyPositions.size();
|
||||
nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys];
|
||||
nd->mPositionKeys = new aiVectorKey[nd->mNumPositionKeys];
|
||||
|
||||
::memcpy(nd->mPositionKeys,&me->mAnim.akeyPositions[0],
|
||||
nd->mNumPositionKeys * sizeof(aiVectorKey));
|
||||
|
@ -356,7 +357,7 @@ void ASEImporter::BuildAnimations()
|
|||
if (me->mAnim.akeyRotations.size() > 1 ) {
|
||||
// Allocate the key array and fill it
|
||||
nd->mNumRotationKeys = (unsigned int) me->mAnim.akeyRotations.size();
|
||||
nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys];
|
||||
nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys];
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Rotation keys are offsets to the previous keys.
|
||||
|
@ -385,7 +386,7 @@ void ASEImporter::BuildAnimations()
|
|||
if (me->mAnim.akeyScaling.size() > 1 ) {
|
||||
// Allocate the key array and fill it
|
||||
nd->mNumScalingKeys = (unsigned int) me->mAnim.akeyScaling.size();
|
||||
nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys];
|
||||
nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys];
|
||||
|
||||
::memcpy(nd->mScalingKeys,&me->mAnim.akeyScaling[0],
|
||||
nd->mNumScalingKeys * sizeof(aiVectorKey));
|
||||
|
@ -404,7 +405,7 @@ void ASEImporter::BuildCameras()
|
|||
pcScene->mCameras = new aiCamera*[pcScene->mNumCameras];
|
||||
|
||||
for (unsigned int i = 0; i < pcScene->mNumCameras;++i) {
|
||||
aiCamera* out = pcScene->mCameras[i] = new aiCamera();
|
||||
aiCamera* out = pcScene->mCameras[i] = new aiCamera();
|
||||
ASE::Camera& in = mParser->m_vCameras[i];
|
||||
|
||||
// copy members
|
||||
|
@ -425,9 +426,8 @@ void ASEImporter::BuildLights()
|
|||
pcScene->mNumLights = (unsigned int)mParser->m_vLights.size();
|
||||
pcScene->mLights = new aiLight*[pcScene->mNumLights];
|
||||
|
||||
for (unsigned int i = 0; i < pcScene->mNumLights;++i)
|
||||
{
|
||||
aiLight* out = pcScene->mLights[i] = new aiLight();
|
||||
for (unsigned int i = 0; i < pcScene->mNumLights;++i) {
|
||||
aiLight* out = pcScene->mLights[i] = new aiLight();
|
||||
ASE::Light& in = mParser->m_vLights[i];
|
||||
|
||||
// The direction is encoded in the transformation matrix of the node.
|
||||
|
@ -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)
|
||||
{
|
||||
aiMatrix4x4 m;
|
||||
|
@ -521,7 +521,7 @@ void ASEImporter::AddMeshes(const ASE::BaseNode* snode,aiNode* 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,
|
||||
const aiMatrix4x4& mat)
|
||||
{
|
||||
|
@ -617,7 +617,7 @@ void ASEImporter::AddNodes (std::vector<BaseNode*>& nodes,
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Build the output node graph
|
||||
void ASEImporter::BuildNodes() {
|
||||
void ASEImporter::BuildNodes(std::vector<BaseNode*>& nodes) {
|
||||
ai_assert(NULL != pcScene);
|
||||
|
||||
// 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);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -53,15 +53,11 @@ struct aiNode;
|
|||
namespace Assimp {
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
@ -88,6 +84,7 @@ protected:
|
|||
*/
|
||||
void GetExtensionList(std::set<std::string>& extensions);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file into the given scene structure.
|
||||
* See BaseImporter::InternReadFile() for details
|
||||
|
@ -95,6 +92,7 @@ protected:
|
|||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||
IOSystem* pIOHandler);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called prior to ReadFile().
|
||||
* The function is a request to the importer to update its configuration
|
||||
|
@ -102,6 +100,9 @@ protected:
|
|||
*/
|
||||
void SetupProperties(const Importer* pImp);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Generate normal vectors basing on smoothing groups
|
||||
* (in some cases the normal are already contained in the file)
|
||||
|
@ -110,6 +111,7 @@ protected:
|
|||
*/
|
||||
bool GenerateNormals(ASE::Mesh& mesh);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Create valid vertex/normal/UV/color/face lists.
|
||||
* All elements are unique, faces have only one set of indices
|
||||
|
@ -118,42 +120,50 @@ protected:
|
|||
*/
|
||||
void BuildUniqueRepresentation(ASE::Mesh& mesh);
|
||||
|
||||
|
||||
/** Create one-material-per-mesh meshes ;-)
|
||||
* \param mesh Mesh to work with
|
||||
* \param Receives the list of all created meshes
|
||||
*/
|
||||
void ConvertMeshes(ASE::Mesh& mesh, std::vector<aiMesh*>& avOut);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Convert a material to a MaterialHelper object
|
||||
* \param mat Input material
|
||||
*/
|
||||
void ConvertMaterial(ASE::Material& mat);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Setup the final material indices for each mesh
|
||||
*/
|
||||
void BuildMaterialIndices();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Build the node graph
|
||||
*/
|
||||
void BuildNodes();
|
||||
void BuildNodes(std::vector<ASE::BaseNode*>& nodes);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Build output cameras
|
||||
*/
|
||||
void BuildCameras();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Build output lights
|
||||
*/
|
||||
void BuildLights();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Build output animations
|
||||
*/
|
||||
void BuildAnimations();
|
||||
void BuildAnimations(const std::vector<ASE::BaseNode*>& nodes);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Add sub nodes to a node
|
||||
|
@ -161,10 +171,10 @@ protected:
|
|||
* \param szName Name of the parent node
|
||||
* \param matrix Current transform
|
||||
*/
|
||||
void AddNodes(std::vector<BaseNode*>& nodes,
|
||||
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
|
||||
aiNode* pcParent,const char* szName);
|
||||
|
||||
void AddNodes(std::vector<BaseNode*>& nodes,
|
||||
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
|
||||
aiNode* pcParent,const char* szName,
|
||||
const aiMatrix4x4& matrix);
|
||||
|
||||
|
@ -188,8 +198,6 @@ protected:
|
|||
/** Scene to be filled */
|
||||
aiScene* pcScene;
|
||||
|
||||
std::vector<BaseNode*> nodes;
|
||||
|
||||
/** Config options: Recompute the normals in every case - WA
|
||||
for 3DS Max broken ASE normal export */
|
||||
bool configRecomputeNormals;
|
||||
|
|
|
@ -132,6 +132,8 @@ bool LWOImporter::HandleTextures(MaterialHelper* pcMat, const TextureList& in, a
|
|||
mapping = aiTextureMapping_UV;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ai_assert(false);
|
||||
};
|
||||
|
||||
if (mapping != aiTextureMapping_UV) {
|
||||
|
|
Loading…
Reference in New Issue