Compare commits
21 Commits
Version_0.
...
Version_0.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
97a38d5260 | ||
![]() |
23ce58291e | ||
![]() |
232acedce7 | ||
![]() |
60cc7bb562 | ||
![]() |
9abd285239 | ||
![]() |
bcdc17c362 | ||
![]() |
b3a8b4bb81 | ||
![]() |
f81f03353d | ||
![]() |
9ac1a25954 | ||
![]() |
57df0a2e15 | ||
![]() |
927ce1cd0a | ||
![]() |
f4d8018f8f | ||
![]() |
806024f4f9 | ||
![]() |
0f379ba04a | ||
![]() |
8929717c9f | ||
![]() |
bbe657d030 | ||
![]() |
1ab385475b | ||
![]() |
9298d88260 | ||
![]() |
91b65bf6e3 | ||
![]() |
b4bd314450 | ||
![]() |
2524971d19 |
@@ -3,7 +3,6 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <gl\glew.h>
|
|
||||||
#include <glm\gtc\matrix_transform.hpp>
|
#include <glm\gtc\matrix_transform.hpp>
|
||||||
|
|
||||||
enum Mtyp {
|
enum Mtyp {
|
||||||
@@ -21,17 +20,20 @@ struct ChunkHeader {
|
|||||||
std::streampos position;
|
std::streampos position;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Segment {
|
||||||
|
std::uint32_t textureIndex = 0;
|
||||||
|
float* vertex = nullptr;
|
||||||
|
float* uv = nullptr;
|
||||||
|
std::vector<std::vector<std::uint32_t>*> meshIndices; // indices into vertex array
|
||||||
|
};
|
||||||
|
|
||||||
struct Modl {
|
struct Modl {
|
||||||
std::string name;
|
std::string name = "";
|
||||||
std::string parent;
|
std::string parent = "";
|
||||||
Mtyp type;
|
Mtyp type = null;
|
||||||
std::uint32_t renderFlags;
|
std::int32_t renderFlags = -1;
|
||||||
glm::mat4 m4x4Translation;
|
glm::mat4 m4x4Translation = glm::mat4(1.0f);
|
||||||
std::string texture;
|
std::vector<Segment*> segmLst;
|
||||||
float* vertex;
|
|
||||||
float* uv;
|
|
||||||
std::uint32_t* mesh;
|
|
||||||
std::uint32_t meshSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -49,7 +51,6 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setModlDefault(Modl* model);
|
|
||||||
void loadChunks(std::list<ChunkHeader*> &destination, std::streampos start, const std::uint32_t end);
|
void loadChunks(std::list<ChunkHeader*> &destination, std::streampos start, const std::uint32_t end);
|
||||||
void analyseMsh2Chunks(std::list<ChunkHeader*> &chunkList);
|
void analyseMsh2Chunks(std::list<ChunkHeader*> &chunkList);
|
||||||
void analyseMatdChunks(std::list<ChunkHeader*> &chunkList);
|
void analyseMatdChunks(std::list<ChunkHeader*> &chunkList);
|
||||||
@@ -57,11 +58,12 @@ private:
|
|||||||
void analyseGeomChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
void analyseGeomChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
||||||
void analyseSegmChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
void analyseSegmChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
||||||
void analyseClthChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
void analyseClthChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
||||||
void readVertex(Modl* dataDestination, std::streampos position);
|
void readVertex(Segment* dataDestination, std::streampos position);
|
||||||
void readUV(Modl* dataDestination, std::streampos position);
|
void readUV(Segment* dataDestination, std::streampos position);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<Modl*> getModels() const;
|
std::vector<Modl*> getModels() const;
|
||||||
|
std::vector<std::string> getTextureList() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
|
||||||
#include <gl\glew.h>
|
#include <gl\glew.h>
|
||||||
#include <gl\glfw3.h>
|
#include <gl\glfw3.h>
|
||||||
#include <glm\glm.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Texture.h"
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#define VERTEX_INDEX_XYZ 0
|
#define VERTEX_INDEX_XYZ 0
|
||||||
#define VERTEX_INDEX_UV 1
|
#define VERTEX_INDEX_UV 1
|
||||||
@@ -96,12 +94,14 @@ private:
|
|||||||
// private functions
|
// private functions
|
||||||
private:
|
private:
|
||||||
void processInit();
|
void processInit();
|
||||||
|
void deleteVectors();
|
||||||
|
|
||||||
void startGLFW();
|
void startGLFW();
|
||||||
void createWindow();
|
void createWindow();
|
||||||
void startGLEW();
|
void startGLEW();
|
||||||
void setCallbackFunctions();
|
void setCallbackFunctions();
|
||||||
|
|
||||||
|
glm::mat4 getModelMatrix(unsigned int index);
|
||||||
glm::mat4 getMVPMatrix(unsigned int index);
|
glm::mat4 getMVPMatrix(unsigned int index);
|
||||||
|
|
||||||
|
|
||||||
@@ -116,6 +116,7 @@ public:
|
|||||||
void addTransX(double value);
|
void addTransX(double value);
|
||||||
void addTransY(double value);
|
void addTransY(double value);
|
||||||
void addTransZ(double value);
|
void addTransZ(double value);
|
||||||
|
void resetView();
|
||||||
|
|
||||||
// main routine
|
// main routine
|
||||||
GLFWwindow* getWindow() const;
|
GLFWwindow* getWindow() const;
|
||||||
|
@@ -9,3 +9,5 @@ extern void mouseMove(GLFWwindow *window, double xpos, double ypos);
|
|||||||
extern void mouseWheel(GLFWwindow *window, double xoffset, double yoffset);
|
extern void mouseWheel(GLFWwindow *window, double xoffset, double yoffset);
|
||||||
|
|
||||||
extern void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods);
|
extern void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods);
|
||||||
|
|
||||||
|
extern void dragNdrop(GLFWwindow* window, int count, const char** paths);
|
@@ -1,5 +1,7 @@
|
|||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
#define PI (4.0*atan(1.0))
|
#define PI (4.0*atan(1.0))
|
||||||
|
|
||||||
|
|
||||||
@@ -72,20 +74,6 @@ Object::~Object()
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// private functions
|
// private functions
|
||||||
|
|
||||||
void Object::setModlDefault(Modl * model)
|
|
||||||
{
|
|
||||||
model->name = "";
|
|
||||||
model->parent = "";
|
|
||||||
model->type = null;
|
|
||||||
model->renderFlags = -1;
|
|
||||||
model->m4x4Translation = glm::mat4(1.0f);
|
|
||||||
model->texture = "";
|
|
||||||
model->vertex = NULL;
|
|
||||||
model->uv = NULL;
|
|
||||||
model->mesh = NULL;
|
|
||||||
model->meshSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::loadChunks(std::list<ChunkHeader*>& destination, std::streampos start, const std::uint32_t end)
|
void Object::loadChunks(std::list<ChunkHeader*>& destination, std::streampos start, const std::uint32_t end)
|
||||||
{
|
{
|
||||||
// jump to first chunk
|
// jump to first chunk
|
||||||
@@ -143,6 +131,8 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
|
|||||||
std::list<ChunkHeader*> tempMatdChunks;
|
std::list<ChunkHeader*> tempMatdChunks;
|
||||||
loadChunks(tempMatdChunks, (*it)->position, (*it)->size);
|
loadChunks(tempMatdChunks, (*it)->position, (*it)->size);
|
||||||
|
|
||||||
|
vTextures.push_back("");
|
||||||
|
|
||||||
// analyse MATD subchunks
|
// analyse MATD subchunks
|
||||||
analyseMatdChunks(tempMatdChunks);
|
analyseMatdChunks(tempMatdChunks);
|
||||||
|
|
||||||
@@ -170,7 +160,6 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
|
|||||||
if (!strcmp("MODL", (*it)->name))
|
if (!strcmp("MODL", (*it)->name))
|
||||||
{
|
{
|
||||||
Modl* tempModl = new Modl;
|
Modl* tempModl = new Modl;
|
||||||
setModlDefault(tempModl);
|
|
||||||
|
|
||||||
// get all subchunks
|
// get all subchunks
|
||||||
std::list<ChunkHeader*> tempChunks;
|
std::list<ChunkHeader*> tempChunks;
|
||||||
@@ -206,7 +195,7 @@ void Object::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
|
|||||||
char* buffer = new char[(*it)->size + 1];
|
char* buffer = new char[(*it)->size + 1];
|
||||||
*buffer = { 0 };
|
*buffer = { 0 };
|
||||||
fsMesh.read(buffer, (*it)->size);
|
fsMesh.read(buffer, (*it)->size);
|
||||||
vTextures.push_back(buffer);
|
vTextures.back() = buffer;
|
||||||
delete buffer;
|
delete buffer;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -382,49 +371,28 @@ void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
|||||||
|
|
||||||
void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
|
void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
|
||||||
{
|
{
|
||||||
|
Segment* tempData = new Segment;
|
||||||
|
|
||||||
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
|
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
|
||||||
{
|
{
|
||||||
/*if (!strcmp("SHDW", (*it)->name))
|
|
||||||
{
|
|
||||||
fsMesh.seekg((*it)->position);
|
|
||||||
/* shadow mesh geometry
|
|
||||||
|
|
||||||
long int - 4 - number of vertex positions
|
|
||||||
float[3][] - 12 each - vertex positions (XYZ)
|
|
||||||
long int - 4 - number of edges
|
|
||||||
short int[4][] - 8 each - edge the following 4 entries from one edge
|
|
||||||
> short int - 2 - vertex index of this edge, referes to the vertex list
|
|
||||||
> short int - 2 - Reference into an edge. Defines the target vertex (the local edge vertex of the referenced edge) to which the edge should be dran from the local vertex
|
|
||||||
> short int - 2 - Second reference into an edge. In all example .msh files I've seen this always refers to the same vertex as the first edge reference
|
|
||||||
> short int - 2 - MAX_VALUE of short integers (65535). Indicates the end of this edge
|
|
||||||
* /
|
|
||||||
continue;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (!strcmp("MATI", (*it)->name))
|
if (!strcmp("MATI", (*it)->name))
|
||||||
{
|
{
|
||||||
fsMesh.seekg((*it)->position);
|
fsMesh.seekg((*it)->position);
|
||||||
std::uint32_t tempIndex;
|
fsMesh.read(reinterpret_cast<char*>(&tempData->textureIndex), sizeof(tempData->textureIndex));
|
||||||
fsMesh.read(reinterpret_cast<char*>(&tempIndex), sizeof(tempIndex));
|
|
||||||
if (vTextures.size() <= tempIndex)
|
|
||||||
{
|
|
||||||
std::cout << "warning texture index <" << tempIndex << "> unknown" << std::endl;
|
|
||||||
dataDestination->texture = "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
dataDestination->texture = vTextures[tempIndex];
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp("POSL", (*it)->name))
|
if (!strcmp("POSL", (*it)->name))
|
||||||
{
|
{
|
||||||
readVertex(dataDestination, (*it)->position);
|
readVertex(tempData, (*it)->position);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (!strcmp("NRML", (*it)->name))
|
/*if (!strcmp("NRML", (*it)->name))
|
||||||
{
|
{
|
||||||
fsMesh.seekg((*it)->position);
|
fsMesh.seekg((*it)->position);
|
||||||
|
std::uint32_t tempSize;
|
||||||
|
fsMesh.read(reinterpret_cast<char*>(&tempSize), sizeof(tempSize));
|
||||||
// List of normals
|
// List of normals
|
||||||
// long int - 4 - number of normal vectores stored in this list
|
// long int - 4 - number of normal vectores stored in this list
|
||||||
// float[3][] - 12 each - UVW vector for each vertex
|
// float[3][] - 12 each - UVW vector for each vertex
|
||||||
@@ -433,44 +401,83 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
|||||||
|
|
||||||
if (!strcmp("UV0L", (*it)->name))
|
if (!strcmp("UV0L", (*it)->name))
|
||||||
{
|
{
|
||||||
readUV(dataDestination, (*it)->position);
|
readUV(tempData, (*it)->position);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp("STRP", (*it)->name))
|
if (!strcmp("STRP", (*it)->name))
|
||||||
{
|
{
|
||||||
|
// don't get null, bone, shadowMesh and hidden mesh indices
|
||||||
|
if (dataDestination->type == null ||
|
||||||
|
dataDestination->type == bone ||
|
||||||
|
dataDestination->type == shadowMesh ||
|
||||||
|
dataDestination->renderFlags == 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// jump to the data section and read the size;
|
||||||
|
std::uint32_t tempSize;
|
||||||
fsMesh.seekg((*it)->position);
|
fsMesh.seekg((*it)->position);
|
||||||
|
fsMesh.read(reinterpret_cast<char*>(&tempSize), sizeof(tempSize));
|
||||||
|
|
||||||
fsMesh.seekg((*it)->position);
|
int highBitCount(0);
|
||||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->meshSize), sizeof(dataDestination->meshSize));
|
std::vector<uint32_t>* tempPoly = new std::vector<uint32_t>;
|
||||||
|
|
||||||
dataDestination->mesh = new std::uint32_t[dataDestination->meshSize];
|
for (unsigned int i = 0; i < tempSize; i++)
|
||||||
|
|
||||||
for (unsigned int i = 0; i < dataDestination->meshSize; i += 3)
|
|
||||||
{
|
{
|
||||||
std::uint16_t tempValue[3];
|
// ReadData
|
||||||
fsMesh.read(reinterpret_cast<char*>(&tempValue[0]), sizeof(std::uint16_t));
|
std::uint16_t tempValue;
|
||||||
fsMesh.read(reinterpret_cast<char*>(&tempValue[1]), sizeof(std::uint16_t));
|
fsMesh.read(reinterpret_cast<char*>(&tempValue), sizeof(std::uint16_t));
|
||||||
fsMesh.read(reinterpret_cast<char*>(&tempValue[2]), sizeof(std::uint16_t));
|
|
||||||
|
|
||||||
if (!(tempValue[0] >> 15 && tempValue[1] >> 15 && !(tempValue[2] >> 15)))
|
// Check for highbit
|
||||||
throw std::invalid_argument("invalid file. go and triangulate!");
|
if (tempValue >> 15)
|
||||||
|
{
|
||||||
tempValue[0] = (std::uint16_t(tempValue[0] << 1) >> 1);
|
highBitCount++;
|
||||||
tempValue[1] = (std::uint16_t(tempValue[1] << 1) >> 1);
|
tempValue = (std::uint16_t(tempValue << 1) >> 1);
|
||||||
|
|
||||||
dataDestination->mesh[i] = (std::uint32_t)tempValue[0];
|
|
||||||
dataDestination->mesh[i + 1] = (std::uint32_t)tempValue[1];
|
|
||||||
dataDestination->mesh[i + 2] = (std::uint32_t)tempValue[2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tempPoly->push_back((std::uint32_t)tempValue);
|
||||||
|
|
||||||
|
// new Polygon found
|
||||||
|
if (highBitCount == 2)
|
||||||
|
{
|
||||||
|
// reset highBitCount
|
||||||
|
highBitCount = 0;
|
||||||
|
|
||||||
|
// remove the last two values..
|
||||||
|
std::uint32_t saveData[2];
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
saveData[i] = tempPoly->back();
|
||||||
|
tempPoly->pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ..and save them in the new vector
|
||||||
|
std::vector<uint32_t>* newPointer = new std::vector<uint32_t>;
|
||||||
|
for (int i = 1; i >= 0; i--)
|
||||||
|
newPointer->push_back(saveData[i]);
|
||||||
|
|
||||||
|
// save the old vector and set the pointer to the new one
|
||||||
|
tempData->meshIndices.push_back(tempPoly);
|
||||||
|
tempPoly = newPointer;
|
||||||
|
} // if high bit set
|
||||||
|
|
||||||
|
} // for all values
|
||||||
|
|
||||||
|
// save the last values (where no 2 high bits follow);
|
||||||
|
tempData->meshIndices.push_back(tempPoly);
|
||||||
|
|
||||||
|
// kick the first element, it's empty as a reason of the algo above;
|
||||||
|
tempData->meshIndices.erase(tempData->meshIndices.begin());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dataDestination->segmLst.push_back(tempData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
|
void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
|
||||||
{
|
{
|
||||||
|
Segment* tempData = new Segment;
|
||||||
|
|
||||||
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
|
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
|
||||||
{
|
{
|
||||||
if (!strcmp("CTEX", (*it)->name))
|
if (!strcmp("CTEX", (*it)->name))
|
||||||
@@ -479,42 +486,71 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
|||||||
char* buffer = new char[(*it)->size];
|
char* buffer = new char[(*it)->size];
|
||||||
*buffer = { 0 };
|
*buffer = { 0 };
|
||||||
fsMesh.read(buffer, (*it)->size);
|
fsMesh.read(buffer, (*it)->size);
|
||||||
dataDestination->texture = buffer;
|
|
||||||
|
bool tempFound(false);
|
||||||
|
|
||||||
|
for (unsigned int index = 0; index < vTextures.size(); index++)
|
||||||
|
{
|
||||||
|
if (!strcmp(buffer, vTextures[index].c_str()))
|
||||||
|
{
|
||||||
|
tempData->textureIndex = index;
|
||||||
|
tempFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tempFound)
|
||||||
|
{
|
||||||
|
vTextures.push_back(std::string(buffer));
|
||||||
|
tempData->textureIndex = vTextures.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
delete buffer;
|
delete buffer;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp("CPOS", (*it)->name))
|
if (!strcmp("CPOS", (*it)->name))
|
||||||
{
|
{
|
||||||
readVertex(dataDestination, (*it)->position);
|
readVertex(tempData, (*it)->position);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp("CUV0", (*it)->name))
|
if (!strcmp("CUV0", (*it)->name))
|
||||||
{
|
{
|
||||||
readUV(dataDestination, (*it)->position);
|
readUV(tempData, (*it)->position);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp("CMSH", (*it)->name))
|
if (!strcmp("CMSH", (*it)->name))
|
||||||
{
|
{
|
||||||
|
// jump to the data section and read the size;
|
||||||
|
std::uint32_t tempSize;
|
||||||
fsMesh.seekg((*it)->position);
|
fsMesh.seekg((*it)->position);
|
||||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->meshSize), sizeof(dataDestination->meshSize));
|
fsMesh.read(reinterpret_cast<char*>(&tempSize), sizeof(tempSize));
|
||||||
|
|
||||||
dataDestination->mesh = new std::uint32_t[dataDestination->meshSize * 3];
|
std::vector<uint32_t>* tempPoly;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < dataDestination->meshSize; i += 3)
|
// for every triangle..
|
||||||
|
for (unsigned int i = 0; i < tempSize; i += 3)
|
||||||
{
|
{
|
||||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->mesh[i]), sizeof(std::uint32_t));
|
tempPoly = new std::vector<uint32_t>;
|
||||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->mesh[i + 1]), sizeof(std::uint32_t));
|
|
||||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->mesh[i + 2]), sizeof(std::uint32_t));
|
// ..get the 3 indices and save them
|
||||||
|
for (int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
std::uint32_t tempValue;
|
||||||
|
fsMesh.read(reinterpret_cast<char*>(&tempValue), sizeof(std::uint32_t));
|
||||||
|
tempPoly->push_back(tempValue);
|
||||||
|
}
|
||||||
|
tempData->meshIndices.push_back(tempPoly);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dataDestination->segmLst.push_back(tempData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::readVertex(Modl* dataDestination, std::streampos position)
|
void Object::readVertex(Segment* dataDestination, std::streampos position)
|
||||||
{
|
{
|
||||||
std::uint32_t tempSize;
|
std::uint32_t tempSize;
|
||||||
fsMesh.seekg(position);
|
fsMesh.seekg(position);
|
||||||
@@ -526,7 +562,7 @@ void Object::readVertex(Modl* dataDestination, std::streampos position)
|
|||||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i]), sizeof(float));
|
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i]), sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::readUV(Modl* dataDestination, std::streampos position)
|
void Object::readUV(Segment* dataDestination, std::streampos position)
|
||||||
{
|
{
|
||||||
std::uint32_t tempSize;
|
std::uint32_t tempSize;
|
||||||
fsMesh.seekg(position);
|
fsMesh.seekg(position);
|
||||||
@@ -547,6 +583,11 @@ std::vector<Modl*> Object::getModels() const
|
|||||||
return vModls;
|
return vModls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> Object::getTextureList() const
|
||||||
|
{
|
||||||
|
return vTextures;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// public functions
|
// public functions
|
||||||
|
@@ -1,17 +1,14 @@
|
|||||||
#include <gl\glew.h>
|
|
||||||
#include <gl\glfw3.h>
|
|
||||||
#include <Windows.h>
|
|
||||||
#include "OpenGLController.h"
|
#include "OpenGLController.h"
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
|
|
||||||
#include <glm\gtc\matrix_transform.hpp>
|
|
||||||
#include "shader.hpp"
|
#include "shader.hpp"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include <iostream>
|
#include <Windows.h>
|
||||||
|
#include <string>
|
||||||
|
#include <glm\gtc\matrix_transform.hpp>
|
||||||
|
|
||||||
|
|
||||||
#define VERTEX_SHADER "Shader/TextureShader.vert"
|
#define VERTEX_SHADER "Shader/TextureShader.vert"
|
||||||
#define FRAGMENT_SHADER "Shader/TextureShader.frag"
|
#define FRAGMENT_SHADER "Shader/TextureShader.frag"
|
||||||
#define MAX_MODEL_COUNT 1000
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// public constructor/destructor
|
// public constructor/destructor
|
||||||
@@ -31,24 +28,7 @@ OpenGLController::~OpenGLController()
|
|||||||
glDeleteTextures(1, &gluiSamplerID);
|
glDeleteTextures(1, &gluiSamplerID);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
|
||||||
while (!vModels.empty())
|
deleteVectors();
|
||||||
{
|
|
||||||
Modl* cursor = vModels.back();
|
|
||||||
vModels.pop_back();
|
|
||||||
|
|
||||||
delete cursor->uv;
|
|
||||||
delete cursor->mesh;
|
|
||||||
delete cursor->vertex;
|
|
||||||
delete cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!vTextures.empty())
|
|
||||||
{
|
|
||||||
textureData* cursor = vTextures.back();
|
|
||||||
vTextures.pop_back();
|
|
||||||
delete cursor->data;
|
|
||||||
delete cursor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -127,6 +107,44 @@ void OpenGLController::processInit()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLController::deleteVectors()
|
||||||
|
{
|
||||||
|
while (!vModels.empty())
|
||||||
|
{
|
||||||
|
Modl* cursor = vModels.back();
|
||||||
|
vModels.pop_back();
|
||||||
|
|
||||||
|
while (!cursor->segmLst.empty())
|
||||||
|
{
|
||||||
|
Segment* segmCuror = cursor->segmLst.back();
|
||||||
|
cursor->segmLst.pop_back();
|
||||||
|
|
||||||
|
delete segmCuror->uv;
|
||||||
|
delete segmCuror->vertex;
|
||||||
|
|
||||||
|
while (!segmCuror->meshIndices.empty())
|
||||||
|
{
|
||||||
|
std::vector<std::uint32_t>* meshCursor = segmCuror->meshIndices.back();
|
||||||
|
meshCursor->clear();
|
||||||
|
segmCuror->meshIndices.pop_back();
|
||||||
|
delete meshCursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete segmCuror;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!vTextures.empty())
|
||||||
|
{
|
||||||
|
textureData* cursor = vTextures.back();
|
||||||
|
vTextures.pop_back();
|
||||||
|
delete cursor->data;
|
||||||
|
delete cursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLController::startGLFW()
|
void OpenGLController::startGLFW()
|
||||||
{
|
{
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
@@ -182,6 +200,23 @@ void OpenGLController::setCallbackFunctions()
|
|||||||
glfwSetWindowSizeCallback(pWindow, windowResize);
|
glfwSetWindowSizeCallback(pWindow, windowResize);
|
||||||
glfwSetScrollCallback(pWindow, mouseWheel);
|
glfwSetScrollCallback(pWindow, mouseWheel);
|
||||||
glfwSetKeyCallback(pWindow, keyPress);
|
glfwSetKeyCallback(pWindow, keyPress);
|
||||||
|
glfwSetDropCallback(pWindow, dragNdrop);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::mat4 OpenGLController::getModelMatrix(unsigned int index)
|
||||||
|
{
|
||||||
|
glm::mat4 tempParentMatrix = glm::mat4(1.0f);
|
||||||
|
|
||||||
|
for (unsigned int loop = 0; loop < vModels.size(); loop++)
|
||||||
|
{
|
||||||
|
if (!strcmp(vModels[index]->parent.c_str(), vModels[loop]->name.c_str()))
|
||||||
|
{
|
||||||
|
tempParentMatrix = getModelMatrix(loop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempParentMatrix * vModels[index]->m4x4Translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
|
glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
|
||||||
@@ -196,10 +231,6 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
|
|||||||
glm::vec3(0, 1, 0)
|
glm::vec3(0, 1, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Model
|
|
||||||
//TODO for all
|
|
||||||
glm::mat4 m4x4Model = vModels[index]->m4x4Translation;
|
|
||||||
|
|
||||||
// User controlled rotation
|
// User controlled rotation
|
||||||
glm::mat4 m4x4ModelRot = glm::mat4(1.0f);
|
glm::mat4 m4x4ModelRot = glm::mat4(1.0f);
|
||||||
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationX, glm::vec3(1, 0, 0));
|
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationX, glm::vec3(1, 0, 0));
|
||||||
@@ -207,7 +238,7 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
|
|||||||
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1));
|
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1));
|
||||||
|
|
||||||
// Return MVP
|
// Return MVP
|
||||||
return m4x4Projection * m4x4View * m4x4ModelRot * m4x4Model;
|
return m4x4Projection * m4x4View * m4x4ModelRot * getModelMatrix(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -254,6 +285,16 @@ void OpenGLController::addTransZ(double value)
|
|||||||
dTranslationZ += value;
|
dTranslationZ += value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLController::resetView()
|
||||||
|
{
|
||||||
|
dTranslationX = 0;
|
||||||
|
dTranslationY = 0;
|
||||||
|
dTranslationZ = 5;
|
||||||
|
fRotationX = 0;
|
||||||
|
fRotationY = 0;
|
||||||
|
fRotationZ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLController::updateScene()
|
void OpenGLController::updateScene()
|
||||||
{
|
{
|
||||||
// get new matrices
|
// get new matrices
|
||||||
@@ -270,18 +311,30 @@ void OpenGLController::updateScene()
|
|||||||
|
|
||||||
int instanceOffset(0);
|
int instanceOffset(0);
|
||||||
|
|
||||||
for (int modelIndex = 0; modelIndex < vModels.size(); modelIndex++)
|
for (unsigned int modelIndex = 0; modelIndex < vModels.size(); modelIndex++)
|
||||||
|
{
|
||||||
|
// skip null, bones, shadowMesh, hidden things (don't increase textrue index!!)
|
||||||
|
if (vModels[modelIndex]->type == null ||
|
||||||
|
vModels[modelIndex]->type == bone ||
|
||||||
|
vModels[modelIndex]->type == shadowMesh ||
|
||||||
|
vModels[modelIndex]->renderFlags == 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto& segIt : vModels[modelIndex]->segmLst)
|
||||||
{
|
{
|
||||||
// give texture to the shader
|
// give texture to the shader
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
std::uint32_t tempTexIndex = segIt->textureIndex >= vTextures.size() ? vTextures.size() - 1 : segIt->textureIndex;
|
||||||
|
|
||||||
|
glTexImage2D(
|
||||||
|
GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
vTextures[modelIndex]->alpha ? GL_RGBA : GL_RGB,
|
vTextures[tempTexIndex]->alpha ? GL_RGBA : GL_RGB,
|
||||||
vTextures[modelIndex]->width,
|
vTextures[tempTexIndex]->width,
|
||||||
vTextures[modelIndex]->height,
|
vTextures[tempTexIndex]->height,
|
||||||
0,
|
0,
|
||||||
vTextures[modelIndex]->alpha ? GL_BGRA : GL_BGR,
|
vTextures[tempTexIndex]->alpha ? GL_BGRA : GL_BGR,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
vTextures[modelIndex]->data->data()
|
vTextures[tempTexIndex]->data->data()
|
||||||
);
|
);
|
||||||
|
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
@@ -289,9 +342,17 @@ void OpenGLController::updateScene()
|
|||||||
// give the MVP to the shader
|
// give the MVP to the shader
|
||||||
glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix(modelIndex)[0][0]);
|
glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix(modelIndex)[0][0]);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, instanceOffset, vModels[modelIndex]->meshSize);
|
// calculate the number of vertex
|
||||||
|
unsigned int vertexCount(0);
|
||||||
|
for (auto& it : segIt->meshIndices)
|
||||||
|
vertexCount += (it->size() - 2) * 3;
|
||||||
|
|
||||||
instanceOffset += vModels[modelIndex]->meshSize;
|
|
||||||
|
glDrawArrays(GL_TRIANGLES, instanceOffset, vertexCount);
|
||||||
|
|
||||||
|
// increase the offset
|
||||||
|
instanceOffset += vertexCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(pWindow);
|
glfwSwapBuffers(pWindow);
|
||||||
@@ -300,44 +361,70 @@ void OpenGLController::updateScene()
|
|||||||
|
|
||||||
void OpenGLController::loadMsh(const char * path)
|
void OpenGLController::loadMsh(const char * path)
|
||||||
{
|
{
|
||||||
|
// clean up old stuff first
|
||||||
|
deleteVectors();
|
||||||
|
|
||||||
|
std::vector<std::string> tempTexList;
|
||||||
|
|
||||||
// get all models
|
// get all models
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object obj(path);
|
Object obj(path);
|
||||||
vModels = obj.getModels();
|
vModels = obj.getModels();
|
||||||
|
tempTexList = obj.getTextureList();
|
||||||
}
|
}
|
||||||
catch (std::invalid_argument e)
|
catch (std::invalid_argument e)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, e.what(), "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
|
MessageBox(NULL, e.what(), "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
|
||||||
exit(1);
|
return; exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect vertex data of all models
|
// collect vertex data of all models
|
||||||
std::vector<Vertex> tempBufferData;
|
std::vector<Vertex> tempBufferData;
|
||||||
|
|
||||||
for (auto& it : vModels)
|
for (auto& modIt : vModels) // for every model chunk
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < it->meshSize; i++)
|
for (auto& segIt : modIt->segmLst) // for every cluster
|
||||||
|
{
|
||||||
|
for (auto& mshIt : segIt->meshIndices) // for every polygon
|
||||||
|
{
|
||||||
|
if (mshIt->size() >= 3) // multipoly
|
||||||
|
{
|
||||||
|
// for every triangle of the multi polygon
|
||||||
|
for (unsigned int tri = 0; tri < mshIt->size() - 2; tri++)
|
||||||
|
{
|
||||||
|
// for every edge of the triangle
|
||||||
|
for (int triEdge = 0; triEdge < 3; triEdge++)
|
||||||
{
|
{
|
||||||
Vertex tempVertex;
|
Vertex tempVertex;
|
||||||
tempVertex.position[0] = (GLfloat)it->vertex[it->mesh[i] * 3];
|
// every edge has 3 coordinates
|
||||||
tempVertex.position[1] = (GLfloat)it->vertex[it->mesh[i] * 3 + 1];
|
for (int j = 0; j < 3; j++)
|
||||||
tempVertex.position[2] = (GLfloat)it->vertex[it->mesh[i] * 3 + 2];
|
tempVertex.position[j] = (GLfloat)segIt->vertex[(*mshIt)[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 3 + j];
|
||||||
|
|
||||||
if (it->uv == NULL)
|
// and 2 UV
|
||||||
|
if (segIt->uv == NULL)
|
||||||
{
|
{
|
||||||
tempVertex.uv[0] = 1.0;
|
tempVertex.uv[0] = 1.0;
|
||||||
tempVertex.uv[1] = 1.0;
|
tempVertex.uv[1] = 1.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tempVertex.uv[0] = (GLfloat)it->uv[it->mesh[i] * 2];
|
for (int j = 0; j < 2; j++)
|
||||||
tempVertex.uv[1] = (GLfloat)it->uv[it->mesh[i] * 2 + 1];
|
tempVertex.uv[j] = (GLfloat)segIt->uv[(*mshIt)[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 2 + j];
|
||||||
}
|
}
|
||||||
|
|
||||||
tempBufferData.push_back(tempVertex);
|
tempBufferData.push_back(tempVertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else // this shouldn't happen (polygon with less then 3 vertex)
|
||||||
|
{
|
||||||
|
deleteVectors();
|
||||||
|
MessageBox(NULL, "You have polygons with less then 3 vertices!", "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fill the buffer
|
// fill the buffer
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, gluiVertexBufferID);
|
glBindBuffer(GL_ARRAY_BUFFER, gluiVertexBufferID);
|
||||||
@@ -350,21 +437,20 @@ void OpenGLController::loadMsh(const char * path)
|
|||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
|
||||||
// get textures
|
// get textures path
|
||||||
for (auto& it : vModels)
|
|
||||||
{
|
|
||||||
textureData* tempData = new textureData;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (it->texture == "")
|
|
||||||
throw std::invalid_argument("no texture name");
|
|
||||||
|
|
||||||
std::string tempPath = path;
|
std::string tempPath = path;
|
||||||
|
|
||||||
while (tempPath.back() != '/' && tempPath.back() != '\\')
|
while (tempPath.back() != '/' && tempPath.back() != '\\')
|
||||||
tempPath.pop_back();
|
tempPath.pop_back();
|
||||||
|
|
||||||
TextureTGA tempTex(std::string(tempPath + it->texture).c_str());
|
// load all textures;
|
||||||
|
for (auto& texIt : tempTexList)
|
||||||
|
{
|
||||||
|
textureData* tempData = new textureData;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TextureTGA tempTex(std::string(tempPath + texIt).c_str());
|
||||||
|
|
||||||
tempData->alpha = tempTex.hasAlpha();
|
tempData->alpha = tempTex.hasAlpha();
|
||||||
tempData->width = tempTex.getWidth();
|
tempData->width = tempTex.getWidth();
|
||||||
@@ -373,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;
|
||||||
@@ -382,4 +467,14 @@ void OpenGLController::loadMsh(const char * path)
|
|||||||
|
|
||||||
vTextures.push_back(tempData);
|
vTextures.push_back(tempData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add a solid default color at the end (maybe there is an invalid index later)
|
||||||
|
textureData* tempData = new textureData;
|
||||||
|
tempData->alpha = true;
|
||||||
|
tempData->width = 1;
|
||||||
|
tempData->height = 1;
|
||||||
|
tempData->data = new std::vector<std::uint8_t>({ 0, 0, 255, 255 });
|
||||||
|
vTextures.push_back(tempData);
|
||||||
|
|
||||||
|
tempTexList.clear();
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
TextureTGA::TextureTGA(const char * filePath)
|
TextureTGA::TextureTGA(const char * filePath)
|
||||||
{
|
{
|
||||||
@@ -58,8 +56,7 @@ TextureTGA::TextureTGA(const char * filePath)
|
|||||||
{
|
{
|
||||||
std::uint8_t tempChunkHeader;
|
std::uint8_t tempChunkHeader;
|
||||||
std::uint8_t tempData[5];
|
std::uint8_t tempData[5];
|
||||||
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));
|
||||||
|
@@ -1,6 +1,3 @@
|
|||||||
//#include "callback.h"
|
|
||||||
#include <gl\glew.h>
|
|
||||||
#include <gl\glfw3.h>
|
|
||||||
#include "OpenGLController.h"
|
#include "OpenGLController.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -81,6 +78,8 @@ void mouseWheel(GLFWwindow *window, double xoffset, double yoffset)
|
|||||||
|
|
||||||
void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods)
|
void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
|
OpenGLController* controller = reinterpret_cast<OpenGLController*>(glfwGetWindowUserPointer(window));
|
||||||
|
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT)
|
if (action == GLFW_PRESS || action == GLFW_REPEAT)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
@@ -96,8 +95,22 @@ void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods)
|
|||||||
case GLFW_KEY_PLUS_GER: case GLFW_KEY_KP_ADD:
|
case GLFW_KEY_PLUS_GER: case GLFW_KEY_KP_ADD:
|
||||||
mouse.speed += 0.1;
|
mouse.speed += 0.1;
|
||||||
break;
|
break;
|
||||||
|
case GLFW_KEY_SPACE:
|
||||||
|
controller->resetView();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dragNdrop(GLFWwindow* window, int count, const char** paths)
|
||||||
|
{
|
||||||
|
OpenGLController* controller = reinterpret_cast<OpenGLController*>(glfwGetWindowUserPointer(window));
|
||||||
|
|
||||||
|
if (count < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
controller->resetView();
|
||||||
|
controller->loadMsh(paths[0]);
|
||||||
|
}
|
||||||
|
@@ -3,9 +3,6 @@
|
|||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
#include "OpenGLController.h"
|
#include "OpenGLController.h"
|
||||||
#include "Object.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@@ -20,8 +17,7 @@ int main(int argc, char** argv)
|
|||||||
else
|
else
|
||||||
scene = OpenGLController::getInstance();
|
scene = OpenGLController::getInstance();
|
||||||
|
|
||||||
scene->loadMsh("..\\Release\\Msh\\multiModTex.msh");
|
scene->loadMsh("..\\Release\\Msh\\quadPoly.msh");
|
||||||
//scene->loadMsh("..\\Release\\Msh\\cubeTex.msh");
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
scene->updateScene();
|
scene->updateScene();
|
||||||
|
11
README.md
11
README.md
@@ -13,11 +13,8 @@ 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
|
||||||
- crashing sometimes - no idea why,
|
- cloth not working correctly
|
||||||
- bones are not triangulated,
|
- optional display bones, shadow, collision,...
|
||||||
- nulls are not triangulated,
|
|
||||||
- crash when loading trooper,
|
|
||||||
- display cloth testing
|
|
||||||
- integrate into a software:
|
- integrate into a software:
|
||||||
-> gui open file ( + drag and drop),
|
-> gui open file ( + drag and drop),
|
||||||
-> list all msh under a directory,
|
-> list all msh under a directory,
|
||||||
@@ -25,6 +22,4 @@ licence, too.
|
|||||||
-> display colisions,
|
-> display colisions,
|
||||||
-> lights,
|
-> lights,
|
||||||
-> handle render flags,
|
-> handle render flags,
|
||||||
- draw more then one model,
|
|
||||||
- use different textures for one or multiple models,
|
|
||||||
- take a look at destruction
|
|
||||||
|
BIN
Release/Msh/1.tga
Normal file
BIN
Release/Msh/1.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Release/Msh/2.tga
Normal file
BIN
Release/Msh/2.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Release/Msh/3.tga
Normal file
BIN
Release/Msh/3.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Release/Msh/4-Poly.msh
Normal file
BIN
Release/Msh/4-Poly.msh
Normal file
Binary file not shown.
BIN
Release/Msh/4.tga
Normal file
BIN
Release/Msh/4.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Release/Msh/5-Poly.msh
Normal file
BIN
Release/Msh/5-Poly.msh
Normal file
Binary file not shown.
BIN
Release/Msh/5.tga
Normal file
BIN
Release/Msh/5.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Release/Msh/6-poly.msh
Normal file
BIN
Release/Msh/6-poly.msh
Normal file
Binary file not shown.
BIN
Release/Msh/6.tga
Normal file
BIN
Release/Msh/6.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Release/Msh/cluster.msh
Normal file
BIN
Release/Msh/cluster.msh
Normal file
Binary file not shown.
BIN
Release/Msh/quadPoly.msh
Normal file
BIN
Release/Msh/quadPoly.msh
Normal file
Binary file not shown.
BIN
Release/Msh/structured.msh
Normal file
BIN
Release/Msh/structured.msh
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user