Commit 23ce5829 authored by Anakin's avatar Anakin
Browse files

fixed the multiedged polygons

parent 232acedc
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#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"
...@@ -389,21 +388,19 @@ void OpenGLController::loadMsh(const char * path) ...@@ -389,21 +388,19 @@ 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++)
{ {
Vertex tempVertex; Vertex tempVertex;
// 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)[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 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)
{ {
...@@ -413,7 +410,7 @@ void OpenGLController::loadMsh(const char * path) ...@@ -413,7 +410,7 @@ void OpenGLController::loadMsh(const char * path)
else else
{ {
for (int j = 0; j < 2; j++) 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); tempBufferData.push_back(tempVertex);
} }
...@@ -462,7 +459,6 @@ void OpenGLController::loadMsh(const char * path) ...@@ -462,7 +459,6 @@ void OpenGLController::loadMsh(const char * path)
} }
catch (std::invalid_argument e) catch (std::invalid_argument e)
{ {
GLubyte solidColor[4] = { 0, 0, 255, 255 };
tempData->alpha = true; tempData->alpha = true;
tempData->width = 1; tempData->width = 1;
tempData->height = 1; tempData->height = 1;
...@@ -474,7 +470,6 @@ void OpenGLController::loadMsh(const char * path) ...@@ -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) // add a solid default color at the end (maybe there is an invalid index later)
textureData* tempData = new textureData; textureData* tempData = new textureData;
GLubyte solidColor[4] = { 0, 0, 255, 255 };
tempData->alpha = true; tempData->alpha = true;
tempData->width = 1; tempData->width = 1;
tempData->height = 1; tempData->height = 1;
......
...@@ -57,7 +57,6 @@ TextureTGA::TextureTGA(const char * filePath) ...@@ -57,7 +57,6 @@ TextureTGA::TextureTGA(const char * filePath)
std::uint8_t tempChunkHeader; std::uint8_t tempChunkHeader;
std::uint8_t tempData[5]; std::uint8_t tempData[5];
unsigned int tempByteIndex = 0; unsigned int tempByteIndex = 0;
std::size_t tempPixelIndex = 0;
do { do {
fsPicture.read(reinterpret_cast<char*>(&tempChunkHeader), sizeof(tempChunkHeader)); fsPicture.read(reinterpret_cast<char*>(&tempChunkHeader), sizeof(tempChunkHeader));
......
...@@ -13,10 +13,7 @@ Feel free to use my code the way you like. But remember i used some public libra ...@@ -13,10 +13,7 @@ Feel free to use my code the way you like. But remember i used some public libra
licence, too. licence, too.
### To Do ### To Do
- cluster use wrong textures - cloth not working correctly
- use normals or fix ccw and cw
- multipoly triangulation not 100% good
- cloth testing
- optional display bones, shadow, collision,... - optional display bones, shadow, collision,...
- integrate into a software: - integrate into a software:
-> gui open file ( + drag and drop), -> gui open file ( + drag and drop),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment