mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-14 12:13:46 +00:00
Just the functional assimp lib rather than the entire assimp repository unnecessarily.
This commit is contained in:
parent
0f7641a282
commit
e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -46,8 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "ObjFileMtlImporter.h"
|
||||
#include "ObjTools.h"
|
||||
#include "ObjFileData.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include "ParsingUtils.h"
|
||||
#include "BaseImporter.h"
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/material.h>
|
||||
|
|
@ -61,7 +60,7 @@ const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
|
|||
ObjFileParser::ObjFileParser()
|
||||
: m_DataIt()
|
||||
, m_DataItEnd()
|
||||
, m_pModel( nullptr )
|
||||
, m_pModel( NULL )
|
||||
, m_uiLine( 0 )
|
||||
, m_pIO( nullptr )
|
||||
, m_progress( nullptr )
|
||||
|
|
@ -74,7 +73,7 @@ ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::str
|
|||
const std::string &originalObjFileName) :
|
||||
m_DataIt(),
|
||||
m_DataItEnd(),
|
||||
m_pModel(nullptr),
|
||||
m_pModel(NULL),
|
||||
m_uiLine(0),
|
||||
m_pIO( io ),
|
||||
m_progress(progress),
|
||||
|
|
@ -83,7 +82,7 @@ ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::str
|
|||
std::fill_n(m_buffer,Buffersize,0);
|
||||
|
||||
// Create the model instance to store all the data
|
||||
m_pModel.reset(new ObjFile::Model());
|
||||
m_pModel = new ObjFile::Model();
|
||||
m_pModel->m_ModelName = modelName;
|
||||
|
||||
// create default material and store it
|
||||
|
|
@ -97,6 +96,8 @@ ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::str
|
|||
}
|
||||
|
||||
ObjFileParser::~ObjFileParser() {
|
||||
delete m_pModel;
|
||||
m_pModel = NULL;
|
||||
}
|
||||
|
||||
void ObjFileParser::setBuffer( std::vector<char> &buffer ) {
|
||||
|
|
@ -105,7 +106,7 @@ void ObjFileParser::setBuffer( std::vector<char> &buffer ) {
|
|||
}
|
||||
|
||||
ObjFile::Model *ObjFileParser::GetModel() const {
|
||||
return m_pModel.get();
|
||||
return m_pModel;
|
||||
}
|
||||
|
||||
void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
||||
|
|
@ -352,8 +353,7 @@ void ObjFileParser::getHomogeneousVector3( std::vector<aiVector3D> &point3d_arra
|
|||
copyNextWord( m_buffer, Buffersize );
|
||||
w = ( ai_real ) fast_atof( m_buffer );
|
||||
|
||||
if (w == 0)
|
||||
throw DeadlyImportError("OBJ: Invalid component in homogeneous vector (Division by zero)");
|
||||
ai_assert( w != 0 );
|
||||
|
||||
point3d_array.push_back( aiVector3D( x/w, y/w, z/w ) );
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
|
|
@ -426,7 +426,7 @@ void ObjFileParser::getFace( aiPrimitiveType type ) {
|
|||
|
||||
if ( *m_DataIt =='/' ) {
|
||||
if (type == aiPrimitiveType_POINT) {
|
||||
ASSIMP_LOG_ERROR("Obj: Separator unexpected in point statement");
|
||||
DefaultLogger::get()->error("Obj: Separator unexpected in point statement");
|
||||
}
|
||||
if (iPos == 0) {
|
||||
//if there are no texture coordinates in the file, but normals
|
||||
|
|
@ -478,6 +478,8 @@ void ObjFileParser::getFace( aiPrimitiveType type ) {
|
|||
} else {
|
||||
//On error, std::atoi will return 0 which is not a valid value
|
||||
delete face;
|
||||
delete m_pModel;
|
||||
m_pModel = nullptr;
|
||||
throw DeadlyImportError("OBJ: Invalid face indice");
|
||||
}
|
||||
|
||||
|
|
@ -486,7 +488,7 @@ void ObjFileParser::getFace( aiPrimitiveType type ) {
|
|||
}
|
||||
|
||||
if ( face->m_vertices.empty() ) {
|
||||
ASSIMP_LOG_ERROR("Obj: Ignoring empty face");
|
||||
DefaultLogger::get()->error("Obj: Ignoring empty face");
|
||||
// skip line and clean up
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
delete face;
|
||||
|
|
@ -556,7 +558,7 @@ void ObjFileParser::getMaterialDesc() {
|
|||
// This may be the case if the material library is missing. We don't want to lose all
|
||||
// materials if that happens, so create a new named material instead of discarding it
|
||||
// completely.
|
||||
ASSIMP_LOG_ERROR("OBJ: failed to locate material " + strName + ", creating new material");
|
||||
DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", creating new material");
|
||||
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
||||
m_pModel->m_pCurrentMaterial->MaterialName.Set(strName);
|
||||
m_pModel->m_MaterialLib.push_back(strName);
|
||||
|
|
@ -603,7 +605,7 @@ void ObjFileParser::getMaterialLib() {
|
|||
|
||||
// Check if directive is valid.
|
||||
if ( 0 == strMatName.length() ) {
|
||||
ASSIMP_LOG_WARN( "OBJ: no name for material library specified." );
|
||||
DefaultLogger::get()->warn( "OBJ: no name for material library specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -612,20 +614,19 @@ void ObjFileParser::getMaterialLib() {
|
|||
if ( '/' != *path.rbegin() ) {
|
||||
path += '/';
|
||||
}
|
||||
absName += path;
|
||||
absName += strMatName;
|
||||
absName = path + strMatName;
|
||||
} else {
|
||||
absName = strMatName;
|
||||
}
|
||||
|
||||
IOStream *pFile = m_pIO->Open( absName );
|
||||
if ( nullptr == pFile ) {
|
||||
ASSIMP_LOG_ERROR("OBJ: Unable to locate material file " + strMatName);
|
||||
|
||||
if (!pFile ) {
|
||||
DefaultLogger::get()->error("OBJ: Unable to locate material file " + strMatName);
|
||||
std::string strMatFallbackName = m_originalObjFileName.substr(0, m_originalObjFileName.length() - 3) + "mtl";
|
||||
ASSIMP_LOG_INFO("OBJ: Opening fallback material file " + strMatFallbackName);
|
||||
DefaultLogger::get()->info("OBJ: Opening fallback material file " + strMatFallbackName);
|
||||
pFile = m_pIO->Open(strMatFallbackName);
|
||||
if (!pFile) {
|
||||
ASSIMP_LOG_ERROR("OBJ: Unable to locate fallback material file " + strMatFallbackName);
|
||||
DefaultLogger::get()->error("OBJ: Unable to locate fallback material file " + strMatFallbackName);
|
||||
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
||||
return;
|
||||
}
|
||||
|
|
@ -640,7 +641,7 @@ void ObjFileParser::getMaterialLib() {
|
|||
m_pIO->Close( pFile );
|
||||
|
||||
// Importing the material library
|
||||
ObjFileMtlImporter mtlImporter( buffer, strMatName, m_pModel.get() );
|
||||
ObjFileMtlImporter mtlImporter( buffer, strMatName, m_pModel );
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -660,7 +661,7 @@ void ObjFileParser::getNewMaterial() {
|
|||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( strMat );
|
||||
if ( it == m_pModel->m_MaterialMap.end() ) {
|
||||
// Show a warning, if material was not found
|
||||
ASSIMP_LOG_WARN("OBJ: Unsupported material requested: " + strMat);
|
||||
DefaultLogger::get()->warn("OBJ: Unsupported material requested: " + strMat);
|
||||
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
|
||||
} else {
|
||||
// Set new material
|
||||
|
|
@ -817,7 +818,7 @@ void ObjFileParser::createMesh( const std::string &meshName )
|
|||
}
|
||||
else
|
||||
{
|
||||
ASSIMP_LOG_ERROR("OBJ: No object detected to attach a new mesh instance.");
|
||||
DefaultLogger::get()->error("OBJ: No object detected to attach a new mesh instance.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -851,7 +852,7 @@ bool ObjFileParser::needsNewMesh( const std::string &materialName )
|
|||
void ObjFileParser::reportErrorTokenInFace()
|
||||
{
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
ASSIMP_LOG_ERROR("OBJ: Not supported token in face description detected");
|
||||
DefaultLogger::get()->error("OBJ: Not supported token in face description detected");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue