Skip to content

Enchant meshloader#4

Open
JBenda wants to merge 3 commits intomainfrom
feature/meshLoaderMaterialSupport
Open

Enchant meshloader#4
JBenda wants to merge 3 commits intomainfrom
feature/meshLoaderMaterialSupport

Conversation

@JBenda
Copy link
Owner

@JBenda 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
@JBenda JBenda added the enhancement New feature or request label Oct 23, 2021
@JBenda JBenda self-assigned this Oct 23, 2021
@JBenda JBenda requested a review from Thanduriel October 23, 2021 12:30
Copy link
Collaborator

@Thanduriel Thanduriel left a 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?)

Comment on lines +208 to +223
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) {
Copy link
Collaborator

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()() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curly bracket position

Comment on lines +91 to +103
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) {
Copy link
Collaborator

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;
Copy link
Collaborator

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
Copy link
Collaborator

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "./"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants