- Bugfix: ColladaLoader failed on <extra> tags in geometry elements

- Bugfix: ColladaLoader reads and filters mesh subgroups without faces now. Who the fuck writes them anyways? I'm looking at you, Maya export!
- Made the VC9 workspace load again. Thanks to Aramis for the hints.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@302 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
ulfjorensen
2009-01-18 00:52:20 +00:00
parent d8cdfb9954
commit 244e2468c6
9 changed files with 127 additions and 28 deletions

View File

@@ -554,17 +554,12 @@ void ColladaParser::ReadGeometryLibrary()
// TODO: (thom) support SIDs
assert( TestAttribute( "sid") == -1);
// a <geometry> always contains a single <mesh> element inside, so we just skip that element in advance
TestOpening( "mesh");
// create a mesh and store it in the library under its ID
Mesh* mesh = new Mesh;
mMeshLibrary[id] = mesh;
// read on from there
ReadMesh( mesh);
mMeshLibrary[id] = mesh;
// check for the closing tag of the outer <geometry> element, the inner closing of <mesh> has been consumed by ReadMesh()
TestClosing( "geometry");
// read on from there
ReadGeometry( mesh);
} else
{
// ignore the rest
@@ -581,6 +576,34 @@ void ColladaParser::ReadGeometryLibrary()
}
}
// ------------------------------------------------------------------------------------------------
// Reads a geometry from the geometry library.
void ColladaParser::ReadGeometry( Collada::Mesh* pMesh)
{
while( mReader->read())
{
if( mReader->getNodeType() == irr::io::EXN_ELEMENT)
{
if( IsElement( "mesh"))
{
// read on from there
ReadMesh( pMesh);
} else
{
// ignore the rest
SkipElement();
}
}
else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
{
if( strcmp( mReader->getNodeName(), "geometry") != 0)
ThrowException( "Expected end of \"geometry\" element.");
break;
}
}
}
// ------------------------------------------------------------------------------------------------
// Reads a mesh from the geometry library
void ColladaParser::ReadMesh( Mesh* pMesh)
@@ -840,25 +863,31 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
}
else if( IsElement( "vcount"))
{
// case <polylist> - specifies the number of indices for each polygon
const char* content = GetTextContent();
vcount.reserve( numPrimitives);
for( unsigned int a = 0; a < numPrimitives; a++)
{
if( *content == 0)
ThrowException( "Expected more values while reading vcount contents.");
// read a number
vcount.push_back( (size_t) strtol10( content, &content));
// skip whitespace after it
SkipSpacesAndLineEnd( &content);
}
TestClosing( "vcount");
if( !mReader->isEmptyElement())
{
// case <polylist> - specifies the number of indices for each polygon
const char* content = GetTextContent();
vcount.reserve( numPrimitives);
for( unsigned int a = 0; a < numPrimitives; a++)
{
if( *content == 0)
ThrowException( "Expected more values while reading vcount contents.");
// read a number
vcount.push_back( (size_t) strtol10( content, &content));
// skip whitespace after it
SkipSpacesAndLineEnd( &content);
}
TestClosing( "vcount");
}
}
else if( IsElement( "p"))
{
// now here the actual fun starts - these are the indices to construct the mesh data from
ReadPrimitives( pMesh, perIndexData, numPrimitives, vcount, primType);
if( !mReader->isEmptyElement())
{
// now here the actual fun starts - these are the indices to construct the mesh data from
ReadPrimitives( pMesh, perIndexData, numPrimitives, vcount, primType);
}
} else
{
ThrowException( "Unexpected sub element in tag \"vertices\".");