|
@@ -422,7 +422,7 @@ void Parser::ParseLV1SoftSkinBlock() {
|
|
me.first = static_cast<int>(curMesh->mBones.size());
|
|
me.first = static_cast<int>(curMesh->mBones.size());
|
|
curMesh->mBones.emplace_back(bone);
|
|
curMesh->mBones.emplace_back(bone);
|
|
}
|
|
}
|
|
- ParseLV4MeshFloat(me.second);
|
|
|
|
|
|
+ ParseLV4MeshReal(me.second);
|
|
|
|
|
|
// Add the new bone weight to list
|
|
// Add the new bone weight to list
|
|
vert.mBoneWeights.push_back(me);
|
|
vert.mBoneWeights.push_back(me);
|
|
@@ -580,14 +580,14 @@ void Parser::ParseLV2MaterialBlock(ASE::Material &mat) {
|
|
}
|
|
}
|
|
// material transparency
|
|
// material transparency
|
|
if (TokenMatch(mFilePtr, "MATERIAL_TRANSPARENCY", 21)) {
|
|
if (TokenMatch(mFilePtr, "MATERIAL_TRANSPARENCY", 21)) {
|
|
- ParseLV4MeshFloat(mat.mTransparency);
|
|
|
|
|
|
+ ParseLV4MeshReal(mat.mTransparency);
|
|
mat.mTransparency = ai_real(1.0) - mat.mTransparency;
|
|
mat.mTransparency = ai_real(1.0) - mat.mTransparency;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// material self illumination
|
|
// material self illumination
|
|
if (TokenMatch(mFilePtr, "MATERIAL_SELFILLUM", 18)) {
|
|
if (TokenMatch(mFilePtr, "MATERIAL_SELFILLUM", 18)) {
|
|
ai_real f = 0.0;
|
|
ai_real f = 0.0;
|
|
- ParseLV4MeshFloat(f);
|
|
|
|
|
|
+ ParseLV4MeshReal(f);
|
|
|
|
|
|
mat.mEmissive.r = f;
|
|
mat.mEmissive.r = f;
|
|
mat.mEmissive.g = f;
|
|
mat.mEmissive.g = f;
|
|
@@ -596,7 +596,7 @@ void Parser::ParseLV2MaterialBlock(ASE::Material &mat) {
|
|
}
|
|
}
|
|
// material shininess
|
|
// material shininess
|
|
if (TokenMatch(mFilePtr, "MATERIAL_SHINE", 14)) {
|
|
if (TokenMatch(mFilePtr, "MATERIAL_SHINE", 14)) {
|
|
- ParseLV4MeshFloat(mat.mSpecularExponent);
|
|
|
|
|
|
+ ParseLV4MeshReal(mat.mSpecularExponent);
|
|
mat.mSpecularExponent *= 15;
|
|
mat.mSpecularExponent *= 15;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -607,7 +607,7 @@ void Parser::ParseLV2MaterialBlock(ASE::Material &mat) {
|
|
}
|
|
}
|
|
// material shininess strength
|
|
// material shininess strength
|
|
if (TokenMatch(mFilePtr, "MATERIAL_SHINESTRENGTH", 22)) {
|
|
if (TokenMatch(mFilePtr, "MATERIAL_SHINESTRENGTH", 22)) {
|
|
- ParseLV4MeshFloat(mat.mShininessStrength);
|
|
|
|
|
|
+ ParseLV4MeshReal(mat.mShininessStrength);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// diffuse color map
|
|
// diffuse color map
|
|
@@ -731,32 +731,32 @@ void Parser::ParseLV3MapBlock(Texture &map) {
|
|
}
|
|
}
|
|
// offset on the u axis
|
|
// offset on the u axis
|
|
if (TokenMatch(mFilePtr, "UVW_U_OFFSET", 12)) {
|
|
if (TokenMatch(mFilePtr, "UVW_U_OFFSET", 12)) {
|
|
- ParseLV4MeshFloat(map.mOffsetU);
|
|
|
|
|
|
+ ParseLV4MeshReal(map.mOffsetU);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// offset on the v axis
|
|
// offset on the v axis
|
|
if (TokenMatch(mFilePtr, "UVW_V_OFFSET", 12)) {
|
|
if (TokenMatch(mFilePtr, "UVW_V_OFFSET", 12)) {
|
|
- ParseLV4MeshFloat(map.mOffsetV);
|
|
|
|
|
|
+ ParseLV4MeshReal(map.mOffsetV);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// tiling on the u axis
|
|
// tiling on the u axis
|
|
if (TokenMatch(mFilePtr, "UVW_U_TILING", 12)) {
|
|
if (TokenMatch(mFilePtr, "UVW_U_TILING", 12)) {
|
|
- ParseLV4MeshFloat(map.mScaleU);
|
|
|
|
|
|
+ ParseLV4MeshReal(map.mScaleU);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// tiling on the v axis
|
|
// tiling on the v axis
|
|
if (TokenMatch(mFilePtr, "UVW_V_TILING", 12)) {
|
|
if (TokenMatch(mFilePtr, "UVW_V_TILING", 12)) {
|
|
- ParseLV4MeshFloat(map.mScaleV);
|
|
|
|
|
|
+ ParseLV4MeshReal(map.mScaleV);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// rotation around the z-axis
|
|
// rotation around the z-axis
|
|
if (TokenMatch(mFilePtr, "UVW_ANGLE", 9)) {
|
|
if (TokenMatch(mFilePtr, "UVW_ANGLE", 9)) {
|
|
- ParseLV4MeshFloat(map.mRotation);
|
|
|
|
|
|
+ ParseLV4MeshReal(map.mRotation);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// map blending factor
|
|
// map blending factor
|
|
if (TokenMatch(mFilePtr, "MAP_AMOUNT", 10)) {
|
|
if (TokenMatch(mFilePtr, "MAP_AMOUNT", 10)) {
|
|
- ParseLV4MeshFloat(map.mTextureBlend);
|
|
|
|
|
|
+ ParseLV4MeshReal(map.mTextureBlend);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -895,15 +895,15 @@ void Parser::ParseLV2CameraSettingsBlock(ASE::Camera &camera) {
|
|
if ('*' == *mFilePtr) {
|
|
if ('*' == *mFilePtr) {
|
|
++mFilePtr;
|
|
++mFilePtr;
|
|
if (TokenMatch(mFilePtr, "CAMERA_NEAR", 11)) {
|
|
if (TokenMatch(mFilePtr, "CAMERA_NEAR", 11)) {
|
|
- ParseLV4MeshFloat(camera.mNear);
|
|
|
|
|
|
+ ParseLV4MeshReal(camera.mNear);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (TokenMatch(mFilePtr, "CAMERA_FAR", 10)) {
|
|
if (TokenMatch(mFilePtr, "CAMERA_FAR", 10)) {
|
|
- ParseLV4MeshFloat(camera.mFar);
|
|
|
|
|
|
+ ParseLV4MeshReal(camera.mFar);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (TokenMatch(mFilePtr, "CAMERA_FOV", 10)) {
|
|
if (TokenMatch(mFilePtr, "CAMERA_FOV", 10)) {
|
|
- ParseLV4MeshFloat(camera.mFOV);
|
|
|
|
|
|
+ ParseLV4MeshReal(camera.mFOV);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -922,15 +922,15 @@ void Parser::ParseLV2LightSettingsBlock(ASE::Light &light) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (TokenMatch(mFilePtr, "LIGHT_INTENS", 12)) {
|
|
if (TokenMatch(mFilePtr, "LIGHT_INTENS", 12)) {
|
|
- ParseLV4MeshFloat(light.mIntensity);
|
|
|
|
|
|
+ ParseLV4MeshReal(light.mIntensity);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (TokenMatch(mFilePtr, "LIGHT_HOTSPOT", 13)) {
|
|
if (TokenMatch(mFilePtr, "LIGHT_HOTSPOT", 13)) {
|
|
- ParseLV4MeshFloat(light.mAngle);
|
|
|
|
|
|
+ ParseLV4MeshReal(light.mAngle);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (TokenMatch(mFilePtr, "LIGHT_FALLOFF", 13)) {
|
|
if (TokenMatch(mFilePtr, "LIGHT_FALLOFF", 13)) {
|
|
- ParseLV4MeshFloat(light.mFalloff);
|
|
|
|
|
|
+ ParseLV4MeshReal(light.mFalloff);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1038,7 +1038,7 @@ void Parser::ParseLV3ScaleAnimationBlock(ASE::Animation &anim) {
|
|
if (b) {
|
|
if (b) {
|
|
anim.akeyScaling.emplace_back();
|
|
anim.akeyScaling.emplace_back();
|
|
aiVectorKey &key = anim.akeyScaling.back();
|
|
aiVectorKey &key = anim.akeyScaling.back();
|
|
- ParseLV4MeshFloatTriple(&key.mValue.x, iIndex);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(&key.mValue.x, iIndex);
|
|
key.mTime = (double)iIndex;
|
|
key.mTime = (double)iIndex;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1077,7 +1077,7 @@ void Parser::ParseLV3PosAnimationBlock(ASE::Animation &anim) {
|
|
if (b) {
|
|
if (b) {
|
|
anim.akeyPositions.emplace_back();
|
|
anim.akeyPositions.emplace_back();
|
|
aiVectorKey &key = anim.akeyPositions.back();
|
|
aiVectorKey &key = anim.akeyPositions.back();
|
|
- ParseLV4MeshFloatTriple(&key.mValue.x, iIndex);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(&key.mValue.x, iIndex);
|
|
key.mTime = (double)iIndex;
|
|
key.mTime = (double)iIndex;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1118,8 +1118,8 @@ void Parser::ParseLV3RotAnimationBlock(ASE::Animation &anim) {
|
|
aiQuatKey &key = anim.akeyRotations.back();
|
|
aiQuatKey &key = anim.akeyRotations.back();
|
|
aiVector3D v;
|
|
aiVector3D v;
|
|
ai_real f;
|
|
ai_real f;
|
|
- ParseLV4MeshFloatTriple(&v.x, iIndex);
|
|
|
|
- ParseLV4MeshFloat(f);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(&v.x, iIndex);
|
|
|
|
+ ParseLV4MeshReal(f);
|
|
key.mTime = (double)iIndex;
|
|
key.mTime = (double)iIndex;
|
|
key.mValue = aiQuaternion(v, f);
|
|
key.mValue = aiQuaternion(v, f);
|
|
}
|
|
}
|
|
@@ -1163,23 +1163,23 @@ void Parser::ParseLV2NodeTransformBlock(ASE::BaseNode &mesh) {
|
|
// fourth row of the transformation matrix - and also the
|
|
// fourth row of the transformation matrix - and also the
|
|
// only information here that is interesting for targets
|
|
// only information here that is interesting for targets
|
|
if (TokenMatch(mFilePtr, "TM_ROW3", 7)) {
|
|
if (TokenMatch(mFilePtr, "TM_ROW3", 7)) {
|
|
- ParseLV4MeshFloatTriple((mode == 1 ? mesh.mTransform[3] : &mesh.mTargetPosition.x));
|
|
|
|
|
|
+ ParseLV4MeshRealTriple((mode == 1 ? mesh.mTransform[3] : &mesh.mTargetPosition.x));
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (mode == 1) {
|
|
if (mode == 1) {
|
|
// first row of the transformation matrix
|
|
// first row of the transformation matrix
|
|
if (TokenMatch(mFilePtr, "TM_ROW0", 7)) {
|
|
if (TokenMatch(mFilePtr, "TM_ROW0", 7)) {
|
|
- ParseLV4MeshFloatTriple(mesh.mTransform[0]);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(mesh.mTransform[0]);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// second row of the transformation matrix
|
|
// second row of the transformation matrix
|
|
if (TokenMatch(mFilePtr, "TM_ROW1", 7)) {
|
|
if (TokenMatch(mFilePtr, "TM_ROW1", 7)) {
|
|
- ParseLV4MeshFloatTriple(mesh.mTransform[1]);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(mesh.mTransform[1]);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// third row of the transformation matrix
|
|
// third row of the transformation matrix
|
|
if (TokenMatch(mFilePtr, "TM_ROW2", 7)) {
|
|
if (TokenMatch(mFilePtr, "TM_ROW2", 7)) {
|
|
- ParseLV4MeshFloatTriple(mesh.mTransform[2]);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(mesh.mTransform[2]);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// inherited position axes
|
|
// inherited position axes
|
|
@@ -1414,7 +1414,7 @@ void Parser::ParseLV4MeshBonesVertices(unsigned int iNumVertices, ASE::Mesh &mes
|
|
|
|
|
|
// --- ignored
|
|
// --- ignored
|
|
ai_real afVert[3];
|
|
ai_real afVert[3];
|
|
- ParseLV4MeshFloatTriple(afVert);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(afVert);
|
|
|
|
|
|
std::pair<int, float> pairOut;
|
|
std::pair<int, float> pairOut;
|
|
while (true) {
|
|
while (true) {
|
|
@@ -1453,7 +1453,7 @@ void Parser::ParseLV3MeshVertexListBlock(
|
|
|
|
|
|
aiVector3D vTemp;
|
|
aiVector3D vTemp;
|
|
unsigned int iIndex;
|
|
unsigned int iIndex;
|
|
- ParseLV4MeshFloatTriple(&vTemp.x, iIndex);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(&vTemp.x, iIndex);
|
|
|
|
|
|
if (iIndex >= iNumVertices) {
|
|
if (iIndex >= iNumVertices) {
|
|
LogWarning("Invalid vertex index. It will be ignored");
|
|
LogWarning("Invalid vertex index. It will be ignored");
|
|
@@ -1506,7 +1506,7 @@ void Parser::ParseLV3MeshTListBlock(unsigned int iNumVertices,
|
|
if (TokenMatch(mFilePtr, "MESH_TVERT", 10)) {
|
|
if (TokenMatch(mFilePtr, "MESH_TVERT", 10)) {
|
|
aiVector3D vTemp;
|
|
aiVector3D vTemp;
|
|
unsigned int iIndex;
|
|
unsigned int iIndex;
|
|
- ParseLV4MeshFloatTriple(&vTemp.x, iIndex);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(&vTemp.x, iIndex);
|
|
|
|
|
|
if (iIndex >= iNumVertices) {
|
|
if (iIndex >= iNumVertices) {
|
|
LogWarning("Tvertex has an invalid index. It will be ignored");
|
|
LogWarning("Tvertex has an invalid index. It will be ignored");
|
|
@@ -1657,7 +1657,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh &sMesh) {
|
|
++mFilePtr;
|
|
++mFilePtr;
|
|
if (faceIdx != UINT_MAX && TokenMatch(mFilePtr, "MESH_VERTEXNORMAL", 17)) {
|
|
if (faceIdx != UINT_MAX && TokenMatch(mFilePtr, "MESH_VERTEXNORMAL", 17)) {
|
|
aiVector3D vNormal;
|
|
aiVector3D vNormal;
|
|
- ParseLV4MeshFloatTriple(&vNormal.x, index);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(&vNormal.x, index);
|
|
if (faceIdx >= sMesh.mFaces.size())
|
|
if (faceIdx >= sMesh.mFaces.size())
|
|
continue;
|
|
continue;
|
|
|
|
|
|
@@ -1679,7 +1679,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh &sMesh) {
|
|
}
|
|
}
|
|
if (TokenMatch(mFilePtr, "MESH_FACENORMAL", 15)) {
|
|
if (TokenMatch(mFilePtr, "MESH_FACENORMAL", 15)) {
|
|
aiVector3D vNormal;
|
|
aiVector3D vNormal;
|
|
- ParseLV4MeshFloatTriple(&vNormal.x, faceIdx);
|
|
|
|
|
|
+ ParseLV4MeshRealTriple(&vNormal.x, faceIdx);
|
|
|
|
|
|
if (faceIdx >= sMesh.mFaces.size()) {
|
|
if (faceIdx >= sMesh.mFaces.size()) {
|
|
ASSIMP_LOG_ERROR("ASE: Invalid vertex index in MESH_FACENORMAL section");
|
|
ASSIMP_LOG_ERROR("ASE: Invalid vertex index in MESH_FACENORMAL section");
|
|
@@ -1844,7 +1844,17 @@ void Parser::ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut
|
|
ParseLV4MeshLongTriple(apOut);
|
|
ParseLV4MeshLongTriple(apOut);
|
|
}
|
|
}
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) {
|
|
|
|
|
|
+void Parser::ParseLV4MeshRealTriple(ai_real *apOut, unsigned int &rIndexOut) {
|
|
|
|
+ ai_assert(nullptr != apOut);
|
|
|
|
+
|
|
|
|
+ // parse the index
|
|
|
|
+ ParseLV4MeshLong(rIndexOut);
|
|
|
|
+
|
|
|
|
+ // parse the three others
|
|
|
|
+ ParseLV4MeshRealTriple(apOut);
|
|
|
|
+}
|
|
|
|
+// ------------------------------------------------------------------------------------------------
|
|
|
|
+void Parser::ParseLV4MeshFloatTriple(float* apOut, unsigned int& rIndexOut) {
|
|
ai_assert(nullptr != apOut);
|
|
ai_assert(nullptr != apOut);
|
|
|
|
|
|
// parse the index
|
|
// parse the index
|
|
@@ -1854,7 +1864,15 @@ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) {
|
|
ParseLV4MeshFloatTriple(apOut);
|
|
ParseLV4MeshFloatTriple(apOut);
|
|
}
|
|
}
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void Parser::ParseLV4MeshFloatTriple(ai_real *apOut) {
|
|
|
|
|
|
+void Parser::ParseLV4MeshRealTriple(ai_real *apOut) {
|
|
|
|
+ ai_assert(nullptr != apOut);
|
|
|
|
+
|
|
|
|
+ for (unsigned int i = 0; i < 3; ++i) {
|
|
|
|
+ ParseLV4MeshReal(apOut[i]);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+// ------------------------------------------------------------------------------------------------
|
|
|
|
+void Parser::ParseLV4MeshFloatTriple(float* apOut) {
|
|
ai_assert(nullptr != apOut);
|
|
ai_assert(nullptr != apOut);
|
|
|
|
|
|
for (unsigned int i = 0; i < 3; ++i) {
|
|
for (unsigned int i = 0; i < 3; ++i) {
|
|
@@ -1862,7 +1880,7 @@ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void Parser::ParseLV4MeshFloat(ai_real &fOut) {
|
|
|
|
|
|
+void Parser::ParseLV4MeshReal(ai_real &fOut) {
|
|
// skip spaces and tabs
|
|
// skip spaces and tabs
|
|
if (!SkipSpaces(&mFilePtr, mEnd)) {
|
|
if (!SkipSpaces(&mFilePtr, mEnd)) {
|
|
// LOG
|
|
// LOG
|
|
@@ -1875,6 +1893,19 @@ void Parser::ParseLV4MeshFloat(ai_real &fOut) {
|
|
mFilePtr = fast_atoreal_move<ai_real>(mFilePtr, fOut);
|
|
mFilePtr = fast_atoreal_move<ai_real>(mFilePtr, fOut);
|
|
}
|
|
}
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
+void Parser::ParseLV4MeshFloat(float &fOut) {
|
|
|
|
+ // skip spaces and tabs
|
|
|
|
+ if (!SkipSpaces(&mFilePtr, mEnd)) {
|
|
|
|
+ // LOG
|
|
|
|
+ LogWarning("Unable to parse float: unexpected EOL [#1]");
|
|
|
|
+ fOut = 0.0;
|
|
|
|
+ ++iLineNumber;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // parse the first float
|
|
|
|
+ mFilePtr = fast_atoreal_move<float>(mFilePtr, fOut);
|
|
|
|
+}
|
|
|
|
+// ------------------------------------------------------------------------------------------------
|
|
void Parser::ParseLV4MeshLong(unsigned int &iOut) {
|
|
void Parser::ParseLV4MeshLong(unsigned int &iOut) {
|
|
// Skip spaces and tabs
|
|
// Skip spaces and tabs
|
|
if (!SkipSpaces(&mFilePtr, mEnd)) {
|
|
if (!SkipSpaces(&mFilePtr, mEnd)) {
|