FEATURE: First prototype for ObjFile material-importer, the assimp data structure will not be created yet.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@17 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
2eb6fca408
commit
a052251bcf
|
@ -38,7 +38,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef OBJ_FILEDATA_H_INC
|
#ifndef OBJ_FILEDATA_H_INC
|
||||||
#define OBJ_FILEDATA_H_INC
|
#define OBJ_FILEDATA_H_INC
|
||||||
|
|
||||||
|
@ -174,6 +173,7 @@ struct Model
|
||||||
std::vector<aiVector3D*> m_Normals;
|
std::vector<aiVector3D*> m_Normals;
|
||||||
//! Groupmap
|
//! Groupmap
|
||||||
GroupMap m_Groups;
|
GroupMap m_Groups;
|
||||||
|
//! Group to face id assignment
|
||||||
std::vector<unsigned int> *m_pGroupFaceIDs;
|
std::vector<unsigned int> *m_pGroupFaceIDs;
|
||||||
//! Active group
|
//! Active group
|
||||||
std::string m_strActiveGroup;
|
std::string m_strActiveGroup;
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#include "ObjFileImporter.h"
|
#include "ObjFileImporter.h"
|
||||||
#include "ObjFileParser.h"
|
#include "ObjFileParser.h"
|
||||||
#include "ObjFileData.h"
|
#include "ObjFileData.h"
|
||||||
#include "../include/IOStream.h"
|
#include "IOStream.h"
|
||||||
#include "../include/IOSystem.h"
|
#include "IOSystem.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "aiScene.h"
|
||||||
#include "aiAssert.h"
|
#include "aiAssert.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "DefaultLogger.h"
|
#include "DefaultLogger.h"
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
|
@ -47,7 +48,6 @@ bool ObjFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) c
|
||||||
if (pFile.empty())
|
if (pFile.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DefaultLogger::get()->info("ObjFileImporter::CanRead");
|
|
||||||
string::size_type pos = pFile.find_last_of(".");
|
string::size_type pos = pFile.find_last_of(".");
|
||||||
if (string::npos == pos)
|
if (string::npos == pos)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,12 +1,31 @@
|
||||||
#include "ObjFileMtlImporter.h"
|
#include "ObjFileMtlImporter.h"
|
||||||
|
#include "aiTypes.h"
|
||||||
|
#include "ObjTools.h"
|
||||||
|
#include "ObjFileData.h"
|
||||||
|
#include "aiAssert.h"
|
||||||
|
#include "fast_atof.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
ObjFileMtlImporter::ObjFileMtlImporter()
|
ObjFileMtlImporter::ObjFileMtlImporter( std::vector<char> &buffer,
|
||||||
|
const std::string &strAbsPath,
|
||||||
|
ObjFile::Model *pModel ) :
|
||||||
|
m_DataIt( buffer.begin() ),
|
||||||
|
m_DataItEnd( buffer.end() ),
|
||||||
|
m_uiLine( 0 ),
|
||||||
|
m_pModel( NULL )
|
||||||
{
|
{
|
||||||
// TODO: Inplement this
|
ai_assert ( NULL != m_pModel );
|
||||||
|
if ( NULL == m_pModel->m_pDefaultMaterial )
|
||||||
|
{
|
||||||
|
m_pModel->m_pDefaultMaterial = new ObjFile::Material();
|
||||||
|
|
||||||
|
//m_pModel->m_pDefaultMaterial->
|
||||||
|
}
|
||||||
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -22,33 +41,154 @@ ObjFileMtlImporter::ObjFileMtlImporter(const ObjFileMtlImporter &rOther)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
ObjFileMtlImporter &ObjFileMtlImporter::operator = (const ObjFileMtlImporter &rOther)
|
ObjFileMtlImporter &ObjFileMtlImporter::operator = (
|
||||||
|
const ObjFileMtlImporter &rOther)
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void ObjFileMtlImporter::getColorRGBA()
|
void ObjFileMtlImporter::load()
|
||||||
{
|
{
|
||||||
|
if ( m_DataIt == m_DataItEnd )
|
||||||
|
return;
|
||||||
|
|
||||||
|
while ( m_DataIt != m_DataItEnd )
|
||||||
|
{
|
||||||
|
switch (*m_DataIt)
|
||||||
|
{
|
||||||
|
case 'K':
|
||||||
|
{
|
||||||
|
++m_DataIt;
|
||||||
|
if (*m_DataIt == 'a') // Ambient color
|
||||||
|
{
|
||||||
|
getColorRGBA( &m_pModel->m_pCurrentMaterial->ambient );
|
||||||
|
}
|
||||||
|
else if (*m_DataIt == 'd') // Diffuse color
|
||||||
|
{
|
||||||
|
getColorRGBA( &m_pModel->m_pCurrentMaterial->diffuse );
|
||||||
|
}
|
||||||
|
else if (*m_DataIt == 's')
|
||||||
|
{
|
||||||
|
getColorRGBA( &m_pModel->m_pCurrentMaterial->specular );
|
||||||
|
}
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'd': // Alpha value
|
||||||
|
{
|
||||||
|
getFloatValue( m_pModel->m_pCurrentMaterial->alpha );
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'N': // Shineness
|
||||||
|
{
|
||||||
|
getIlluminationModel( m_pModel->m_pCurrentMaterial->illumination_model );
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'm': // Texture
|
||||||
|
{
|
||||||
|
getTexture();
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'n': // New material name
|
||||||
|
{
|
||||||
|
createMaterial();
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'i': // Illumination model
|
||||||
|
{
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void ObjFileMtlImporter::getIlluminationModel()
|
void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor )
|
||||||
{
|
{
|
||||||
|
ai_assert( NULL != pColor );
|
||||||
|
|
||||||
|
float r, g, b;
|
||||||
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
|
r = (float) fast_atof(m_buffer);
|
||||||
|
|
||||||
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
|
g = (float) fast_atof(m_buffer);
|
||||||
|
|
||||||
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
|
b = (float) fast_atof(m_buffer);
|
||||||
|
|
||||||
|
pColor->r = r;
|
||||||
|
pColor->g = g;
|
||||||
|
pColor->b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void ObjFileMtlImporter::getFloatValue()
|
void ObjFileMtlImporter::getIlluminationModel( int &illum_model )
|
||||||
{
|
{
|
||||||
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
|
illum_model = atoi(m_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
void ObjFileMtlImporter::getFloatValue( float &value )
|
||||||
|
{
|
||||||
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
|
value = (float) fast_atof(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void ObjFileMtlImporter::createMaterial()
|
void ObjFileMtlImporter::createMaterial()
|
||||||
{
|
{
|
||||||
|
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
||||||
|
|
||||||
|
/*m_DataIt = getNextToken<DataArrayIt>( m_DataIt, m_DataItEnd );
|
||||||
|
if (m_DataIt == m_DataItEnd)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char *pStart = &(*m_DataIt);
|
||||||
|
while ( !isSpace(*m_DataIt) && m_DataIt != m_DataItEnd )
|
||||||
|
++m_DataIt;
|
||||||
|
|
||||||
|
// Get name
|
||||||
|
std::string strName(pStart, &(*m_DataIt));
|
||||||
|
if ( strName.empty() )
|
||||||
|
return;*/
|
||||||
|
std::string strName;
|
||||||
|
m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strName );
|
||||||
|
if ( m_DataItEnd == m_DataIt )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pModel->m_pCurrentMaterial->MaterialName.Set( strName );
|
||||||
|
m_pModel->m_MaterialLib.push_back( strName );
|
||||||
|
m_pModel->m_MaterialMap[ strName ] = m_pModel->m_pCurrentMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void ObjFileMtlImporter::getTexture()
|
void ObjFileMtlImporter::getTexture()
|
||||||
{
|
{
|
||||||
|
std::string strTexture;
|
||||||
|
m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strTexture );
|
||||||
|
if ( m_DataItEnd == m_DataIt )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pModel->m_pCurrentMaterial->texture.Set( strTexture );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
@ -35,25 +35,41 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------*/
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef OBJFILEMTLIMPORTER_H_INC
|
#ifndef OBJFILEMTLIMPORTER_H_INC
|
||||||
#define OBJFILEMTLIMPORTER_H_INC
|
#define OBJFILEMTLIMPORTER_H_INC
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct aiColor3D;
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace ObjFile
|
||||||
|
{
|
||||||
|
struct Model;
|
||||||
|
struct Material;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class ObjFileMtlImporter
|
* @class ObjFileMtlImporter
|
||||||
* @brief Loads the material description from a mtl file.
|
* @brief Loads the material description from a mtl file.
|
||||||
*/
|
*/
|
||||||
class ObjFileMtlImporter
|
class ObjFileMtlImporter
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
static const size_t BUFFERSIZE = 1024;
|
||||||
|
typedef std::vector<char> DataArray;
|
||||||
|
typedef std::vector<char>::iterator DataArrayIt;
|
||||||
|
typedef std::vector<char>::const_iterator ConstDataArrayIt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Default constructor
|
//! \brief Default constructor
|
||||||
ObjFileMtlImporter();
|
ObjFileMtlImporter( std::vector<char> &buffer, const std::string &strAbsPath,
|
||||||
|
ObjFile::Model *pModel );
|
||||||
|
|
||||||
//! \brief DEstructor
|
//! \brief DEstructor
|
||||||
~ObjFileMtlImporter();
|
~ObjFileMtlImporter();
|
||||||
|
@ -65,11 +81,20 @@ private:
|
||||||
//! \brief Assignment operator, returns only a reference of this instance.
|
//! \brief Assignment operator, returns only a reference of this instance.
|
||||||
ObjFileMtlImporter &operator = (const ObjFileMtlImporter &rOther);
|
ObjFileMtlImporter &operator = (const ObjFileMtlImporter &rOther);
|
||||||
|
|
||||||
void getColorRGBA();
|
void load();
|
||||||
void getIlluminationModel();
|
void getColorRGBA( aiColor3D *pColor);
|
||||||
void getFloatValue();
|
void getIlluminationModel( int &illum_model );
|
||||||
|
void getFloatValue( float &value );
|
||||||
void createMaterial();
|
void createMaterial();
|
||||||
void getTexture();
|
void getTexture();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_strAbsPath;
|
||||||
|
DataArrayIt m_DataIt;
|
||||||
|
DataArrayIt m_DataItEnd;
|
||||||
|
ObjFile::Model *m_pModel;
|
||||||
|
unsigned int m_uiLine;
|
||||||
|
char m_buffer[BUFFERSIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
|
@ -118,7 +118,7 @@ void ObjFileParser::parseFile()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -174,12 +174,13 @@ void ObjFileParser::getVector3(std::vector<aiVector3D*> &point3d_array)
|
||||||
z = (float) fast_atof(m_buffer);
|
z = (float) fast_atof(m_buffer);
|
||||||
|
|
||||||
point3d_array.push_back(new aiVector3D(x,y,z));
|
point3d_array.push_back(new aiVector3D(x,y,z));
|
||||||
skipLine();
|
//skipLine();
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get values for a new 2D vector instance
|
// Get values for a new 2D vector instance
|
||||||
void ObjFileParser::getVector2(std::vector<aiVector2D*> &point2d_array)
|
void ObjFileParser::getVector2( std::vector<aiVector2D*> &point2d_array )
|
||||||
{
|
{
|
||||||
float x, y;
|
float x, y;
|
||||||
copyNextWord(m_buffer, BUFFERSIZE);
|
copyNextWord(m_buffer, BUFFERSIZE);
|
||||||
|
@ -189,20 +190,8 @@ void ObjFileParser::getVector2(std::vector<aiVector2D*> &point2d_array)
|
||||||
y = (float) fast_atof(m_buffer);
|
y = (float) fast_atof(m_buffer);
|
||||||
|
|
||||||
point2d_array.push_back(new aiVector2D(x, y));
|
point2d_array.push_back(new aiVector2D(x, y));
|
||||||
skipLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
// Skips a line
|
|
||||||
void ObjFileParser::skipLine()
|
|
||||||
{
|
|
||||||
while (m_DataIt != m_DataItEnd && *m_DataIt != '\n')
|
|
||||||
++m_DataIt;
|
|
||||||
if (m_DataIt != m_DataItEnd)
|
|
||||||
{
|
|
||||||
++m_DataIt;
|
|
||||||
++m_uiLine;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -212,6 +201,7 @@ void ObjFileParser::getFace()
|
||||||
copyNextLine(m_buffer, BUFFERSIZE);
|
copyNextLine(m_buffer, BUFFERSIZE);
|
||||||
if (m_DataIt == m_DataItEnd)
|
if (m_DataIt == m_DataItEnd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char *pPtr = m_buffer;
|
char *pPtr = m_buffer;
|
||||||
char *pEnd = &pPtr[BUFFERSIZE];
|
char *pEnd = &pPtr[BUFFERSIZE];
|
||||||
pPtr = getNextToken<char*>(pPtr, pEnd);
|
pPtr = getNextToken<char*>(pPtr, pEnd);
|
||||||
|
@ -296,7 +286,7 @@ void ObjFileParser::getFace()
|
||||||
m_pModel->m_pCurrent->m_Faces.push_back(face);
|
m_pModel->m_pCurrent->m_Faces.push_back(face);
|
||||||
|
|
||||||
// Skip the rest of the line
|
// Skip the rest of the line
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -319,14 +309,14 @@ void ObjFileParser::getMaterialDesc()
|
||||||
|
|
||||||
// Search for material
|
// Search for material
|
||||||
std::string strFile;
|
std::string strFile;
|
||||||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find(strName);
|
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( strName );
|
||||||
if (it == m_pModel->m_MaterialMap.end())
|
if (it == m_pModel->m_MaterialMap.end())
|
||||||
{
|
{
|
||||||
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
||||||
m_pModel->m_MaterialMap[strName] = m_pModel->m_pCurrentMaterial;
|
m_pModel->m_MaterialMap[ strName ] = m_pModel->m_pCurrentMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -366,7 +356,7 @@ void ObjFileParser::getMaterialLib()
|
||||||
std::string absName = m_strAbsPath + IOSystem.getOsSeparator() + strMatName;
|
std::string absName = m_strAbsPath + IOSystem.getOsSeparator() + strMatName;
|
||||||
if (!IOSystem.Exists(absName))
|
if (!IOSystem.Exists(absName))
|
||||||
{
|
{
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,20 +369,20 @@ void ObjFileParser::getMaterialLib()
|
||||||
if (0L != pFile)
|
if (0L != pFile)
|
||||||
{
|
{
|
||||||
size_t size = pFile->FileSize();
|
size_t size = pFile->FileSize();
|
||||||
char *pBuffer = new char[size];
|
std::vector<char> buffer;
|
||||||
size_t read_size = pFile->Read(pBuffer, sizeof(char), size);
|
buffer.resize( size );
|
||||||
FileSystem.Close(pFile);
|
|
||||||
|
size_t read_size = pFile->Read( &buffer[ 0 ], sizeof(char), size );
|
||||||
|
FileSystem.Close( pFile );
|
||||||
|
|
||||||
// TODO: Load mtl file
|
// TODO: Load mtl file
|
||||||
|
|
||||||
delete [] pBuffer;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load material library (all materials will be created)
|
// Load material library (all materials will be created)
|
||||||
m_pModel->m_MaterialLib.push_back(strMatName);
|
m_pModel->m_MaterialLib.push_back(strMatName);
|
||||||
|
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -421,7 +411,7 @@ void ObjFileParser::getNewMaterial()
|
||||||
m_pModel->m_pCurrentMaterial = (*it).second;
|
m_pModel->m_pCurrentMaterial = (*it).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -458,16 +448,16 @@ void ObjFileParser::getGroupName()
|
||||||
}
|
}
|
||||||
m_pModel->m_strActiveGroup = strGroupName;
|
m_pModel->m_strActiveGroup = strGroupName;
|
||||||
}
|
}
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Not supported
|
// Not supported
|
||||||
void ObjFileParser::getGroupNumber()
|
void ObjFileParser::getGroupNumber()
|
||||||
{
|
{
|
||||||
// TODO: Implement this
|
// Not used
|
||||||
|
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -509,7 +499,7 @@ void ObjFileParser::getObjectName()
|
||||||
m_pModel->m_Objects.push_back(m_pModel->m_pCurrent);*/
|
m_pModel->m_Objects.push_back(m_pModel->m_pCurrent);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
skipLine();
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Creates a new object instance
|
// Creates a new object instance
|
||||||
|
@ -528,7 +518,8 @@ void ObjFileParser::createObject(const std::string &strObjectName)
|
||||||
void ObjFileParser::reportErrorTokenInFace()
|
void ObjFileParser::reportErrorTokenInFace()
|
||||||
{
|
{
|
||||||
std::string strErr("");
|
std::string strErr("");
|
||||||
skipLine();
|
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
std::cerr << "Not supported token in face desc. detected : " << strErr << std::endl;
|
std::cerr << "Not supported token in face desc. detected : " << strErr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ inline Char_T getNextWord(Char_T pBuffer, Char_T pEnd)
|
||||||
* @param pBuffer Pointer to data buffer
|
* @param pBuffer Pointer to data buffer
|
||||||
* @param pEnd Pointer to end of buffer
|
* @param pEnd Pointer to end of buffer
|
||||||
* @return Pointer to next token
|
* @return Pointer to next token
|
||||||
*/
|
*/
|
||||||
template<class Char_T>
|
template<class Char_T>
|
||||||
inline Char_T getNextToken(Char_T pBuffer, Char_T pEnd)
|
inline Char_T getNextToken(Char_T pBuffer, Char_T pEnd)
|
||||||
{
|
{
|
||||||
|
@ -91,6 +91,65 @@ inline Char_T getNextToken(Char_T pBuffer, Char_T pEnd)
|
||||||
return getNextWord(pBuffer, pEnd);
|
return getNextWord(pBuffer, pEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Skips a line
|
||||||
|
* @param Iterator set to current position
|
||||||
|
* @param Iterator set to end of scratch buffer for readout
|
||||||
|
* @param Current linenumber in format
|
||||||
|
* @return Current-iterator with new position
|
||||||
|
*/
|
||||||
|
template<class char_t>
|
||||||
|
inline char_t skipLine(char_t it, char_t end, unsigned int &uiLine)
|
||||||
|
{
|
||||||
|
while ( it != end && *it != '\n' )
|
||||||
|
++it;
|
||||||
|
if ( it != end )
|
||||||
|
{
|
||||||
|
++it;
|
||||||
|
++uiLine;
|
||||||
|
}
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class char_t>
|
||||||
|
inline char_t getName( char_t it, char_t end, std::string &name )
|
||||||
|
{
|
||||||
|
name = "";
|
||||||
|
it = getNextToken<char_t>( it, end );
|
||||||
|
if ( it == end )
|
||||||
|
return end;
|
||||||
|
|
||||||
|
char *pStart = &(*it);
|
||||||
|
while ( !isSpace(*it) && it != end )
|
||||||
|
++it;
|
||||||
|
|
||||||
|
// Get name
|
||||||
|
std::string strName(pStart, &(*it));
|
||||||
|
if ( strName.empty() )
|
||||||
|
return it;
|
||||||
|
else
|
||||||
|
name = strName;
|
||||||
|
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class char_t>
|
||||||
|
inline char_t CopyNextWord( char_t it, char_t end, char *pBuffer, size_t length )
|
||||||
|
{
|
||||||
|
size_t index = 0;
|
||||||
|
it = getNextWord<char_t>( it, end );
|
||||||
|
while (!isSpace( *it ) && it != end )
|
||||||
|
{
|
||||||
|
pBuffer[index] = *it ;
|
||||||
|
index++;
|
||||||
|
if (index == length-1)
|
||||||
|
break;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
pBuffer[index] = '\0';
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,7 +81,6 @@ private:
|
||||||
void copyNextLine(char *pBuffer, size_t length);
|
void copyNextLine(char *pBuffer, size_t length);
|
||||||
void getVector3(std::vector<aiVector3D*> &point3d_array);
|
void getVector3(std::vector<aiVector3D*> &point3d_array);
|
||||||
void getVector2(std::vector<aiVector2D*> &point2d_array);
|
void getVector2(std::vector<aiVector2D*> &point2d_array);
|
||||||
void skipLine();
|
|
||||||
void getFace();
|
void getFace();
|
||||||
void getMaterialDesc();
|
void getMaterialDesc();
|
||||||
void getComment();
|
void getComment();
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||||
# Visual Studio 2005
|
# Visual C++ Express 2005
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimp", "assimp.vcproj", "{5691E159-2D9B-407F-971F-EA5C592DC524}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimp_view", "assimp_view.vcproj", "{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{5691E159-2D9B-407F-971F-EA5C592DC524} = {5691E159-2D9B-407F-971F-EA5C592DC524}
|
||||||
|
EndProjectSection
|
||||||
ProjectSection(WebsiteProperties) = preProject
|
ProjectSection(WebsiteProperties) = preProject
|
||||||
Debug.AspNetCompiler.Debug = "True"
|
Debug.AspNetCompiler.Debug = "True"
|
||||||
Release.AspNetCompiler.Debug = "False"
|
Release.AspNetCompiler.Debug = "False"
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimp_view", "assimp_view.vcproj", "{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimp", "assimp.vcproj", "{5691E159-2D9B-407F-971F-EA5C592DC524}"
|
||||||
ProjectSection(WebsiteProperties) = preProject
|
|
||||||
Debug.AspNetCompiler.Debug = "True"
|
|
||||||
Release.AspNetCompiler.Debug = "False"
|
|
||||||
EndProjectSection
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{5691E159-2D9B-407F-971F-EA5C592DC524} = {5691E159-2D9B-407F-971F-EA5C592DC524}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -24,6 +20,12 @@ Global
|
||||||
Release|Win32 = Release|Win32
|
Release|Win32 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Debug_DLL|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Release_DLL|Win32.ActiveCfg = Release|Win32
|
||||||
|
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Release|Win32.Build.0 = Release|Win32
|
||||||
{5691E159-2D9B-407F-971F-EA5C592DC524}.Debug_DLL|Win32.ActiveCfg = Debug_DLL|Win32
|
{5691E159-2D9B-407F-971F-EA5C592DC524}.Debug_DLL|Win32.ActiveCfg = Debug_DLL|Win32
|
||||||
{5691E159-2D9B-407F-971F-EA5C592DC524}.Debug_DLL|Win32.Build.0 = Debug_DLL|Win32
|
{5691E159-2D9B-407F-971F-EA5C592DC524}.Debug_DLL|Win32.Build.0 = Debug_DLL|Win32
|
||||||
{5691E159-2D9B-407F-971F-EA5C592DC524}.Debug|Win32.ActiveCfg = Debug|Win32
|
{5691E159-2D9B-407F-971F-EA5C592DC524}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
@ -32,12 +34,6 @@ Global
|
||||||
{5691E159-2D9B-407F-971F-EA5C592DC524}.Release_DLL|Win32.Build.0 = Release_DLL|Win32
|
{5691E159-2D9B-407F-971F-EA5C592DC524}.Release_DLL|Win32.Build.0 = Release_DLL|Win32
|
||||||
{5691E159-2D9B-407F-971F-EA5C592DC524}.Release|Win32.ActiveCfg = Release|Win32
|
{5691E159-2D9B-407F-971F-EA5C592DC524}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{5691E159-2D9B-407F-971F-EA5C592DC524}.Release|Win32.Build.0 = Release|Win32
|
{5691E159-2D9B-407F-971F-EA5C592DC524}.Release|Win32.Build.0 = Release|Win32
|
||||||
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Debug_DLL|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Release_DLL|Win32.ActiveCfg = Release|Win32
|
|
||||||
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Reference in New Issue