From 23ce58291e690739f73e4f778d66a6524918fe54 Mon Sep 17 00:00:00 2001 From: Anakin Date: Wed, 23 Nov 2016 17:30:38 +0100 Subject: [PATCH] fixed the multiedged polygons --- MshViewer/Source/OpenGlController.cpp | 11 +++-------- MshViewer/Source/Texture.cpp | 1 - README.md | 5 +---- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/MshViewer/Source/OpenGlController.cpp b/MshViewer/Source/OpenGlController.cpp index 17fec58..b2e221a 100644 --- a/MshViewer/Source/OpenGlController.cpp +++ b/MshViewer/Source/OpenGlController.cpp @@ -6,7 +6,6 @@ #include #include -#include #define VERTEX_SHADER "Shader/TextureShader.vert" #define FRAGMENT_SHADER "Shader/TextureShader.frag" @@ -389,21 +388,19 @@ void OpenGLController::loadMsh(const char * path) { for (auto& mshIt : segIt->meshIndices) // for every polygon { - std::cout << "== Poly ==" << std::endl; if (mshIt->size() >= 3) // multipoly { // for every triangle of the multi polygon for (unsigned int tri = 0; tri < mshIt->size() - 2; tri++) { - std::cout << "== Triangle ==" << std::endl; // for every edge of the triangle for (int triEdge = 0; triEdge < 3; triEdge++) { Vertex tempVertex; // every edge has 3 coordinates for (int j = 0; j < 3; j++) - tempVertex.position[j] = (GLfloat)segIt->vertex[(*mshIt)[triEdge > 0 ? tri + triEdge : 0] * 3 + j]; - std::cout << (triEdge > 0 ? tri + triEdge : 0) << std::endl; + tempVertex.position[j] = (GLfloat)segIt->vertex[(*mshIt)[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 3 + j]; + // and 2 UV if (segIt->uv == NULL) { @@ -413,7 +410,7 @@ void OpenGLController::loadMsh(const char * path) else { for (int j = 0; j < 2; j++) - tempVertex.uv[j] = (GLfloat)segIt->uv[(*mshIt)[triEdge > 0 ? tri + triEdge : 0] * 2 + j]; + tempVertex.uv[j] = (GLfloat)segIt->uv[(*mshIt)[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 2 + j]; } tempBufferData.push_back(tempVertex); } @@ -462,7 +459,6 @@ void OpenGLController::loadMsh(const char * path) } catch (std::invalid_argument e) { - GLubyte solidColor[4] = { 0, 0, 255, 255 }; tempData->alpha = true; tempData->width = 1; tempData->height = 1; @@ -474,7 +470,6 @@ void OpenGLController::loadMsh(const char * path) // add a solid default color at the end (maybe there is an invalid index later) textureData* tempData = new textureData; - GLubyte solidColor[4] = { 0, 0, 255, 255 }; tempData->alpha = true; tempData->width = 1; tempData->height = 1; diff --git a/MshViewer/Source/Texture.cpp b/MshViewer/Source/Texture.cpp index a689b3d..0ba4b84 100644 --- a/MshViewer/Source/Texture.cpp +++ b/MshViewer/Source/Texture.cpp @@ -57,7 +57,6 @@ TextureTGA::TextureTGA(const char * filePath) std::uint8_t tempChunkHeader; std::uint8_t tempData[5]; unsigned int tempByteIndex = 0; - std::size_t tempPixelIndex = 0; do { fsPicture.read(reinterpret_cast(&tempChunkHeader), sizeof(tempChunkHeader)); diff --git a/README.md b/README.md index 3fe1dbc..8163e70 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,7 @@ Feel free to use my code the way you like. But remember i used some public libra licence, too. ### To Do -- cluster use wrong textures -- use normals or fix ccw and cw -- multipoly triangulation not 100% good -- cloth testing +- cloth not working correctly - optional display bones, shadow, collision,... - integrate into a software: -> gui open file ( + drag and drop),