ASE bugfix - light source sections are handled correctly now, unknown subchunks, too.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@118 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2008-08-28 23:00:03 +00:00
parent 64400f9123
commit cae8563764
2 changed files with 5 additions and 54 deletions

View File

@ -89,7 +89,7 @@ using namespace Assimp::ASE;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#define AI_ASE_HANDLE_SECTION(iDepth, level, msg) \ #define AI_ASE_HANDLE_SECTION(iDepth, level, msg) \
else if ('{' == *this->m_szFile)iDepth++; \ if ('{' == *this->m_szFile)iDepth++; \
else if ('}' == *this->m_szFile) \ else if ('}' == *this->m_szFile) \
{ \ { \
if (0 == --iDepth) \ if (0 == --iDepth) \
@ -201,18 +201,6 @@ bool Parser::SkipToNextToken()
} }
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool Parser::SkipOpeningBracket()
{
if (!SkipSpaces(this->m_szFile,&this->m_szFile))return false;
if ('{' != *this->m_szFile)
{
this->LogWarning("Unable to parse block: Unexpected character, \'{\' expected [#1]");
return false;
}
this->SkipToNextToken();
return true;
}
// ------------------------------------------------------------------------------------------------
bool Parser::SkipSection() bool Parser::SkipSection()
{ {
// must handle subsections ... // must handle subsections ...
@ -308,6 +296,7 @@ void Parser::Parse()
{ {
this->m_szFile+=13; this->m_szFile+=13;
this->LogInfo("Found light source (*LIGHTOBJECT chunk). It will be ignored"); this->LogInfo("Found light source (*LIGHTOBJECT chunk). It will be ignored");
SkipSection();
continue; continue;
} }
if (0 == strncmp(this->m_szFile,"*CAMERAOBJECT",13) && if (0 == strncmp(this->m_szFile,"*CAMERAOBJECT",13) &&
@ -315,6 +304,7 @@ void Parser::Parse()
{ {
this->m_szFile+=14; this->m_szFile+=14;
this->LogInfo("Found virtual camera (*CAMERAOBJECT chunk). It will be ignored"); this->LogInfo("Found virtual camera (*CAMERAOBJECT chunk). It will be ignored");
SkipSection();
continue; continue;
} }
if (0 == strncmp(this->m_szFile,"*COMMENT",8) && if (0 == strncmp(this->m_szFile,"*COMMENT",8) &&
@ -425,10 +415,6 @@ void Parser::ParseLV1MaterialListBlock()
// get a reference to the material // get a reference to the material
Material& sMat = this->m_vMaterials[iIndex+iOldMaterialCount]; Material& sMat = this->m_vMaterials[iIndex+iOldMaterialCount];
// skip the '{'
this->SkipOpeningBracket();
// parse the material block // parse the material block
this->ParseLV2MaterialBlock(sMat); this->ParseLV2MaterialBlock(sMat);
continue; continue;
@ -555,8 +541,6 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
IsSpaceOrNewLine(*(this->m_szFile+12))) IsSpaceOrNewLine(*(this->m_szFile+12)))
{ {
this->m_szFile+=13; this->m_szFile+=13;
// skip the opening bracket
this->SkipOpeningBracket();
// parse the texture block // parse the texture block
this->ParseLV3MapBlock(mat.sTexDiffuse);continue; this->ParseLV3MapBlock(mat.sTexDiffuse);continue;
} }
@ -565,8 +549,6 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
IsSpaceOrNewLine(*(this->m_szFile+12))) IsSpaceOrNewLine(*(this->m_szFile+12)))
{ {
this->m_szFile+=13; this->m_szFile+=13;
// skip the opening bracket
this->SkipOpeningBracket();
// parse the texture block // parse the texture block
this->ParseLV3MapBlock(mat.sTexAmbient);continue; this->ParseLV3MapBlock(mat.sTexAmbient);continue;
} }
@ -575,8 +557,6 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
IsSpaceOrNewLine(*(this->m_szFile+13))) IsSpaceOrNewLine(*(this->m_szFile+13)))
{ {
this->m_szFile+=14; this->m_szFile+=14;
// skip the opening bracket
this->SkipOpeningBracket();
// parse the texture block // parse the texture block
this->ParseLV3MapBlock(mat.sTexSpecular);continue; this->ParseLV3MapBlock(mat.sTexSpecular);continue;
} }
@ -585,8 +565,6 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
IsSpaceOrNewLine(*(this->m_szFile+12))) IsSpaceOrNewLine(*(this->m_szFile+12)))
{ {
this->m_szFile+=13; this->m_szFile+=13;
// skip the opening bracket
this->SkipOpeningBracket();
// parse the texture block // parse the texture block
this->ParseLV3MapBlock(mat.sTexOpacity);continue; this->ParseLV3MapBlock(mat.sTexOpacity);continue;
} }
@ -595,8 +573,6 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
IsSpaceOrNewLine(*(this->m_szFile+14))) IsSpaceOrNewLine(*(this->m_szFile+14)))
{ {
this->m_szFile+=15; this->m_szFile+=15;
// skip the opening bracket
this->SkipOpeningBracket();
// parse the texture block // parse the texture block
this->ParseLV3MapBlock(mat.sTexEmissive);continue; this->ParseLV3MapBlock(mat.sTexEmissive);continue;
} }
@ -605,18 +581,14 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
IsSpaceOrNewLine(*(this->m_szFile+9))) IsSpaceOrNewLine(*(this->m_szFile+9)))
{ {
this->m_szFile+=10; this->m_szFile+=10;
// skip the opening bracket
this->SkipOpeningBracket();
// parse the texture block // parse the texture block
this->ParseLV3MapBlock(mat.sTexBump); this->ParseLV3MapBlock(mat.sTexBump);
} }
// specular/shininess map // specular/shininess map
if (0 == strncmp(this->m_szFile,"*MAP_SHINE",10) && if (0 == strncmp(this->m_szFile,"*MAP_SHINESTRENGTH",18) &&
IsSpaceOrNewLine(*(this->m_szFile+10))) IsSpaceOrNewLine(*(this->m_szFile+18)))
{ {
this->m_szFile+=11; this->m_szFile+=11;
// skip the opening bracket
this->SkipOpeningBracket();
// parse the texture block // parse the texture block
this->ParseLV3MapBlock(mat.sTexShininess);continue; this->ParseLV3MapBlock(mat.sTexShininess);continue;
} }
@ -648,9 +620,6 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
// get a reference to the material // get a reference to the material
Material& sMat = mat.avSubMaterials[iIndex]; Material& sMat = mat.avSubMaterials[iIndex];
// skip the '{'
this->SkipOpeningBracket();
// parse the material block // parse the material block
this->ParseLV2MaterialBlock(sMat); this->ParseLV2MaterialBlock(sMat);
continue; continue;
@ -1051,7 +1020,6 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV3MeshFaceListBlock(iNumFaces,mesh);continue; this->ParseLV3MeshFaceListBlock(iNumFaces,mesh);continue;
} }
// mesh texture vertex list block // mesh texture vertex list block
@ -1059,7 +1027,6 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV3MeshTListBlock(iNumTVertices,mesh);continue; this->ParseLV3MeshTListBlock(iNumTVertices,mesh);continue;
} }
// mesh texture face block // mesh texture face block
@ -1067,7 +1034,6 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV3MeshTFaceListBlock(iNumTFaces,mesh);continue; this->ParseLV3MeshTFaceListBlock(iNumTFaces,mesh);continue;
} }
// mesh color vertex list block // mesh color vertex list block
@ -1075,7 +1041,6 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV3MeshCListBlock(iNumCVertices,mesh);continue; this->ParseLV3MeshCListBlock(iNumCVertices,mesh);continue;
} }
// mesh color face block // mesh color face block
@ -1083,7 +1048,6 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV3MeshCFaceListBlock(iNumCFaces,mesh);continue; this->ParseLV3MeshCFaceListBlock(iNumCFaces,mesh);continue;
} }
// another mesh UV channel ... // another mesh UV channel ...
@ -1099,21 +1063,16 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
{ {
this->LogWarning("Mapping channel has an invalid index. Skipping UV channel"); this->LogWarning("Mapping channel has an invalid index. Skipping UV channel");
// skip it ... // skip it ...
this->SkipOpeningBracket();
this->SkipSection(); this->SkipSection();
} }
if (iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS) if (iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS)
{ {
this->LogWarning("Too many UV channels specified. Skipping channel .."); this->LogWarning("Too many UV channels specified. Skipping channel ..");
// skip it ... // skip it ...
this->SkipOpeningBracket();
this->SkipSection(); this->SkipSection();
} }
else else
{ {
// skip the '{'
this->SkipOpeningBracket();
// parse the mapping channel // parse the mapping channel
this->ParseLV3MappingChannel(iIndex-1,mesh); this->ParseLV3MappingChannel(iIndex-1,mesh);
} }
@ -1172,7 +1131,6 @@ void Parser::ParseLV3MeshWeightsBlock(ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV4MeshBones(iNumBones,mesh);continue; this->ParseLV4MeshBones(iNumBones,mesh);continue;
} }
// parse the list of bones vertices // parse the list of bones vertices
@ -1180,7 +1138,6 @@ void Parser::ParseLV3MeshWeightsBlock(ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+22))) IsSpaceOrNewLine(*(this->m_szFile+22)))
{ {
this->m_szFile+=23; this->m_szFile+=23;
this->SkipOpeningBracket();
this->ParseLV4MeshBonesVertices(iNumVertices,mesh); this->ParseLV4MeshBonesVertices(iNumVertices,mesh);
continue; continue;
} }
@ -1448,7 +1405,6 @@ void Parser::ParseLV3MappingChannel(unsigned int iChannel, ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV3MeshTListBlock(iNumTVertices,mesh,iChannel); this->ParseLV3MeshTListBlock(iNumTVertices,mesh,iChannel);
continue; continue;
} }
@ -1457,7 +1413,6 @@ void Parser::ParseLV3MappingChannel(unsigned int iChannel, ASE::Mesh& mesh)
IsSpaceOrNewLine(*(this->m_szFile+15))) IsSpaceOrNewLine(*(this->m_szFile+15)))
{ {
this->m_szFile+=16; this->m_szFile+=16;
this->SkipOpeningBracket();
this->ParseLV3MeshTFaceListBlock(iNumTFaces,mesh, iChannel); this->ParseLV3MeshTFaceListBlock(iNumTFaces,mesh, iChannel);
continue; continue;
} }

View File

@ -471,10 +471,6 @@ private:
//! \param iOut Output integer //! \param iOut Output integer
void ParseLV4MeshLong(unsigned int& iOut); void ParseLV4MeshLong(unsigned int& iOut);
// -------------------------------------------------------------------
//! Skip the opening bracket at the beginning of a complex statement
bool SkipOpeningBracket();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
//! Skip everything to the next: '*' or '\0' //! Skip everything to the next: '*' or '\0'
bool SkipToNextToken(); bool SkipToNextToken();