- 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
pull/1/head
ulfjorensen 2009-01-18 00:52:20 +00:00
parent d8cdfb9954
commit 244e2468c6
9 changed files with 127 additions and 28 deletions

View File

@ -155,7 +155,7 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
// accumulated mesh references by this node // accumulated mesh references by this node
std::vector<size_t> newMeshRefs; std::vector<size_t> newMeshRefs;
// for the moment we simply ignore all material tags and transfer the meshes one by one // add a mesh for each subgroup in each collada mesh
BOOST_FOREACH( const Collada::MeshInstance& mid, pNode->mMeshes) BOOST_FOREACH( const Collada::MeshInstance& mid, pNode->mMeshes)
{ {
// find the referred mesh // find the referred mesh
@ -172,6 +172,9 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
for( size_t sm = 0; sm < srcMesh->mSubMeshes.size(); ++sm) for( size_t sm = 0; sm < srcMesh->mSubMeshes.size(); ++sm)
{ {
const Collada::SubMesh& submesh = srcMesh->mSubMeshes[sm]; const Collada::SubMesh& submesh = srcMesh->mSubMeshes[sm];
if( submesh.mNumFaces == 0)
continue;
// find material assigned to this submesh // find material assigned to this submesh
std::map<std::string, std::string>::const_iterator meshMatIt = mid.mMaterials.find( submesh.mMaterial); std::map<std::string, std::string>::const_iterator meshMatIt = mid.mMaterials.find( submesh.mMaterial);
std::string meshMaterial; std::string meshMaterial;
@ -216,8 +219,8 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
if( srcMesh->mTexCoords[a].size() == srcMesh->mPositions.size()) if( srcMesh->mTexCoords[a].size() == srcMesh->mPositions.size())
{ {
dstMesh->mTextureCoords[a] = new aiVector3D[numVertices]; dstMesh->mTextureCoords[a] = new aiVector3D[numVertices];
for( size_t b = vertexStart; b < vertexStart + numVertices; ++b) for( size_t b = 0; b < numVertices; ++b)
dstMesh->mTextureCoords[a][b].Set( srcMesh->mTexCoords[a][b].x, srcMesh->mTexCoords[a][b].y, 0.0f); dstMesh->mTextureCoords[a][b].Set( srcMesh->mTexCoords[a][vertexStart+b].x, srcMesh->mTexCoords[a][vertexStart+b].y, 0.0f);
dstMesh->mNumUVComponents[a] = 2; dstMesh->mNumUVComponents[a] = 2;
} }
} }

View File

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

View File

@ -101,6 +101,9 @@ protected:
/** Reads the geometry library contents */ /** Reads the geometry library contents */
void ReadGeometryLibrary(); void ReadGeometryLibrary();
/** Reads a geometry from the geometry library. */
void ReadGeometry( Collada::Mesh* pMesh);
/** Reads a mesh from the geometry library */ /** Reads a mesh from the geometry library */
void ReadMesh( Collada::Mesh* pMesh); void ReadMesh( Collada::Mesh* pMesh);

View File

@ -100,7 +100,6 @@ Global
{5691E159-2D9B-407F-971F-EA5C592DC524}.release-st|x64.ActiveCfg = release-st|x64 {5691E159-2D9B-407F-971F-EA5C592DC524}.release-st|x64.ActiveCfg = release-st|x64
{5691E159-2D9B-407F-971F-EA5C592DC524}.release-st|x64.Build.0 = release-st|x64 {5691E159-2D9B-407F-971F-EA5C592DC524}.release-st|x64.Build.0 = release-st|x64
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug|Win32.ActiveCfg = debug|Win32 {9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug|Win32.ActiveCfg = debug|Win32
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug|Win32.Build.0 = debug|Win32
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug|x64.ActiveCfg = debug|x64 {9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug|x64.ActiveCfg = debug|x64
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug|x64.Build.0 = debug|x64 {9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug|x64.Build.0 = debug|x64
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug-dll|Win32.ActiveCfg = debug-dll|Win32 {9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.debug-dll|Win32.ActiveCfg = debug-dll|Win32

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="DllShared"
OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)"
IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="ASSIMP_BUILD_DLL_EXPORT"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
/>
</VisualStudioPropertySheet>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="LibShared"
OutputDirectory="./../../lib/$(ProjectName)_$(ConfigurationName)_$(PlatformName)"
IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)"
>
</VisualStudioPropertySheet>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="NoBoostShared"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="ASSIMP_BUILD_BOOST_WORKAROUND;ASSIMP_BUILD_SINGLETHREADED"
/>
</VisualStudioPropertySheet>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="SingleThreadedShared"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="ASSIMP_BUILD_SINGLETHREADED"
/>
</VisualStudioPropertySheet>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="UnitTest"
OutputDirectory="./../../lib/$(ProjectName)_$(ConfigurationName)_$(PlatformName)"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..\..\contrib\cppunit-1.12.1\include&quot;"
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
/>
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories="&quot;..\..\contrib\cppunit-1.12.1\lib&quot;"
/>
</VisualStudioPropertySheet>