mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-16 13:13:53 +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.
|
||||
|
|
@ -50,13 +49,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include "ColladaParser.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include "fast_atof.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/light.h>
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include "TinyFormatter.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
|
@ -68,7 +67,7 @@ using namespace Assimp::Formatter;
|
|||
// Constructor to be privately used by Importer
|
||||
ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
|
||||
: mFileName( pFile )
|
||||
, mReader( nullptr )
|
||||
, mReader( NULL )
|
||||
, mDataLibrary()
|
||||
, mAccessorLibrary()
|
||||
, mMeshLibrary()
|
||||
|
|
@ -79,20 +78,20 @@ ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
|
|||
, mLightLibrary()
|
||||
, mCameraLibrary()
|
||||
, mControllerLibrary()
|
||||
, mRootNode( nullptr )
|
||||
, mRootNode( NULL )
|
||||
, mAnims()
|
||||
, mUnitSize( 1.0f )
|
||||
, mUpDirection( UP_Y )
|
||||
, mFormat(FV_1_5_n ) // We assume the newest file format by default
|
||||
{
|
||||
// validate io-handler instance
|
||||
if (nullptr == pIOHandler ) {
|
||||
if ( NULL == pIOHandler ) {
|
||||
throw DeadlyImportError("IOSystem is NULL." );
|
||||
}
|
||||
|
||||
// open the file
|
||||
std::unique_ptr<IOStream> file( pIOHandler->Open(pFile ) );
|
||||
if (file.get() == nullptr) {
|
||||
if (file.get() == NULL) {
|
||||
throw DeadlyImportError( "Failed to open file " + pFile + "." );
|
||||
}
|
||||
|
||||
|
|
@ -152,22 +151,22 @@ void ColladaParser::ReadContents()
|
|||
|
||||
if (!::strncmp(version,"1.5",3)) {
|
||||
mFormat = FV_1_5_n;
|
||||
ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n");
|
||||
DefaultLogger::get()->debug("Collada schema version is 1.5.n");
|
||||
}
|
||||
else if (!::strncmp(version,"1.4",3)) {
|
||||
mFormat = FV_1_4_n;
|
||||
ASSIMP_LOG_DEBUG("Collada schema version is 1.4.n");
|
||||
DefaultLogger::get()->debug("Collada schema version is 1.4.n");
|
||||
}
|
||||
else if (!::strncmp(version,"1.3",3)) {
|
||||
mFormat = FV_1_3_n;
|
||||
ASSIMP_LOG_DEBUG("Collada schema version is 1.3.n");
|
||||
DefaultLogger::get()->debug("Collada schema version is 1.3.n");
|
||||
}
|
||||
}
|
||||
|
||||
ReadStructure();
|
||||
} else
|
||||
{
|
||||
ASSIMP_LOG_DEBUG_F( "Ignoring global element <", mReader->getNodeName(), ">." );
|
||||
DefaultLogger::get()->debug( format() << "Ignoring global element <" << mReader->getNodeName() << ">." );
|
||||
SkipElement();
|
||||
}
|
||||
} else
|
||||
|
|
@ -222,7 +221,6 @@ void ColladaParser::ReadStructure()
|
|||
}
|
||||
|
||||
PostProcessRootAnimations();
|
||||
PostProcessControllers();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -361,21 +359,6 @@ void ColladaParser::ReadAnimationClipLibrary()
|
|||
}
|
||||
}
|
||||
|
||||
void ColladaParser::PostProcessControllers()
|
||||
{
|
||||
std::string meshId;
|
||||
for (ControllerLibrary::iterator it = mControllerLibrary.begin(); it != mControllerLibrary.end(); ++it) {
|
||||
meshId = it->second.mMeshId;
|
||||
ControllerLibrary::iterator findItr = mControllerLibrary.find(meshId);
|
||||
while(findItr != mControllerLibrary.end()) {
|
||||
meshId = findItr->second.mMeshId;
|
||||
findItr = mControllerLibrary.find(meshId);
|
||||
}
|
||||
|
||||
it->second.mMeshId = meshId;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Re-build animations from animation clip library, if present, otherwise combine single-channel animations
|
||||
void ColladaParser::PostProcessRootAnimations()
|
||||
|
|
@ -984,13 +967,13 @@ void ColladaParser::ReadImage( Collada::Image& pImage)
|
|||
// they're not skipped.
|
||||
int attrib = TestAttribute("array_index");
|
||||
if (attrib != -1 && mReader->getAttributeValueAsInt(attrib) > 0) {
|
||||
ASSIMP_LOG_WARN("Collada: Ignoring texture array index");
|
||||
DefaultLogger::get()->warn("Collada: Ignoring texture array index");
|
||||
continue;
|
||||
}
|
||||
|
||||
attrib = TestAttribute("mip_index");
|
||||
if (attrib != -1 && mReader->getAttributeValueAsInt(attrib) > 0) {
|
||||
ASSIMP_LOG_WARN("Collada: Ignoring MIP map layer");
|
||||
DefaultLogger::get()->warn("Collada: Ignoring MIP map layer");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1011,7 +994,7 @@ void ColladaParser::ReadImage( Collada::Image& pImage)
|
|||
// embedded image. get format
|
||||
const int attrib = TestAttribute("format");
|
||||
if (-1 == attrib)
|
||||
ASSIMP_LOG_WARN("Collada: Unknown image file format");
|
||||
DefaultLogger::get()->warn("Collada: Unknown image file format");
|
||||
else pImage.mEmbeddedFormat = mReader->getAttributeValue(attrib);
|
||||
|
||||
const char* data = GetTextContent();
|
||||
|
|
@ -1590,7 +1573,7 @@ void ColladaParser::ReadSamplerProperties( Sampler& out )
|
|||
out.mOp = aiTextureOp_Multiply;
|
||||
|
||||
else {
|
||||
ASSIMP_LOG_WARN("Collada: Unsupported MAYA texture blend mode");
|
||||
DefaultLogger::get()->warn("Collada: Unsupported MAYA texture blend mode");
|
||||
}
|
||||
TestClosing( "blend_mode");
|
||||
}
|
||||
|
|
@ -2541,7 +2524,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
|
|||
if( pInput.mIndex == 0)
|
||||
pMesh->mPositions.push_back( aiVector3D( obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported");
|
||||
DefaultLogger::get()->error("Collada: just one vertex position stream supported");
|
||||
break;
|
||||
case IT_Normal:
|
||||
// pad to current vertex count if necessary
|
||||
|
|
@ -2552,7 +2535,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
|
|||
if( pInput.mIndex == 0)
|
||||
pMesh->mNormals.push_back( aiVector3D( obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported");
|
||||
DefaultLogger::get()->error("Collada: just one vertex normal stream supported");
|
||||
break;
|
||||
case IT_Tangent:
|
||||
// pad to current vertex count if necessary
|
||||
|
|
@ -2563,7 +2546,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
|
|||
if( pInput.mIndex == 0)
|
||||
pMesh->mTangents.push_back( aiVector3D( obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported");
|
||||
DefaultLogger::get()->error("Collada: just one vertex tangent stream supported");
|
||||
break;
|
||||
case IT_Bitangent:
|
||||
// pad to current vertex count if necessary
|
||||
|
|
@ -2574,7 +2557,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
|
|||
if( pInput.mIndex == 0)
|
||||
pMesh->mBitangents.push_back( aiVector3D( obj[0], obj[1], obj[2]));
|
||||
else
|
||||
ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported");
|
||||
DefaultLogger::get()->error("Collada: just one vertex bitangent stream supported");
|
||||
break;
|
||||
case IT_Texcoord:
|
||||
// up to 4 texture coord sets are fine, ignore the others
|
||||
|
|
@ -2590,7 +2573,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
|
|||
pMesh->mNumUVComponents[pInput.mIndex]=3;
|
||||
} else
|
||||
{
|
||||
ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping.");
|
||||
DefaultLogger::get()->error("Collada: too many texture coordinate sets. Skipping.");
|
||||
}
|
||||
break;
|
||||
case IT_Color:
|
||||
|
|
@ -2610,7 +2593,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
|
|||
pMesh->mColors[pInput.mIndex].push_back(result);
|
||||
} else
|
||||
{
|
||||
ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping.");
|
||||
DefaultLogger::get()->error("Collada: too many vertex color sets. Skipping.");
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -2739,7 +2722,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
|
|||
{
|
||||
const char* s = mReader->getAttributeValue(attrId);
|
||||
if (s[0] != '#')
|
||||
ASSIMP_LOG_ERROR("Collada: Unresolved reference format of camera");
|
||||
DefaultLogger::get()->error("Collada: Unresolved reference format of camera");
|
||||
else
|
||||
pNode->mPrimaryCamera = s+1;
|
||||
}
|
||||
|
|
@ -2752,7 +2735,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
|
|||
{
|
||||
const char* s = mReader->getAttributeValue(attrID);
|
||||
if (s[0] != '#')
|
||||
ASSIMP_LOG_ERROR("Collada: Unresolved reference format of node");
|
||||
DefaultLogger::get()->error("Collada: Unresolved reference format of node");
|
||||
else
|
||||
{
|
||||
pNode->mNodeInstances.push_back(NodeInstance());
|
||||
|
|
@ -2770,7 +2753,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
|
|||
// Reference to a light, name given in 'url' attribute
|
||||
int attrID = TestAttribute("url");
|
||||
if (-1 == attrID)
|
||||
ASSIMP_LOG_WARN("Collada: Expected url attribute in <instance_light> element");
|
||||
DefaultLogger::get()->warn("Collada: Expected url attribute in <instance_light> element");
|
||||
else
|
||||
{
|
||||
const char* url = mReader->getAttributeValue( attrID);
|
||||
|
|
@ -2786,7 +2769,7 @@ void ColladaParser::ReadSceneNode( Node* pNode)
|
|||
// Reference to a camera, name given in 'url' attribute
|
||||
int attrID = TestAttribute("url");
|
||||
if (-1 == attrID)
|
||||
ASSIMP_LOG_WARN("Collada: Expected url attribute in <instance_camera> element");
|
||||
DefaultLogger::get()->warn("Collada: Expected url attribute in <instance_camera> element");
|
||||
else
|
||||
{
|
||||
const char* url = mReader->getAttributeValue( attrID);
|
||||
|
|
@ -2873,7 +2856,7 @@ void ColladaParser::ReadMaterialVertexInputBinding( Collada::SemanticMappingTabl
|
|||
tbl.mMap[s] = vn;
|
||||
}
|
||||
else if( IsElement( "bind")) {
|
||||
ASSIMP_LOG_WARN("Collada: Found unsupported <bind> element");
|
||||
DefaultLogger::get()->warn("Collada: Found unsupported <bind> element");
|
||||
}
|
||||
}
|
||||
else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
|
||||
|
|
@ -2992,9 +2975,10 @@ void ColladaParser::ReportWarning(const char* msg,...)
|
|||
ai_assert(iLen > 0);
|
||||
|
||||
va_end(args);
|
||||
ASSIMP_LOG_WARN_F("Validation warning: ", std::string(szBuffer,iLen));
|
||||
DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen));
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Skips all data until the end node of the current element
|
||||
void ColladaParser::SkipElement()
|
||||
|
|
@ -3105,7 +3089,7 @@ const char* ColladaParser::TestTextContent()
|
|||
// read contents of the element
|
||||
if( !mReader->read() )
|
||||
return NULL;
|
||||
if( mReader->getNodeType() != irr::io::EXN_TEXT && mReader->getNodeType() != irr::io::EXN_CDATA)
|
||||
if( mReader->getNodeType() != irr::io::EXN_TEXT)
|
||||
return NULL;
|
||||
|
||||
// skip leading whitespace
|
||||
|
|
@ -3189,7 +3173,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform( const std::vector<Transform
|
|||
Collada::InputType ColladaParser::GetTypeForSemantic( const std::string& semantic)
|
||||
{
|
||||
if ( semantic.empty() ) {
|
||||
ASSIMP_LOG_WARN("Vertex input type is empty." );
|
||||
DefaultLogger::get()->warn( format() << "Vertex input type is empty." );
|
||||
return IT_Invalid;
|
||||
}
|
||||
|
||||
|
|
@ -3208,7 +3192,7 @@ Collada::InputType ColladaParser::GetTypeForSemantic( const std::string& semanti
|
|||
else if( semantic == "TANGENT" || semantic == "TEXTANGENT")
|
||||
return IT_Tangent;
|
||||
|
||||
ASSIMP_LOG_WARN_F( "Unknown vertex input type \"", semantic, "\". Ignoring." );
|
||||
DefaultLogger::get()->warn( format() << "Unknown vertex input type \"" << semantic << "\". Ignoring." );
|
||||
return IT_Invalid;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue