trying to fix the polygon mess up,

added new multipoly for testing
This commit is contained in:
Anakin 2016-11-22 20:05:02 +01:00
parent 60cc7bb562
commit 232acedce7
4 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@
#include <string> #include <string>
#include <glm\gtc\matrix_transform.hpp> #include <glm\gtc\matrix_transform.hpp>
#include <iostream>
#define VERTEX_SHADER "Shader/TextureShader.vert" #define VERTEX_SHADER "Shader/TextureShader.vert"
#define FRAGMENT_SHADER "Shader/TextureShader.frag" #define FRAGMENT_SHADER "Shader/TextureShader.frag"
@ -388,11 +389,13 @@ void OpenGLController::loadMsh(const char * path)
{ {
for (auto& mshIt : segIt->meshIndices) // for every polygon for (auto& mshIt : segIt->meshIndices) // for every polygon
{ {
std::cout << "== Poly ==" << std::endl;
if (mshIt->size() >= 3) // multipoly if (mshIt->size() >= 3) // multipoly
{ {
// for every triangle of the multi polygon // for every triangle of the multi polygon
for (unsigned int tri = 0; tri < mshIt->size() - 2; tri++) for (unsigned int tri = 0; tri < mshIt->size() - 2; tri++)
{ {
std::cout << "== Triangle ==" << std::endl;
// for every edge of the triangle // for every edge of the triangle
for (int triEdge = 0; triEdge < 3; triEdge++) for (int triEdge = 0; triEdge < 3; triEdge++)
{ {
@ -400,7 +403,7 @@ void OpenGLController::loadMsh(const char * path)
// every edge has 3 coordinates // every edge has 3 coordinates
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
tempVertex.position[j] = (GLfloat)segIt->vertex[(*mshIt)[triEdge > 0 ? tri + triEdge : 0] * 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;
// and 2 UV // and 2 UV
if (segIt->uv == NULL) if (segIt->uv == NULL)
{ {

BIN
Release/Msh/4-Poly.msh Normal file

Binary file not shown.

BIN
Release/Msh/5-Poly.msh Normal file

Binary file not shown.

BIN
Release/Msh/6-poly.msh Normal file

Binary file not shown.