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