-
Notifications
You must be signed in to change notification settings - Fork 7
Enchant meshloader #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
JBenda
commented
Oct 23, 2021
- support for .mtl files
- triangulates ploygones with more then 3 vertices (ear cut)
- support for materials and sub objects
- grouping informations are accessible
* support for .mtl files * triangulates ploygones with more then 3 vertices (ear cut) * support for materials and sub objects * grouping informations are accessible
Thanduriel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add documentation
- adjust naming convention
- (remove extra scopes?)
| void MtlParser::parseIllumination(const std::string_view& _line) { | ||
| int i = static_cast<int>(parseFloat(_line.data(), _line.data() + _line.size())); | ||
| if(i < 0 || i >= utils::MeshData::MaterialData::USED_LIGHT::END) { | ||
| spdlog::warn("unsupported illumination model for object, use FULL instead!"); | ||
| i = 2; | ||
| } | ||
| m_pNewMtl->illumination = static_cast<utils::MeshData::MaterialData::USED_LIGHT>(i); | ||
| } | ||
| void MtlParser::parse() { | ||
| std::string_view suffix(m_filename); | ||
| auto pos = suffix.find_last_of('.'); | ||
| suffix.remove_prefix(pos); | ||
| if(suffix == ".mtl") { | ||
| std::string filename = m_tmp.directory + m_filename.data(); | ||
| std::ifstream file(filename); | ||
| if(file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curly brackets go on new lines
| } | ||
| } /// namespace utils | ||
|
|
||
| std::vector<int> EarCutTriangulation::operator()() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curly bracket position
| void slide(auto data, auto fun) | ||
| { | ||
| auto itr = data.begin(); | ||
| fun(itr - data.begin(), *data.back(), *itr[0], *itr[1]); | ||
| ++itr; | ||
| for(;itr != data.end() - 1; ++itr) { | ||
| fun(itr - data.begin(), *itr[-1], *itr[0], *itr[1]); | ||
| } | ||
| fun(itr - data.begin(), *data.end()[-2], *data.back(), *data.front()); | ||
| } | ||
|
|
||
| /// calculate primary orientation of polygone | ||
| Orientation determineMainOrientation(auto data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curly brackets
| /** \param mainOrientation primary orientation of polygone (needed to determined inside for classification of reflex and convex */ | ||
| void classifyVertices(Orientation mainOrientation); | ||
|
|
||
| const std::vector<glm::vec3>& m_polygone; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polygone -> polygon
| return res; | ||
| } | ||
| } | ||
| /// triangulate a polygone with the earcut algorithm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference for the algorithm
| @@ -0,0 +1,269 @@ | |||
| #include "./triangulation.hpp" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "./"