From 5cec0128cd6c85c8fdd3bff65f62988f066f64f7 Mon Sep 17 00:00:00 2001 From: Anakin Date: Sun, 23 Oct 2016 16:01:06 +0200 Subject: [PATCH] draw all triangles instead of the first 12, added todo section to the README.md, clean up code --- MshViewer/Header/Object.h | 3 ++- MshViewer/Header/OpenGLController.h | 1 + MshViewer/Source/Object.cpp | 28 ++++++++++++++------------ MshViewer/Source/OpenGlController.cpp | 3 ++- README.md | 19 ++++++++++++++++- Release/Msh/sphere.msh | Bin 0 -> 2632 bytes 6 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 Release/Msh/sphere.msh diff --git a/MshViewer/Header/Object.h b/MshViewer/Header/Object.h index c9182c5..a5e60b1 100644 --- a/MshViewer/Header/Object.h +++ b/MshViewer/Header/Object.h @@ -39,8 +39,8 @@ struct Modl { std::string texture; float* vertex; float* uv; - std::uint32_t meshSize; std::uint32_t* mesh; + std::uint32_t meshSize; }; @@ -73,6 +73,7 @@ private: public: std::vector getVertex() const; std::vector getUV() const; + std::list getSize() const; std::list getTexture() const; }; diff --git a/MshViewer/Header/OpenGLController.h b/MshViewer/Header/OpenGLController.h index fbf782d..537fd03 100644 --- a/MshViewer/Header/OpenGLController.h +++ b/MshViewer/Header/OpenGLController.h @@ -49,6 +49,7 @@ private: // data std::vector vfVertices; std::vector vfUV; + std::uint32_t ui32MeshSize; // transformation =============== //values diff --git a/MshViewer/Source/Object.cpp b/MshViewer/Source/Object.cpp index 2be66c8..512f986 100644 --- a/MshViewer/Source/Object.cpp +++ b/MshViewer/Source/Object.cpp @@ -124,9 +124,6 @@ void Object::loadChunks(std::list& destination, std::streampos sta } } while (true); - - std::cout << "got all chunks, totaly found: " << destination.size() << std::endl; - } void Object::analyseMsh2Chunks(std::list& chunkList) @@ -180,7 +177,6 @@ void Object::analyseMsh2Chunks(std::list& chunkList) if (!strcmp("MODL", (*it)->name)) { - Modl* tempModl = new Modl; setModlDefault(tempModl); @@ -313,12 +309,10 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list& c continue; } } - } void Object::analyseGeomChunks(Modl * dataDestination, std::list& chunkList) { - for (std::list::iterator it = chunkList.begin(); it != chunkList.end(); it++) { if (!strcmp("SEGM", (*it)->name)) @@ -359,14 +353,13 @@ void Object::analyseGeomChunks(Modl * dataDestination, std::list& continue; } } - } void Object::analyseSegmChunks(Modl * dataDestination, std::list& chunkList) { for (std::list::iterator it = chunkList.begin(); it != chunkList.end(); it++) { - if (!strcmp("SHDW", (*it)->name)) + /*if (!strcmp("SHDW", (*it)->name)) { fsMesh.seekg((*it)->position); /* shadow mesh geometry @@ -379,9 +372,9 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::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)) { @@ -404,14 +397,14 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list& continue; } - if (!strcmp("NRML", (*it)->name)) + /*if (!strcmp("NRML", (*it)->name)) { fsMesh.seekg((*it)->position); // List of normals // long int - 4 - number of normal vectores stored in this list // float[3][] - 12 each - UVW vector for each vertex continue; - } + }*/ if (!strcmp("UV0L", (*it)->name)) { @@ -494,7 +487,6 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list& continue; } } - } void Object::readVertex(Modl* dataDestination, std::streampos position) @@ -571,6 +563,16 @@ std::vector Object::getUV() const return tempData; } +std::list Object::getSize() const +{ + std::list tempData; + + for (std::list::const_iterator it = lModls.begin(); it != lModls.end(); it++) + tempData.push_back((*it)->meshSize); + + return tempData; +} + std::list Object::getTexture() const { std::list tempData; diff --git a/MshViewer/Source/OpenGlController.cpp b/MshViewer/Source/OpenGlController.cpp index 28ace6e..6d05476 100644 --- a/MshViewer/Source/OpenGlController.cpp +++ b/MshViewer/Source/OpenGlController.cpp @@ -247,7 +247,7 @@ void OpenGLController::updateScene() glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0); //draw objects - glDrawArrays(GL_TRIANGLES, 0, 12 * 3); + glDrawArrays(GL_TRIANGLES, 0, ui32MeshSize * 3); //close attributes glDisableVertexAttribArray(0); @@ -288,6 +288,7 @@ void OpenGLController::loadMsh(const char * path) vfVertices = obj.getVertex(); vfUV = obj.getUV(); listTextures = obj.getTexture(); + ui32MeshSize = obj.getSize().front(); } catch (std::invalid_argument e) { diff --git a/README.md b/README.md index 91e38da..24d0fef 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,21 @@ So far it is just me. If you wanna help me, let me know :D ### Licence Feel free to use my code the way you like. But remember i used some public libraries. Make sure you read their -licence, too. \ No newline at end of file +licence, too. + +### To Do +- sphere isn't displayed correctly, +- bones are not triangulated, +- nulls are not triangulated, +- crash when loading trooper, +- display cloth testing +- integrate into a software: +-> gui open file ( + drag and drop), +-> list all msh under a directory, +-> display shadows, +-> display colisions, +-> lights, +-> handle render flags, +- draw more then one model, +- use different textures for one or multiple models, +- take a look at destruction diff --git a/Release/Msh/sphere.msh b/Release/Msh/sphere.msh new file mode 100644 index 0000000000000000000000000000000000000000..e05aa35f95cef41e63ec21241ddc4f0cb9579e07 GIT binary patch literal 2632 zcmb7_%}-oa7{*_4`2OgiFi@a$fX*M5)(t}NGa-a5CgoZiCf;#tk|q5W$) zzklP(_RVefx^j9mT)VZAUrq7b%X7}*8FBJQ~Y$%r7TsmFY;aYMz6Yjsh zwz=}O(k#n@pFXMgFMRye=j^rpc`}I0oa`$uuc2rE@5p0c-ZhtEvky)@^tGO|Cq2bl ztM6m!rd`fD!+pidyLzvzUf=ly`ix)b2YKhgEA#2!qn#y3#b; zNoXx!#+Gz@GL9$tJ6G}<5A)QCCtZCII~~S538ycgTwh|!IXEZhGhpF-hI#o6>#2jF zPv?{Qz>_=Uoc5Lm^PeWAS?U2v$8+E1U2j3X>uo;~_9lN?=X^T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