|
@@ -102,6 +102,8 @@ public:
|
|
//
|
|
//
|
|
} else if ( nodeName == D3MF::XmlTag::basematerials ) {
|
|
} else if ( nodeName == D3MF::XmlTag::basematerials ) {
|
|
ReadBaseMaterials();
|
|
ReadBaseMaterials();
|
|
|
|
+ } else if ( nodeName == D3MF::XmlTag::meta ) {
|
|
|
|
+ ReadMetadata();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -109,6 +111,15 @@ public:
|
|
scene->mRootNode->mName.Set( "3MF" );
|
|
scene->mRootNode->mName.Set( "3MF" );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ( !mMetaData.empty() ) {
|
|
|
|
+ const size_t numMeta( mMetaData.size() );
|
|
|
|
+ scene->mMetaData = aiMetadata::Alloc( numMeta );
|
|
|
|
+ for ( size_t i = 0; i < numMeta; ++i ) {
|
|
|
|
+ aiString val( mMetaData[ i ].value );
|
|
|
|
+ scene->mMetaData->Add( mMetaData[ i ].name, val );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
scene->mNumMeshes = static_cast<unsigned int>( mMeshes.size());
|
|
scene->mNumMeshes = static_cast<unsigned int>( mMeshes.size());
|
|
scene->mMeshes = new aiMesh*[scene->mNumMeshes]();
|
|
scene->mMeshes = new aiMesh*[scene->mNumMeshes]();
|
|
|
|
|
|
@@ -180,6 +191,21 @@ private:
|
|
return mesh;
|
|
return mesh;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ void ReadMetadata() {
|
|
|
|
+ const std::string name = xmlReader->getAttributeValue( D3MF::XmlTag::meta_name.c_str() );
|
|
|
|
+ xmlReader->read();
|
|
|
|
+ const std::string value = xmlReader->getNodeData();
|
|
|
|
+
|
|
|
|
+ if ( name.empty() ) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MetaEntry entry;
|
|
|
|
+ entry.name = name;
|
|
|
|
+ entry.value = value;
|
|
|
|
+ mMetaData.push_back( entry );
|
|
|
|
+ }
|
|
|
|
+
|
|
void ImportVertices(aiMesh* mesh) {
|
|
void ImportVertices(aiMesh* mesh) {
|
|
std::vector<aiVector3D> vertices;
|
|
std::vector<aiVector3D> vertices;
|
|
while(ReadToEndElement(D3MF::XmlTag::vertices)) {
|
|
while(ReadToEndElement(D3MF::XmlTag::vertices)) {
|
|
@@ -371,8 +397,12 @@ private:
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private:
|
|
private:
|
|
|
|
+ struct MetaEntry {
|
|
|
|
+ std::string name;
|
|
|
|
+ std::string value;
|
|
|
|
+ };
|
|
|
|
+ std::vector<MetaEntry> mMetaData;
|
|
std::vector<aiMesh*> mMeshes;
|
|
std::vector<aiMesh*> mMeshes;
|
|
MatArray mMatArray;
|
|
MatArray mMatArray;
|
|
unsigned int mActiveMatGroup;
|
|
unsigned int mActiveMatGroup;
|