Skip to content
Snippets Groups Projects
Commit 23ce5829 authored by Anakin's avatar Anakin
Browse files

fixed the multiedged polygons

parent 232acedc
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,6 @@
#include <string>
#include <glm\gtc\matrix_transform.hpp>
#include <iostream>
#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;
......
......@@ -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<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
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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment