+ support of obj format where texture colors are in range [0, 1] (as written by MeshLab)
This commit is contained in:
parent
d51ea4c96b
commit
f07b836ce7
|
@ -236,6 +236,12 @@ bool MeshInput::LoadOBJ (std::istream &rstrIn)
|
||||||
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||||
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||||
"\\s+(\\d{1,3})\\s+(\\d{1,3})\\s+(\\d{1,3})\\s*$");
|
"\\s+(\\d{1,3})\\s+(\\d{1,3})\\s+(\\d{1,3})\\s*$");
|
||||||
|
boost::regex rx_t("^v\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||||
|
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||||
|
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||||
|
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||||
|
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
|
||||||
|
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)\\s*$");
|
||||||
boost::regex rx_f3("^f\\s+([0-9]+)/?[0-9]*/?[0-9]*"
|
boost::regex rx_f3("^f\\s+([0-9]+)/?[0-9]*/?[0-9]*"
|
||||||
"\\s+([0-9]+)/?[0-9]*/?[0-9]*"
|
"\\s+([0-9]+)/?[0-9]*/?[0-9]*"
|
||||||
"\\s+([0-9]+)/?[0-9]*/?[0-9]*\\s*$");
|
"\\s+([0-9]+)/?[0-9]*/?[0-9]*\\s*$");
|
||||||
|
@ -289,6 +295,21 @@ bool MeshInput::LoadOBJ (std::istream &rstrIn)
|
||||||
meshPoints.back().SetProperty(prop);
|
meshPoints.back().SetProperty(prop);
|
||||||
rgb_value = MeshIO::PER_VERTEX;
|
rgb_value = MeshIO::PER_VERTEX;
|
||||||
}
|
}
|
||||||
|
else if (boost::regex_match(line.c_str(), what, rx_t)) {
|
||||||
|
readvertices = true;
|
||||||
|
fX = (float)std::atof(what[1].first);
|
||||||
|
fY = (float)std::atof(what[4].first);
|
||||||
|
fZ = (float)std::atof(what[7].first);
|
||||||
|
float r = static_cast<float>(std::atof(what[10].first));
|
||||||
|
float g = static_cast<float>(std::atof(what[13].first));
|
||||||
|
float b = static_cast<float>(std::atof(what[16].first));
|
||||||
|
meshPoints.push_back(MeshPoint(Base::Vector3f(fX, fY, fZ)));
|
||||||
|
|
||||||
|
App::Color c(r,g,b);
|
||||||
|
unsigned long prop = static_cast<uint32_t>(c.getPackedValue());
|
||||||
|
meshPoints.back().SetProperty(prop);
|
||||||
|
rgb_value = MeshIO::PER_VERTEX;
|
||||||
|
}
|
||||||
else if (boost::regex_match(line.c_str(), what, rx_f3)) {
|
else if (boost::regex_match(line.c_str(), what, rx_f3)) {
|
||||||
// starts a new segment
|
// starts a new segment
|
||||||
if (readvertices) {
|
if (readvertices) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user