commit
6daecdcc5a
|
@ -181,7 +181,7 @@ bool D3MFExporter::export3DModel() {
|
||||||
|
|
||||||
writeHeader();
|
writeHeader();
|
||||||
mModelOutput << "<" << XmlTag::model << " " << XmlTag::model_unit << "=\"millimeter\""
|
mModelOutput << "<" << XmlTag::model << " " << XmlTag::model_unit << "=\"millimeter\""
|
||||||
<< "xmlns=\"http://schemas.microsoft.com/3dmanufacturing/core/2015/02\">"
|
<< " xmlns=\"http://schemas.microsoft.com/3dmanufacturing/core/2015/02\">"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
mModelOutput << "<" << XmlTag::resources << ">";
|
mModelOutput << "<" << XmlTag::resources << ">";
|
||||||
mModelOutput << std::endl;
|
mModelOutput << std::endl;
|
||||||
|
@ -212,7 +212,7 @@ bool D3MFExporter::export3DModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFExporter::writeHeader() {
|
void D3MFExporter::writeHeader() {
|
||||||
mModelOutput << "<?xml version=\"1.0\" encoding=\"UTF - 8\"?>";
|
mModelOutput << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||||
mModelOutput << std::endl;
|
mModelOutput << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,16 +254,28 @@ void D3MFExporter::writeBaseMaterials() {
|
||||||
if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) {
|
if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) {
|
||||||
hexDiffuseColor.clear();
|
hexDiffuseColor.clear();
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
hexDiffuseColor = "#";
|
// rgbs %
|
||||||
|
if(color.r <= 1 && color.g <= 1 && color.b <= 1 && color.a <= 1){
|
||||||
|
|
||||||
tmp = DecimalToHexa( (ai_real) color.r );
|
hexDiffuseColor = Rgba2Hex(
|
||||||
hexDiffuseColor += tmp;
|
(int)((ai_real)color.r)*255,
|
||||||
tmp = DecimalToHexa((ai_real)color.g);
|
(int)((ai_real)color.g)*255,
|
||||||
hexDiffuseColor += tmp;
|
(int)((ai_real)color.b)*255,
|
||||||
tmp = DecimalToHexa((ai_real)color.b);
|
(int)((ai_real)color.a)*255,
|
||||||
hexDiffuseColor += tmp;
|
true
|
||||||
tmp = DecimalToHexa((ai_real)color.a);
|
);
|
||||||
hexDiffuseColor += tmp;
|
|
||||||
|
}else{
|
||||||
|
hexDiffuseColor = "#";
|
||||||
|
tmp = DecimalToHexa( (ai_real) color.r );
|
||||||
|
hexDiffuseColor += tmp;
|
||||||
|
tmp = DecimalToHexa((ai_real)color.g);
|
||||||
|
hexDiffuseColor += tmp;
|
||||||
|
tmp = DecimalToHexa((ai_real)color.b);
|
||||||
|
hexDiffuseColor += tmp;
|
||||||
|
tmp = DecimalToHexa((ai_real)color.a);
|
||||||
|
hexDiffuseColor += tmp;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hexDiffuseColor = "#FFFFFFFF";
|
hexDiffuseColor = "#FFFFFFFF";
|
||||||
}
|
}
|
||||||
|
@ -284,7 +296,7 @@ void D3MFExporter::writeObjects() {
|
||||||
if ( nullptr == currentNode ) {
|
if ( nullptr == currentNode ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mModelOutput << "<" << XmlTag::object << " id=\"" << currentNode->mName.C_Str() << "\" type=\"model\">";
|
mModelOutput << "<" << XmlTag::object << " id=\"" << i + 2 << "\" type=\"model\">";
|
||||||
mModelOutput << std::endl;
|
mModelOutput << std::endl;
|
||||||
for ( unsigned int j = 0; j < currentNode->mNumMeshes; ++j ) {
|
for ( unsigned int j = 0; j < currentNode->mNumMeshes; ++j ) {
|
||||||
aiMesh *currentMesh = mScene->mMeshes[ currentNode->mMeshes[ j ] ];
|
aiMesh *currentMesh = mScene->mMeshes[ currentNode->mMeshes[ j ] ];
|
||||||
|
@ -348,7 +360,7 @@ void D3MFExporter::writeBuild() {
|
||||||
mModelOutput << "<" << XmlTag::build << ">" << std::endl;
|
mModelOutput << "<" << XmlTag::build << ">" << std::endl;
|
||||||
|
|
||||||
for ( size_t i = 0; i < mBuildItems.size(); ++i ) {
|
for ( size_t i = 0; i < mBuildItems.size(); ++i ) {
|
||||||
mModelOutput << "<" << XmlTag::item << " objectid=\"" << i + 1 << "\"/>";
|
mModelOutput << "<" << XmlTag::item << " objectid=\"" << i + 2 << "\"/>";
|
||||||
mModelOutput << std::endl;
|
mModelOutput << std::endl;
|
||||||
}
|
}
|
||||||
mModelOutput << "</" << XmlTag::build << ">";
|
mModelOutput << "</" << XmlTag::build << ">";
|
||||||
|
|
|
@ -145,4 +145,21 @@ std::string DecimalToHexa( T toConvert ) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief translate RGBA to String
|
||||||
|
/// @param r aiColor.r
|
||||||
|
/// @param g aiColor.g
|
||||||
|
/// @param b aiColor.b
|
||||||
|
/// @param a aiColor.a
|
||||||
|
/// @param with_head #
|
||||||
|
/// @return The hexadecimal string, is empty in case of an error.
|
||||||
|
AI_FORCE_INLINE std::string Rgba2Hex(int r, int g, int b, int a, bool with_head) {
|
||||||
|
std::stringstream ss;
|
||||||
|
if (with_head) {
|
||||||
|
ss << "#";
|
||||||
|
}
|
||||||
|
ss << std::hex << (r << 24 | g << 16 | b << 8 | a);
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // INCLUDED_AI_STRINGUTILS_H
|
#endif // INCLUDED_AI_STRINGUTILS_H
|
||||||
|
|
Loading…
Reference in New Issue