3MF: fix model folder desc.

This commit is contained in:
Kim Kulling
2018-03-11 20:15:49 +01:00
parent 017b7d1a2f
commit c8ae0bbb3d
3 changed files with 46 additions and 21 deletions

View File

@@ -153,7 +153,11 @@ bool D3MFExporter::exportRelations() {
mRelOutput << "<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">";
for ( size_t i = 0; i < mRelations.size(); ++i ) {
mRelOutput << "<Relationship Target=\"/" << mRelations[ i ]->target << "\" ";
if ( mRelations[ i ]->target[ 0 ] == '/' ) {
mRelOutput << "<Relationship Target=\"" << mRelations[ i ]->target << "\" ";
} else {
mRelOutput << "<Relationship Target=\"/" << mRelations[ i ]->target << "\" ";
}
mRelOutput << "Id=\"" << mRelations[i]->id << "\" ";
mRelOutput << "Type=\"" << mRelations[ i ]->type << "\" />";
mRelOutput << std::endl;
@@ -205,14 +209,6 @@ void D3MFExporter::writeHeader() {
mModelOutput << std::endl;
}
static std::string to_hex( int to_convert ) {
std::string result;
std::stringstream ss;
ss << std::hex << to_convert;
ss >> result;
return result;
}
void D3MFExporter::writeBaseMaterials() {
mModelOutput << "<basematerials id=\"1\">\n";
for ( size_t i = 0; i < mScene->mNumMaterials; ++i ) {
@@ -229,19 +225,20 @@ void D3MFExporter::writeBaseMaterials() {
if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) {
hexDiffuseColor = "#";
std::string tmp;
tmp = to_hex( color.r );
tmp = DecimalToHexa( color.r );
hexDiffuseColor += tmp;
tmp = to_hex( color.g );
tmp = DecimalToHexa( color.g );
hexDiffuseColor += tmp;
tmp = to_hex( color.b );
tmp = DecimalToHexa( color.b );
hexDiffuseColor += tmp;
tmp = to_hex( color.a );
tmp = DecimalToHexa( color.a );
hexDiffuseColor += tmp;
} else {
hexDiffuseColor = "#FFFFFFFF";
}
mModelOutput << "<base name=\""+strName+"\" "+" displaycolor=\""+hexDiffuseColor+"\">\n";
mModelOutput << "<base name=\""+strName+"\" "+" displaycolor=\""+hexDiffuseColor+"\" />\n";
}
mModelOutput << "</basematerials>\n";
}

View File

@@ -259,7 +259,6 @@ private:
while ( ReadToEndElement( D3MF::XmlTag::basematerials ) ) {
mMatArray.push_back( readMaterialDef() );
xmlReader->read();
}
}
@@ -398,7 +397,6 @@ static const aiImporterDesc desc = {
Extension.c_str()
};
D3MFImporter::D3MFImporter()
: BaseImporter() {
// empty
@@ -431,8 +429,8 @@ const aiImporterDesc *D3MFImporter::GetInfo() const {
return &desc;
}
void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
D3MF::D3MFOpcPackage opcPackage(pIOHandler, pFile);
void D3MFImporter::InternReadFile( const std::string &filename, aiScene *pScene, IOSystem *pIOHandler ) {
D3MF::D3MFOpcPackage opcPackage(pIOHandler, filename);
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(opcPackage.RootStream()));
std::unique_ptr<D3MF::XmlReader> xmlReader(irr::io::createIrrXMLReader(xmlStream.get()));