- untabify obj parser.
- bugfix openddl: latest version Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>pull/502/head
parent
124f408976
commit
c3e2fa0761
File diff suppressed because it is too large
Load Diff
|
@ -64,57 +64,57 @@ struct Model;
|
||||||
class ObjFileImporter : public BaseImporter
|
class ObjFileImporter : public BaseImporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
ObjFileImporter();
|
ObjFileImporter();
|
||||||
|
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
~ObjFileImporter();
|
~ObjFileImporter();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \brief Returns whether the class can handle the format of the given file.
|
/// \brief Returns whether the class can handle the format of the given file.
|
||||||
/// \remark See BaseImporter::CanRead() for details.
|
/// \remark See BaseImporter::CanRead() for details.
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! \brief Appends the supported extension.
|
//! \brief Appends the supported extension.
|
||||||
const aiImporterDesc* GetInfo () const;
|
const aiImporterDesc* GetInfo () const;
|
||||||
|
|
||||||
//! \brief File import implementation.
|
//! \brief File import implementation.
|
||||||
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
||||||
|
|
||||||
//! \brief Create the data from imported content.
|
//! \brief Create the data from imported content.
|
||||||
void CreateDataFromImport(const ObjFile::Model* pModel, aiScene* pScene);
|
void CreateDataFromImport(const ObjFile::Model* pModel, aiScene* pScene);
|
||||||
|
|
||||||
//! \brief Creates all nodes stored in imported content.
|
//! \brief Creates all nodes stored in imported content.
|
||||||
aiNode *createNodes(const ObjFile::Model* pModel, const ObjFile::Object* pData,
|
aiNode *createNodes(const ObjFile::Model* pModel, const ObjFile::Object* pData,
|
||||||
aiNode *pParent, aiScene* pScene, std::vector<aiMesh*> &MeshArray);
|
aiNode *pParent, aiScene* pScene, std::vector<aiMesh*> &MeshArray);
|
||||||
|
|
||||||
//! \brief Creates topology data like faces and meshes for the geometry.
|
//! \brief Creates topology data like faces and meshes for the geometry.
|
||||||
aiMesh *createTopology( const ObjFile::Model* pModel, const ObjFile::Object* pData,
|
aiMesh *createTopology( const ObjFile::Model* pModel, const ObjFile::Object* pData,
|
||||||
unsigned int uiMeshIndex );
|
unsigned int uiMeshIndex );
|
||||||
|
|
||||||
//! \brief Creates vertices from model.
|
//! \brief Creates vertices from model.
|
||||||
void createVertexArray(const ObjFile::Model* pModel, const ObjFile::Object* pCurrentObject,
|
void createVertexArray(const ObjFile::Model* pModel, const ObjFile::Object* pCurrentObject,
|
||||||
unsigned int uiMeshIndex, aiMesh* pMesh,unsigned int uiIdxCount);
|
unsigned int uiMeshIndex, aiMesh* pMesh,unsigned int uiIdxCount);
|
||||||
|
|
||||||
//! \brief Object counter helper method.
|
//! \brief Object counter helper method.
|
||||||
void countObjects(const std::vector<ObjFile::Object*> &rObjects, int &iNumMeshes);
|
void countObjects(const std::vector<ObjFile::Object*> &rObjects, int &iNumMeshes);
|
||||||
|
|
||||||
//! \brief Material creation.
|
//! \brief Material creation.
|
||||||
void createMaterials(const ObjFile::Model* pModel, aiScene* pScene);
|
void createMaterials(const ObjFile::Model* pModel, aiScene* pScene);
|
||||||
void addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode = 1);
|
void addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode = 1);
|
||||||
|
|
||||||
//! \brief Appends a child node to a parent node and updates the data structures.
|
//! \brief Appends a child node to a parent node and updates the data structures.
|
||||||
void appendChildToParentNode(aiNode *pParent, aiNode *pChild);
|
void appendChildToParentNode(aiNode *pParent, aiNode *pChild);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Data buffer
|
//! Data buffer
|
||||||
std::vector<char> m_Buffer;
|
std::vector<char> m_Buffer;
|
||||||
//! Pointer to root object instance
|
//! Pointer to root object instance
|
||||||
ObjFile::Object *m_pRootObject;
|
ObjFile::Object *m_pRootObject;
|
||||||
//! Absolute pathname of model in file system
|
//! Absolute pathname of model in file system
|
||||||
std::string m_strAbsPath;
|
std::string m_strAbsPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -63,76 +63,76 @@ class IOSystem;
|
||||||
class ObjFileParser
|
class ObjFileParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const size_t BUFFERSIZE = 4096;
|
static const size_t BUFFERSIZE = 4096;
|
||||||
typedef std::vector<char> DataArray;
|
typedef std::vector<char> DataArray;
|
||||||
typedef std::vector<char>::iterator DataArrayIt;
|
typedef std::vector<char>::iterator DataArrayIt;
|
||||||
typedef std::vector<char>::const_iterator ConstDataArrayIt;
|
typedef std::vector<char>::const_iterator ConstDataArrayIt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \brief Constructor with data array.
|
/// \brief Constructor with data array.
|
||||||
ObjFileParser(std::vector<char> &Data,const std::string &strModelName, IOSystem* io);
|
ObjFileParser(std::vector<char> &Data,const std::string &strModelName, IOSystem* io);
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
~ObjFileParser();
|
~ObjFileParser();
|
||||||
/// \brief Model getter.
|
/// \brief Model getter.
|
||||||
ObjFile::Model *GetModel() const;
|
ObjFile::Model *GetModel() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Parse the loaded file
|
/// Parse the loaded file
|
||||||
void parseFile();
|
void parseFile();
|
||||||
/// Method to copy the new delimited word in the current line.
|
/// Method to copy the new delimited word in the current line.
|
||||||
void copyNextWord(char *pBuffer, size_t length);
|
void copyNextWord(char *pBuffer, size_t length);
|
||||||
/// Method to copy the new line.
|
/// Method to copy the new line.
|
||||||
void copyNextLine(char *pBuffer, size_t length);
|
void copyNextLine(char *pBuffer, size_t length);
|
||||||
/// Stores the vector
|
/// Stores the vector
|
||||||
void getVector( std::vector<aiVector3D> &point3d_array );
|
void getVector( std::vector<aiVector3D> &point3d_array );
|
||||||
/// Stores the following 3d vector.
|
/// Stores the following 3d vector.
|
||||||
void getVector3( std::vector<aiVector3D> &point3d_array );
|
void getVector3( std::vector<aiVector3D> &point3d_array );
|
||||||
/// Stores the following 3d vector.
|
/// Stores the following 3d vector.
|
||||||
void getVector2(std::vector<aiVector2D> &point2d_array);
|
void getVector2(std::vector<aiVector2D> &point2d_array);
|
||||||
/// Stores the following face.
|
/// Stores the following face.
|
||||||
void getFace(aiPrimitiveType type);
|
void getFace(aiPrimitiveType type);
|
||||||
/// Reads the material description.
|
/// Reads the material description.
|
||||||
void getMaterialDesc();
|
void getMaterialDesc();
|
||||||
/// Gets a comment.
|
/// Gets a comment.
|
||||||
void getComment();
|
void getComment();
|
||||||
/// Gets a a material library.
|
/// Gets a a material library.
|
||||||
void getMaterialLib();
|
void getMaterialLib();
|
||||||
/// Creates a new material.
|
/// Creates a new material.
|
||||||
void getNewMaterial();
|
void getNewMaterial();
|
||||||
/// Gets the group name from file.
|
/// Gets the group name from file.
|
||||||
void getGroupName();
|
void getGroupName();
|
||||||
/// Gets the group number from file.
|
/// Gets the group number from file.
|
||||||
void getGroupNumber();
|
void getGroupNumber();
|
||||||
/// Gets the group number and resolution from file.
|
/// Gets the group number and resolution from file.
|
||||||
void getGroupNumberAndResolution();
|
void getGroupNumberAndResolution();
|
||||||
/// Returns the index of the material. Is -1 if not material was found.
|
/// Returns the index of the material. Is -1 if not material was found.
|
||||||
int getMaterialIndex( const std::string &strMaterialName );
|
int getMaterialIndex( const std::string &strMaterialName );
|
||||||
/// Parse object name
|
/// Parse object name
|
||||||
void getObjectName();
|
void getObjectName();
|
||||||
/// Creates a new object.
|
/// Creates a new object.
|
||||||
void createObject(const std::string &strObjectName);
|
void createObject(const std::string &strObjectName);
|
||||||
/// Creates a new mesh.
|
/// Creates a new mesh.
|
||||||
void createMesh();
|
void createMesh();
|
||||||
/// Returns true, if a new mesh instance must be created.
|
/// Returns true, if a new mesh instance must be created.
|
||||||
bool needsNewMesh( const std::string &rMaterialName );
|
bool needsNewMesh( const std::string &rMaterialName );
|
||||||
/// Error report in token
|
/// Error report in token
|
||||||
void reportErrorTokenInFace();
|
void reportErrorTokenInFace();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Default material name
|
/// Default material name
|
||||||
static const std::string DEFAULT_MATERIAL;
|
static const std::string DEFAULT_MATERIAL;
|
||||||
//! Iterator to current position in buffer
|
//! Iterator to current position in buffer
|
||||||
DataArrayIt m_DataIt;
|
DataArrayIt m_DataIt;
|
||||||
//! Iterator to end position of buffer
|
//! Iterator to end position of buffer
|
||||||
DataArrayIt m_DataItEnd;
|
DataArrayIt m_DataItEnd;
|
||||||
//! Pointer to model instance
|
//! Pointer to model instance
|
||||||
ObjFile::Model *m_pModel;
|
ObjFile::Model *m_pModel;
|
||||||
//! Current line (for debugging)
|
//! Current line (for debugging)
|
||||||
unsigned int m_uiLine;
|
unsigned int m_uiLine;
|
||||||
//! Helper buffer
|
//! Helper buffer
|
||||||
char m_buffer[BUFFERSIZE];
|
char m_buffer[BUFFERSIZE];
|
||||||
/// Pointer to IO system instance.
|
/// Pointer to IO system instance.
|
||||||
IOSystem *m_pIO;
|
IOSystem *m_pIO;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
|
@ -244,15 +244,6 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
in++;
|
in++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the properties
|
|
||||||
if( ddl_nullptr != first ) {
|
|
||||||
std::cout << id->m_buffer << std::endl;
|
|
||||||
DDLNode *current( top() );
|
|
||||||
if( current ) {
|
|
||||||
current->setProperties( first );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// store the node
|
// store the node
|
||||||
DDLNode *node( createDDLNode( id, this ) );
|
DDLNode *node( createDDLNode( id, this ) );
|
||||||
if( nullptr != node ) {
|
if( nullptr != node ) {
|
||||||
|
@ -261,6 +252,11 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
std::cerr << "nullptr returned by creating DDLNode." << std::endl;
|
std::cerr << "nullptr returned by creating DDLNode." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the properties
|
||||||
|
if( ddl_nullptr != first ) {
|
||||||
|
node->setProperties( first );
|
||||||
|
}
|
||||||
|
|
||||||
Name *name( ddl_nullptr );
|
Name *name( ddl_nullptr );
|
||||||
in = OpenDDLParser::parseName( in, end, &name );
|
in = OpenDDLParser::parseName( in, end, &name );
|
||||||
if( ddl_nullptr != name ) {
|
if( ddl_nullptr != name ) {
|
||||||
|
@ -277,6 +273,7 @@ char *OpenDDLParser::parseStructure( char *in, char *end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool error( false );
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
if( *in == '{' ) {
|
if( *in == '{' ) {
|
||||||
in++;
|
in++;
|
||||||
|
@ -307,6 +304,7 @@ char *OpenDDLParser::parseStructure( char *in, char *end ) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "0 for array is invalid." << std::endl;
|
std::cerr << "0 for array is invalid." << std::endl;
|
||||||
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,12 +322,16 @@ char *OpenDDLParser::parseStructure( char *in, char *end ) {
|
||||||
} else {
|
} else {
|
||||||
in++;
|
in++;
|
||||||
logInvalidTokenError( in, "{", m_logCallback );
|
logInvalidTokenError( in, "{", m_logCallback );
|
||||||
|
error = true;
|
||||||
return in;
|
return in;
|
||||||
|
|
||||||
}
|
}
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
|
|
||||||
in++;
|
// pop node from stack after successful parsing
|
||||||
|
if( !error ) {
|
||||||
|
popNode();
|
||||||
|
}
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue