summaryrefslogtreecommitdiff
path: root/src/3rdparty/assimp/code/ColladaLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/assimp/code/ColladaLoader.cpp')
-rw-r--r--src/3rdparty/assimp/code/ColladaLoader.cpp84
1 files changed, 55 insertions, 29 deletions
diff --git a/src/3rdparty/assimp/code/ColladaLoader.cpp b/src/3rdparty/assimp/code/ColladaLoader.cpp
index bf807b8b6..86406aad9 100644
--- a/src/3rdparty/assimp/code/ColladaLoader.cpp
+++ b/src/3rdparty/assimp/code/ColladaLoader.cpp
@@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file Implementation of the Collada loader */
#include "AssimpPCH.h"
-#ifndef ASSIMP_BUILD_NO_DAE_IMPORTER
+#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
#include "../include/assimp/anim.h"
#include "ColladaLoader.h"
@@ -73,6 +73,7 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
ColladaLoader::ColladaLoader()
+: noSkeletonMesh(), ignoreUpDirection(false)
{}
// ------------------------------------------------------------------------------------------------
@@ -104,6 +105,14 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo
}
// ------------------------------------------------------------------------------------------------
+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;
+}
+
+
+// ------------------------------------------------------------------------------------------------
// Get file extension list
const aiImporterDesc* ColladaLoader::GetInfo () const
{
@@ -147,20 +156,26 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
// ... then fill the materials with the now adjusted settings
FillMaterials(parser, pScene);
- // 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 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);
+ }
// store all meshes
StoreSceneMeshes( pScene);
@@ -180,7 +195,9 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
// If no meshes have been loaded, it's probably just an animated skeleton.
if (!pScene->mNumMeshes) {
- SkeletonMeshBuilder hero(pScene);
+ if (!noSkeletonMesh) {
+ SkeletonMeshBuilder hero(pScene);
+ }
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
}
}
@@ -315,11 +332,11 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
out->mAngleInnerCone = AI_DEG_TO_RAD( srcLight->mFalloffAngle );
- // ... some extension magic. FUCKING COLLADA.
- if (srcLight->mOuterAngle == 10e10f)
+ // ... some extension magic.
+ if (srcLight->mOuterAngle >= ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET*(1-1e-6f))
{
- // ... some deprecation magic. FUCKING FCOLLADA.
- if (srcLight->mPenumbraAngle == 10e10f)
+ // ... some deprecation magic.
+ if (srcLight->mPenumbraAngle >= ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET*(1-1e-6f))
{
// Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess ....
// epsilon chosen to be 0.1
@@ -372,7 +389,7 @@ void ColladaLoader::BuildCamerasForNode( const ColladaParser& pParser, const Col
out->mClipPlaneNear = srcCamera->mZNear;
// ... but for the rest some values are optional
- // and we need to compute the others in any combination. FUCKING COLLADA.
+ // and we need to compute the others in any combination.
if (srcCamera->mAspect != 10e10f)
out->mAspect = srcCamera->mAspect;
@@ -456,7 +473,7 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
}
else
{
- DefaultLogger::get()->warn( boost::str( boost::format( "Collada: No material specified for subgroup \"%s\" in geometry \"%s\".") % submesh.mMaterial % mid.mMeshOrController));
+ DefaultLogger::get()->warn( boost::str( boost::format( "Collada: No material specified for subgroup <%s> in geometry <%s>.") % submesh.mMaterial % mid.mMeshOrController));
if( !mid.mMaterials.empty() )
meshMaterial = mid.mMaterials.begin()->second.mMatName;
}
@@ -504,7 +521,11 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
// assign the material index
dstMesh->mMaterialIndex = matIdx;
- }
+ if(dstMesh->mName.length == 0)
+ {
+ dstMesh->mName = mid.mMeshOrController;
+ }
+ }
}
}
@@ -523,6 +544,8 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
const Collada::Controller* pSrcController, size_t pStartVertex, size_t pStartFace)
{
aiMesh* dstMesh = new aiMesh;
+
+ dstMesh->mName = pSrcMesh->mName;
// count the vertices addressed by its faces
const size_t numVertices = std::accumulate( pSrcMesh->mFaceSize.begin() + pStartFace,
@@ -534,7 +557,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
std::copy( pSrcMesh->mPositions.begin() + pStartVertex, pSrcMesh->mPositions.begin() +
pStartVertex + numVertices, dstMesh->mVertices);
- // normals, if given. HACK: (thom) Due to the fucking Collada spec we never
+ // normals, if given. HACK: (thom) Due to the glorious Collada spec we never
// know if we have the same number of normals as there are positions. So we
// also ignore any vertex attribute if it has a different count
if( pSrcMesh->mNormals.size() >= pStartVertex + numVertices)
@@ -625,7 +648,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
throw DeadlyImportError( "Data type mismatch while resolving mesh joints");
// sanity check: we rely on the vertex weights always coming as pairs of BoneIndex-WeightIndex
if( pSrcController->mWeightInputJoints.mOffset != 0 || pSrcController->mWeightInputWeights.mOffset != 1)
- throw DeadlyImportError( "Unsupported vertex_weight adresssing scheme. Fucking collada spec.");
+ throw DeadlyImportError( "Unsupported vertex_weight addressing scheme. ");
// create containers to collect the weights for each bone
size_t numBones = jointNames.mStrings.size();
@@ -956,7 +979,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
else if( subElement == "Z")
entry.mSubElement = 2;
else
- DefaultLogger::get()->warn( boost::str( boost::format( "Unknown anim subelement \"%s\". Ignoring") % subElement));
+ DefaultLogger::get()->warn( boost::str( boost::format( "Unknown anim subelement <%s>. Ignoring") % subElement));
} else
{
// no subelement following, transformId is remaining string
@@ -1434,13 +1457,16 @@ void ColladaLoader::ConvertPath (aiString& ss)
ss.data[ss.length] = 0;
}
- // find and convert all %xyz special chars
+ // find and convert all %xy special chars
char* out = ss.data;
for( const char* it = ss.data; it != ss.data + ss.length; /**/ )
{
- if( *it == '%' )
+ if( *it == '%' && (it + 3) < ss.data + ss.length )
{
- size_t nbr = strtoul16( ++it, &it);
+ // separate the number to avoid dragging in chars from behind into the parsing
+ char mychar[3] = { it[1], it[2], 0 };
+ size_t nbr = strtoul16( mychar);
+ it += 3;
*out++ = (char)(nbr & 0xFF);
} else
{