本文整理汇总了C++中BoundBox::min方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundBox::min方法的具体用法?C++ BoundBox::min怎么用?C++ BoundBox::min使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundBox
的用法示例。
在下文中一共展示了BoundBox::min方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
//.........这里部分代码省略.........
texcoords.push_back(texcoord);
} else if (tokens[0] == "vn") {
if (tokens.size() != 4) {
cerr << path << ": Normal command does not have correct number of components\n";
continue;
}
const Vector3f normal(FromString<float>(tokens[1]),
FromString<float>(tokens[2]),
FromString<float>(tokens[3]));
normals.push_back(normal);
} else if (tokens[0] == "f") {
Face face = { };
if (tokens.size() != 4 && tokens.size() != 5) {
cerr << path << ": Face command does not have correct number of arguments\n";
continue;
}
face.isQuad = tokens.size() == 5;
face.mat = MaterialLib::load(mtlPath, mtlName);
const size_t slashesCount = count(tokens[1].begin(), tokens[1].end(), '/');
switch (slashesCount) {
case 0: {
for (size_t i = 0; i < 3U + face.isQuad; i++) {
face.vertexIdxs[i] = indexFromStr(tokens[i + 1], vertices.size()) - 1;
}
faces.push_back(face);
break;
}
case 1: {
for (size_t i = 0; i < 3U + face.isQuad; i++) {
const std::string &token = tokens[i + 1];
const size_t slashPos = token.find('/');
face.vertexIdxs[i] = indexFromStr(token.substr(0, slashPos), vertices.size()) - 1;
if (token.size() - slashPos > 1)
face.texcoordIdxs[i] = indexFromStr(token.substr(slashPos + 1), texcoords.size()) - 1;
}
faces.push_back(face);
break;
}
case 2: {
for (size_t i = 0; i < 3U + face.isQuad; i++) {
const std::string &token = tokens[i + 1];
const size_t slash0Pos = token.find('/');
const size_t slash1Pos = token.find('/', slash0Pos + 1);
face.vertexIdxs[i] = indexFromStr(token.substr(0, slash0Pos), vertices.size()) - 1;
if (slash1Pos - slash0Pos > 1)
face.texcoordIdxs[i] = indexFromStr(token.substr(slash0Pos + 1, slash1Pos - slash0Pos),
texcoords.size()) - 1;
if (token.size() - slash0Pos > 1)
face.normalIdxs[i] = indexFromStr(token.substr(slash1Pos + 1), normals.size()) - 1;
}
faces.push_back(face);
break;
}
default:
cerr << path << ": Invalid face command in \"" << line << "\"\n";
break;
}
} else if (tokens[0] == "usemtl") {
if (tokens.size() != 2) {
cerr << path << ": Use material command does not have correct number of arguments\n";
continue;
}
mtlName = tokens[1];
} else if (tokens[0] == "mtllib") {
if (tokens.size() != 2) {
cerr << path << ": Material library command does not have correct number of arguments\n";
continue;
}
mtlPath = tokens[1];
} else {
cerr << path << ": Unrecognized token \"" << tokens[0] << "\"\n";
}
}
ifs.close();
const time_point loadEndTime = high_resolution_clock::now();
cout
<< "File \""
<< path
<< "\" loaded in "
<< DurationStr(loadStartTime, loadEndTime)
<< " with "
<< faces.size()
<< " face(s), "
<< normals.size()
<< " normal(s), and "
<< texcoords.size()
<< " texture coordinate(s).\n"
<< "\tBounding box: {"
<< boundBox.min().transpose()
<< ", "
<< boundBox.max().transpose()
<< "}\n";
return true;
}