3MF: fix model folder desc.

pull/1832/head
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()));

View File

@ -55,7 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/// @return The number of written characters if the buffer size was big enough. If an encoding error occurs, a negative number is returned.
#if defined(_MSC_VER) && _MSC_VER < 1900
inline int c99_ai_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) {
inline
int c99_ai_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) {
int count(-1);
if (0 != size) {
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
@ -67,7 +68,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
return count;
}
inline int ai_snprintf(char *outBuf, size_t size, const char *format, ...) {
inline
int ai_snprintf(char *outBuf, size_t size, const char *format, ...) {
int count;
va_list ap;
@ -82,14 +84,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define ai_snprintf snprintf
#endif
/// @fn to_string
/// @brief The portable version of to_string ( some gcc-versions on embedded devices are not supporting this).
/// @param value The value to write into the std::string.
/// @return The value as a std::string
template <typename T>
inline
std::string to_string( T value ) {
std::ostringstream os;
os << value;
return os.str();
}
/// @fn ai_strtof
/// @brief The portable version of strtof.
/// @param begin The first character of the string.
/// @param end The last character
/// @return The float value, 0.0f in cas of an error.
inline
float ai_strtof( const char *begin, const char *end ) {
if ( nullptr == begin ) {
@ -107,5 +119,23 @@ float ai_strtof( const char *begin, const char *end ) {
return val;
}
#endif // INCLUDED_AI_STRINGUTILS_H
/// @fn DecimalToHexa
/// @brief The portable to convert a decimal value into a hexadecimal string.
/// @param toConvert Value to convert
/// @return The hexadecimal string, is empty in case of an error.
template<class T>
inline
std::string DecimalToHexa( T toConvert ) {
std::string result;
std::stringstream ss;
ss << std::hex << toConvert;
ss >> result;
for ( size_t i = 0; i < result.size(); ++i ) {
result[ i ] = toupper( result[ i ] );
}
return result;
}
#endif // INCLUDED_AI_STRINGUTILS_H