mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-21 15:43:45 +00:00
Updated assimp to latest
This commit is contained in:
parent
25ce4477ce
commit
161bf7f83b
461 changed files with 34662 additions and 30165 deletions
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -46,23 +47,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
|
||||
|
||||
#include "ColladaLoader.h"
|
||||
#include "ColladaParser.h"
|
||||
|
||||
#include <assimp/anim.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/Defines.h>
|
||||
|
||||
#include "ColladaParser.h"
|
||||
#include "fast_atof.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "SkeletonMeshBuilder.h"
|
||||
#include "CreateAnimMesh.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/SkeletonMeshBuilder.h>
|
||||
#include <assimp/CreateAnimMesh.h>
|
||||
|
||||
#include "time.h"
|
||||
#include "math.h"
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <assimp/Defines.h>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::Formatter;
|
||||
|
|
@ -83,34 +85,37 @@ static const aiImporterDesc desc = {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
ColladaLoader::ColladaLoader()
|
||||
: mFileName()
|
||||
, mMeshIndexByID()
|
||||
, mMaterialIndexByName()
|
||||
, mMeshes()
|
||||
, newMats()
|
||||
, mCameras()
|
||||
, mLights()
|
||||
, mTextures()
|
||||
, mAnims()
|
||||
, noSkeletonMesh( false )
|
||||
, ignoreUpDirection(false)
|
||||
, mNodeNameCounter( 0 )
|
||||
{}
|
||||
: mFileName()
|
||||
, mMeshIndexByID()
|
||||
, mMaterialIndexByName()
|
||||
, mMeshes()
|
||||
, newMats()
|
||||
, mCameras()
|
||||
, mLights()
|
||||
, mTextures()
|
||||
, mAnims()
|
||||
, noSkeletonMesh( false )
|
||||
, ignoreUpDirection(false)
|
||||
, useColladaName( false )
|
||||
, mNodeNameCounter( 0 ) {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
ColladaLoader::~ColladaLoader()
|
||||
{}
|
||||
ColladaLoader::~ColladaLoader() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
{
|
||||
bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||
// check file extension
|
||||
std::string extension = GetExtension(pFile);
|
||||
|
||||
if( extension == "dae")
|
||||
if (extension == "dae") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// XML - too generic, we need to open the file and search for typical keywords
|
||||
if( extension == "xml" || !extension.length() || checkSig) {
|
||||
|
|
@ -118,10 +123,13 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo
|
|||
* support a specific file extension in general pIOHandler
|
||||
* might be NULL and it's our duty to return true here.
|
||||
*/
|
||||
if (!pIOHandler)return true;
|
||||
if (!pIOHandler) {
|
||||
return true;
|
||||
}
|
||||
const char* tokens[] = {"<collada"};
|
||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +138,7 @@ void ColladaLoader::SetupProperties(const Importer* pImp)
|
|||
{
|
||||
noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0;
|
||||
ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0;
|
||||
useColladaName = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES,0) != 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -141,8 +150,7 @@ const aiImporterDesc* ColladaLoader::GetInfo () const
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
|
||||
mFileName = pFile;
|
||||
|
||||
// clean all member arrays - just for safety, it should work even if we did not
|
||||
|
|
@ -178,26 +186,27 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
|
|||
// ... then fill the materials with the now adjusted settings
|
||||
FillMaterials(parser, pScene);
|
||||
|
||||
// Apply unitsize scale calculation
|
||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0,
|
||||
0, parser.mUnitSize, 0, 0,
|
||||
0, 0, parser.mUnitSize, 0,
|
||||
0, 0, 0, 1);
|
||||
if( !ignoreUpDirection ) {
|
||||
// Convert to Y_UP, if different orientation
|
||||
if( parser.mUpDirection == ColladaParser::UP_X)
|
||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
||||
0, -1, 0, 0,
|
||||
1, 0, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1);
|
||||
else if( parser.mUpDirection == ColladaParser::UP_Z)
|
||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
||||
1, 0, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, -1, 0, 0,
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
// Apply unit-size scale calculation
|
||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0,
|
||||
0, parser.mUnitSize, 0, 0,
|
||||
0, 0, parser.mUnitSize, 0,
|
||||
0, 0, 0, 1);
|
||||
if( !ignoreUpDirection ) {
|
||||
// Convert to Y_UP, if different orientation
|
||||
if( parser.mUpDirection == ColladaParser::UP_X)
|
||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
||||
0, -1, 0, 0,
|
||||
1, 0, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1);
|
||||
else if( parser.mUpDirection == ColladaParser::UP_Z)
|
||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
||||
1, 0, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, -1, 0, 0,
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
|
||||
// store all meshes
|
||||
StoreSceneMeshes( pScene);
|
||||
|
||||
|
|
@ -291,7 +300,7 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co
|
|||
nd = FindNode(pParser.mRootNode, nodeInst.mNode);
|
||||
}
|
||||
if (!nd)
|
||||
DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + nodeInst.mNode);
|
||||
ASSIMP_LOG_ERROR_F("Collada: Unable to resolve reference to instanced node ", nodeInst.mNode);
|
||||
|
||||
else {
|
||||
// attach this node to the list of children
|
||||
|
|
@ -308,7 +317,7 @@ void ColladaLoader::ApplyVertexToEffectSemanticMapping(Collada::Sampler& sampler
|
|||
std::map<std::string, Collada::InputSemanticMapEntry>::const_iterator it = table.mMap.find(sampler.mUVChannel);
|
||||
if (it != table.mMap.end()) {
|
||||
if (it->second.mType != Collada::IT_Texcoord)
|
||||
DefaultLogger::get()->error("Collada: Unexpected effect input mapping");
|
||||
ASSIMP_LOG_ERROR("Collada: Unexpected effect input mapping");
|
||||
|
||||
sampler.mUVId = it->second.mSet;
|
||||
}
|
||||
|
|
@ -324,7 +333,7 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
|
|||
ColladaParser::LightLibrary::const_iterator srcLightIt = pParser.mLightLibrary.find( lid.mLight);
|
||||
if( srcLightIt == pParser.mLightLibrary.end())
|
||||
{
|
||||
DefaultLogger::get()->warn("Collada: Unable to find light for ID \"" + lid.mLight + "\". Skipping.");
|
||||
ASSIMP_LOG_WARN_F("Collada: Unable to find light for ID \"" , lid.mLight , "\". Skipping.");
|
||||
continue;
|
||||
}
|
||||
const Collada::Light* srcLight = &srcLightIt->second;
|
||||
|
|
@ -392,14 +401,14 @@ void ColladaLoader::BuildCamerasForNode( const ColladaParser& pParser, const Col
|
|||
ColladaParser::CameraLibrary::const_iterator srcCameraIt = pParser.mCameraLibrary.find( cid.mCamera);
|
||||
if( srcCameraIt == pParser.mCameraLibrary.end())
|
||||
{
|
||||
DefaultLogger::get()->warn("Collada: Unable to find camera for ID \"" + cid.mCamera + "\". Skipping.");
|
||||
ASSIMP_LOG_WARN_F("Collada: Unable to find camera for ID \"" , cid.mCamera , "\". Skipping.");
|
||||
continue;
|
||||
}
|
||||
const Collada::Camera* srcCamera = &srcCameraIt->second;
|
||||
|
||||
// orthographic cameras not yet supported in Assimp
|
||||
if (srcCamera->mOrtho) {
|
||||
DefaultLogger::get()->warn("Collada: Orthographic cameras are not supported.");
|
||||
ASSIMP_LOG_WARN("Collada: Orthographic cameras are not supported.");
|
||||
}
|
||||
|
||||
// now fill our ai data structure
|
||||
|
|
@ -469,7 +478,7 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
|
|||
|
||||
if( !srcMesh)
|
||||
{
|
||||
DefaultLogger::get()->warn( format() << "Collada: Unable to find geometry for ID \"" << mid.mMeshOrController << "\". Skipping." );
|
||||
ASSIMP_LOG_WARN_F( "Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping." );
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
|
|
@ -498,7 +507,8 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
|
|||
}
|
||||
else
|
||||
{
|
||||
DefaultLogger::get()->warn( format() << "Collada: No material specified for subgroup <" << submesh.mMaterial << "> in geometry <" << mid.mMeshOrController << ">." );
|
||||
ASSIMP_LOG_WARN_F( "Collada: No material specified for subgroup <", submesh.mMaterial, "> in geometry <",
|
||||
mid.mMeshOrController, ">." );
|
||||
if( !mid.mMaterials.empty() )
|
||||
meshMaterial = mid.mMaterials.begin()->second.mMatName;
|
||||
}
|
||||
|
|
@ -720,8 +730,11 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
|
|||
std::vector<aiAnimMesh*> animMeshes;
|
||||
for (unsigned int i = 0; i < targetMeshes.size(); i++)
|
||||
{
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(targetMeshes.at(i));
|
||||
animMesh->mWeight = targetWeights[i];
|
||||
aiMesh* targetMesh = targetMeshes.at(i);
|
||||
aiAnimMesh *animMesh = aiCreateAnimMesh(targetMesh);
|
||||
float weight = targetWeights[i];
|
||||
animMesh->mWeight = weight == 0 ? 1.0f : weight;
|
||||
animMesh->mName = targetMesh->mName;
|
||||
animMeshes.push_back(animMesh);
|
||||
}
|
||||
dstMesh->mMethod = (method == Collada::Relative)
|
||||
|
|
@ -736,10 +749,6 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
|
|||
// create bones if given
|
||||
if( pSrcController && pSrcController->mType == Collada::Skin)
|
||||
{
|
||||
// refuse if the vertex count does not match
|
||||
// if( pSrcController->mWeightCounts.size() != dstMesh->mNumVertices)
|
||||
// throw DeadlyImportError( "Joint Controller vertex count does not match mesh vertex count");
|
||||
|
||||
// resolve references - joint names
|
||||
const Collada::Accessor& jointNamesAcc = pParser.ResolveLibraryReference( pParser.mAccessorLibrary, pSrcController->mJointNameSource);
|
||||
const Collada::Data& jointNames = pParser.ResolveLibraryReference( pParser.mDataLibrary, jointNamesAcc.mSource);
|
||||
|
|
@ -871,7 +880,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
|
|||
if( bnode)
|
||||
bone->mName.Set( FindNameForNode( bnode));
|
||||
else
|
||||
DefaultLogger::get()->warn( format() << "ColladaLoader::CreateMesh(): could not find corresponding node for joint \"" << bone->mName.data << "\"." );
|
||||
ASSIMP_LOG_WARN_F( "ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\"." );
|
||||
|
||||
// and insert bone
|
||||
dstMesh->mBones[boneCount++] = bone;
|
||||
|
|
@ -952,7 +961,7 @@ void ColladaLoader::StoreSceneMaterials( aiScene* pScene)
|
|||
// Stores all animations
|
||||
void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser)
|
||||
{
|
||||
// recursivly collect all animations from the collada scene
|
||||
// recursively collect all animations from the collada scene
|
||||
StoreAnimations( pScene, pParser, &pParser.mAnims, "");
|
||||
|
||||
// catch special case: many animations with the same length, each affecting only a single node.
|
||||
|
|
@ -967,7 +976,8 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
|
|||
for( size_t b = a+1; b < mAnims.size(); ++b)
|
||||
{
|
||||
aiAnimation* other = mAnims[b];
|
||||
if( other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration && other->mTicksPerSecond == templateAnim->mTicksPerSecond )
|
||||
if( other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration &&
|
||||
other->mTicksPerSecond == templateAnim->mTicksPerSecond )
|
||||
collectedAnimIndices.push_back( b);
|
||||
}
|
||||
|
||||
|
|
@ -1119,6 +1129,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
continue;
|
||||
|
||||
// now check all channels if they affect the current node
|
||||
std::string targetID, subElement;
|
||||
for( std::vector<Collada::AnimationChannel>::const_iterator cit = pSrcAnim->mChannels.begin();
|
||||
cit != pSrcAnim->mChannels.end(); ++cit)
|
||||
{
|
||||
|
|
@ -1145,7 +1156,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
}
|
||||
if( srcChannel.mTarget.find( '/', slashPos+1) != std::string::npos)
|
||||
continue;
|
||||
std::string targetID = srcChannel.mTarget.substr( 0, slashPos);
|
||||
|
||||
targetID.clear();
|
||||
targetID = srcChannel.mTarget.substr( 0, slashPos);
|
||||
if( targetID != srcNode->mID)
|
||||
continue;
|
||||
|
||||
|
|
@ -1158,7 +1171,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
|
||||
entry.mTransformId = srcChannel.mTarget.substr( slashPos+1, dotPos - slashPos - 1);
|
||||
|
||||
std::string subElement = srcChannel.mTarget.substr( dotPos+1);
|
||||
subElement.clear();
|
||||
subElement = srcChannel.mTarget.substr( dotPos+1);
|
||||
if( subElement == "ANGLE")
|
||||
entry.mSubElement = 3; // last number in an Axis-Angle-Transform is the angle
|
||||
else if( subElement == "X")
|
||||
|
|
@ -1168,9 +1182,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
else if( subElement == "Z")
|
||||
entry.mSubElement = 2;
|
||||
else
|
||||
DefaultLogger::get()->warn( format() << "Unknown anim subelement <" << subElement << ">. Ignoring" );
|
||||
} else
|
||||
{
|
||||
ASSIMP_LOG_WARN_F( "Unknown anim subelement <", subElement, ">. Ignoring" );
|
||||
} else {
|
||||
// no subelement following, transformId is remaining string
|
||||
entry.mTransformId = srcChannel.mTarget.substr( slashPos+1);
|
||||
}
|
||||
|
|
@ -1179,7 +1192,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
if (bracketPos != std::string::npos)
|
||||
{
|
||||
entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1, bracketPos - slashPos - 1);
|
||||
std::string subElement = srcChannel.mTarget.substr(bracketPos);
|
||||
subElement.clear();
|
||||
subElement = srcChannel.mTarget.substr(bracketPos);
|
||||
|
||||
if (subElement == "(0)(0)")
|
||||
entry.mSubElement = 0;
|
||||
|
|
@ -1213,7 +1227,6 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
entry.mSubElement = 14;
|
||||
else if (subElement == "(3)(3)")
|
||||
entry.mSubElement = 15;
|
||||
|
||||
}
|
||||
|
||||
// determine which transform step is affected by this channel
|
||||
|
|
@ -1399,7 +1412,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
|||
anims.push_back( dstAnim);
|
||||
} else
|
||||
{
|
||||
DefaultLogger::get()->warn( "Collada loader: found empty animation channel, ignored. Please check your exporter.");
|
||||
ASSIMP_LOG_WARN( "Collada loader: found empty animation channel, ignored. Please check your exporter.");
|
||||
}
|
||||
|
||||
if( !entries.empty() && entries.front().mTimeAccessor->mCount > 0 )
|
||||
|
|
@ -1554,7 +1567,7 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser,
|
|||
}
|
||||
}
|
||||
if (-1 == map) {
|
||||
DefaultLogger::get()->warn("Collada: unable to determine UV channel for texture");
|
||||
ASSIMP_LOG_WARN("Collada: unable to determine UV channel for texture");
|
||||
map = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1591,7 +1604,7 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce
|
|||
break;
|
||||
|
||||
default:
|
||||
DefaultLogger::get()->warn("Collada: Unrecognized shading mode, using gouraud shading");
|
||||
ASSIMP_LOG_WARN("Collada: Unrecognized shading mode, using gouraud shading");
|
||||
shadeMode = aiShadingMode_Gouraud;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1650,9 +1663,10 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce
|
|||
}
|
||||
|
||||
// add textures, if given
|
||||
if( !effect.mTexAmbient.mName.empty())
|
||||
/* It is merely a lightmap */
|
||||
AddTexture( mat, pParser, effect, effect.mTexAmbient, aiTextureType_LIGHTMAP);
|
||||
if (!effect.mTexAmbient.mName.empty()) {
|
||||
// It is merely a light-map
|
||||
AddTexture(mat, pParser, effect, effect.mTexAmbient, aiTextureType_LIGHTMAP);
|
||||
}
|
||||
|
||||
if( !effect.mTexEmissive.mName.empty())
|
||||
AddTexture( mat, pParser, effect, effect.mTexEmissive, aiTextureType_EMISSIVE);
|
||||
|
|
@ -1680,8 +1694,8 @@ void ColladaLoader::BuildMaterials( ColladaParser& pParser, aiScene* /*pScene*/)
|
|||
{
|
||||
newMats.reserve(pParser.mMaterialLibrary.size());
|
||||
|
||||
for( ColladaParser::MaterialLibrary::const_iterator matIt = pParser.mMaterialLibrary.begin(); matIt != pParser.mMaterialLibrary.end(); ++matIt)
|
||||
{
|
||||
for( ColladaParser::MaterialLibrary::const_iterator matIt = pParser.mMaterialLibrary.begin();
|
||||
matIt != pParser.mMaterialLibrary.end(); ++matIt) {
|
||||
const Collada::Material& material = matIt->second;
|
||||
// a material is only a reference to an effect
|
||||
ColladaParser::EffectLibrary::iterator effIt = pParser.mEffectLibrary.find( material.mEffect);
|
||||
|
|
@ -1745,11 +1759,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars
|
|||
ColladaParser::ImageLibrary::const_iterator imIt = pParser.mImageLibrary.find( name);
|
||||
if( imIt == pParser.mImageLibrary.end())
|
||||
{
|
||||
//missing texture should not stop the conversion
|
||||
//throw DeadlyImportError( format() <<
|
||||
// "Collada: Unable to resolve effect texture entry \"" << pName << "\", ended up at ID \"" << name << "\"." );
|
||||
|
||||
DefaultLogger::get()->warn("Collada: Unable to resolve effect texture entry \"" + pName + "\", ended up at ID \"" + name + "\".");
|
||||
ASSIMP_LOG_WARN_F("Collada: Unable to resolve effect texture entry \"", pName, "\", ended up at ID \"", name, "\".");
|
||||
|
||||
//set default texture file name
|
||||
result.Set(name + ".jpg");
|
||||
|
|
@ -1768,7 +1778,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars
|
|||
|
||||
// setup format hint
|
||||
if (imIt->second.mEmbeddedFormat.length() > 3) {
|
||||
DefaultLogger::get()->warn("Collada: texture format hint is too long, truncating to 3 characters");
|
||||
ASSIMP_LOG_WARN("Collada: texture format hint is too long, truncating to 3 characters");
|
||||
}
|
||||
strncpy(tex->achFormatHint,imIt->second.mEmbeddedFormat.c_str(),3);
|
||||
|
||||
|
|
@ -1778,6 +1788,11 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars
|
|||
tex->pcData = (aiTexel*)new char[tex->mWidth];
|
||||
memcpy(tex->pcData,&imIt->second.mImageData[0],tex->mWidth);
|
||||
|
||||
// TODO: check the possibility of using the flag "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING"
|
||||
// In FBX files textures are now stored internally by Assimp with their filename included
|
||||
// Now Assimp can lookup through the loaded textures after all data is processed
|
||||
// We need to load all textures before referencing them, as FBX file format order may reference a texture before loading it
|
||||
// This may occur on this case too, it has to be studied
|
||||
// setup texture reference string
|
||||
result.data[0] = '*';
|
||||
result.length = 1 + ASSIMP_itoa10(result.data+1,static_cast<unsigned int>(MAXLEN-1),static_cast<int32_t>(mTextures.size()));
|
||||
|
|
@ -1799,7 +1814,7 @@ void ColladaLoader::ConvertPath (aiString& ss)
|
|||
{
|
||||
// TODO: collada spec, p 22. Handle URI correctly.
|
||||
// For the moment we're just stripping the file:// away to make it work.
|
||||
// Windoes doesn't seem to be able to find stuff like
|
||||
// Windows doesn't seem to be able to find stuff like
|
||||
// 'file://..\LWO\LWO2\MappingModes\earthSpherical.jpg'
|
||||
if (0 == strncmp(ss.data,"file://",7))
|
||||
{
|
||||
|
|
@ -1810,10 +1825,13 @@ void ColladaLoader::ConvertPath (aiString& ss)
|
|||
|
||||
// Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes...
|
||||
// I need to filter it without destroying linux paths starting with "/somewhere"
|
||||
if( ss.data[0] == '/' && isalpha( ss.data[1]) && ss.data[2] == ':' )
|
||||
{
|
||||
ss.length--;
|
||||
memmove( ss.data, ss.data+1, ss.length);
|
||||
#if defined( _MSC_VER )
|
||||
if( ss.data[0] == '/' && isalpha( (unsigned char) ss.data[1]) && ss.data[2] == ':' ) {
|
||||
#else
|
||||
if (ss.data[ 0 ] == '/' && isalpha( ss.data[ 1 ] ) && ss.data[ 2 ] == ':') {
|
||||
#endif
|
||||
--ss.length;
|
||||
::memmove( ss.data, ss.data+1, ss.length);
|
||||
ss.data[ss.length] = 0;
|
||||
}
|
||||
|
||||
|
|
@ -1863,9 +1881,9 @@ const std::string& ColladaLoader::ReadString( const Collada::Accessor& pAccessor
|
|||
void ColladaLoader::CollectNodes( const aiNode* pNode, std::vector<const aiNode*>& poNodes) const
|
||||
{
|
||||
poNodes.push_back( pNode);
|
||||
|
||||
for( size_t a = 0; a < pNode->mNumChildren; ++a)
|
||||
CollectNodes( pNode->mChildren[a], poNodes);
|
||||
for (size_t a = 0; a < pNode->mNumChildren; ++a) {
|
||||
CollectNodes(pNode->mChildren[a], poNodes);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -1907,17 +1925,29 @@ const Collada::Node* ColladaLoader::FindNodeBySID( const Collada::Node* pNode, c
|
|||
// The name must be unique for proper node-bone association.
|
||||
std::string ColladaLoader::FindNameForNode( const Collada::Node* pNode)
|
||||
{
|
||||
// Now setup the name of the assimp node. The collada name might not be
|
||||
// unique, so we use the collada ID.
|
||||
if (!pNode->mID.empty())
|
||||
return pNode->mID;
|
||||
else if (!pNode->mSID.empty())
|
||||
return pNode->mSID;
|
||||
else
|
||||
// If explicitly requested, just use the collada name.
|
||||
if (useColladaName)
|
||||
{
|
||||
// No need to worry. Unnamed nodes are no problem at all, except
|
||||
// if cameras or lights need to be assigned to them.
|
||||
return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
|
||||
if (!pNode->mName.empty()) {
|
||||
return pNode->mName;
|
||||
} else {
|
||||
return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now setup the name of the assimp node. The collada name might not be
|
||||
// unique, so we use the collada ID.
|
||||
if (!pNode->mID.empty())
|
||||
return pNode->mID;
|
||||
else if (!pNode->mSID.empty())
|
||||
return pNode->mSID;
|
||||
else
|
||||
{
|
||||
// No need to worry. Unnamed nodes are no problem at all, except
|
||||
// if cameras or lights need to be assigned to them.
|
||||
return format() << "$ColladaAutoName$_" << mNodeNameCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue