diff --git a/code/DefaultIOSystem.cpp b/code/DefaultIOSystem.cpp index 421615088..5ce86eadc 100644 --- a/code/DefaultIOSystem.cpp +++ b/code/DefaultIOSystem.cpp @@ -171,12 +171,12 @@ bool DefaultIOSystem::ComparePaths (const char* one, const char* second) const std::string DefaultIOSystem::fileName(std::string path) { std::string ret = path; - std::less comp; - const char* end_path = comp(strrchr(path.c_str(), '\\'), strrchr(path.c_str(), '/')) ? strrchr(path.c_str(), '/') : strrchr(path.c_str(), '\\'); - if(end_path != NULL) ret = ret.substr(end_path + 1 - path.c_str(), ret.npos); + std::size_t last = ret.find_last_of("\\/"); + if (last != std::string::npos) ret = ret.substr(last + 1); return ret; } + std::string DefaultIOSystem::completeBaseName(std::string path) { std::string ret = fileName(path); @@ -185,12 +185,12 @@ std::string DefaultIOSystem::completeBaseName(std::string path) return ret; } + std::string DefaultIOSystem::absolutePath(std::string path) { - std::string ret; - std::less comp; - const char* end_path = comp(strrchr(path.c_str(), '\\'), strrchr(path.c_str(), '/')) ? strrchr(path.c_str(), '/') : strrchr(path.c_str(), '\\'); - if(end_path != NULL) ret = std::string(path.c_str(), end_path + 1 - path.c_str()); + std::string ret = path; + std::size_t last = ret.find_last_of("\\/"); + if (last != std::string::npos) ret = ret.substr(0, last); return ret; } diff --git a/code/StepExporter.cpp b/code/StepExporter.cpp index 877a64217..0ce273313 100644 --- a/code/StepExporter.cpp +++ b/code/StepExporter.cpp @@ -178,6 +178,12 @@ void StepExporter::WriteFile() mOutput.setf(std::ios::fixed); mOutput.precision(16); // precission for double + // standard color + aiColor4D fColor; + fColor.r = 0.8f; + fColor.g = 0.8f; + fColor.b = 0.8f; + int ind = 100; // the start index to be used int faceEntryLen = 30; // number of entries for a triangle/face // prepare unique (count triangles and vertices) @@ -310,6 +316,18 @@ void StepExporter::WriteFile() int pid1 = uniqueVerts.find(v1)->second; int pid2 = uniqueVerts.find(v2)->second; int pid3 = uniqueVerts.find(v3)->second; + + // mean vertex color for the face if available + if (mesh->HasVertexColors(0)) + { + fColor.r = 0.0; + fColor.g = 0.0; + fColor.b = 0.0; + fColor += mesh->mColors[0][face->mIndices[0]]; + fColor += mesh->mColors[0][face->mIndices[1]]; + fColor += mesh->mColors[0][face->mIndices[2]]; + fColor /= 3.0f; + } int sid = ind; // the sub index mOutput << "#" << sid << "=STYLED_ITEM('',(#" << sid+1 << "),#" << sid+8 << ")" << endstr; /* the item that must be referenced in #1 */ @@ -320,7 +338,7 @@ void StepExporter::WriteFile() mOutput << "#" << sid+4 << "=SURFACE_STYLE_FILL_AREA(#" << sid+5 << ")" << endstr; mOutput << "#" << sid+5 << "=FILL_AREA_STYLE('',(#" << sid+6 << "))" << endstr; mOutput << "#" << sid+6 << "=FILL_AREA_STYLE_COLOUR('',#" << sid+7 << ")" << endstr; - mOutput << "#" << sid+7 << "=COLOUR_RGB('',0.0,0.0,1.0)" << endstr; + mOutput << "#" << sid+7 << "=COLOUR_RGB(''," << fColor.r << "," << fColor.g << "," << fColor.b << ")" << endstr; /* this is the geometry */ mOutput << "#" << sid+8 << "=FACE_SURFACE('',(#" << sid+13 << "),#" << sid+9<< ",.T.)" << endstr; /* the face that must be referenced in 29 */ diff --git a/code/XFileExporter.cpp b/code/XFileExporter.cpp index 74e1f0389..276b309dd 100644 --- a/code/XFileExporter.cpp +++ b/code/XFileExporter.cpp @@ -500,13 +500,13 @@ void XFileExporter::WriteMesh(aiMesh* mesh) std::string XFileExporter::toXFileString(aiString &name) { - std::string pref = "NN_"; // node name prefix to prevent unexpected start of string + std::string pref = ""; // node name prefix to prevent unexpected start of string std::string str = pref + std::string(name.C_Str()); for (int i=0; i < (int) str.length(); ++i) { - if ((str[i] >= 48 && str[i] <= 57) || // 0-9 - (str[i] >= 65 && str[i] <= 90) || // A-Z - (str[i] >= 97 && str[i] <= 122)) // a-z + if ((str[i] >= '0' && str[i] <= '9') || // 0-9 + (str[i] >= 'A' && str[i] <= 'Z') || // A-Z + (str[i] >= 'a' && str[i] <= 'z')) // a-z continue; str[i] = '_'; }