draw all triangles instead of the first 12,

added todo section to the README.md,
clean up code
This commit is contained in:
Anakin 2016-10-23 16:01:06 +02:00
parent 6d5489a96c
commit 5cec0128cd
6 changed files with 38 additions and 16 deletions

View File

@ -39,8 +39,8 @@ struct Modl {
std::string texture; std::string texture;
float* vertex; float* vertex;
float* uv; float* uv;
std::uint32_t meshSize;
std::uint32_t* mesh; std::uint32_t* mesh;
std::uint32_t meshSize;
}; };
@ -73,6 +73,7 @@ private:
public: public:
std::vector<GLfloat> getVertex() const; std::vector<GLfloat> getVertex() const;
std::vector<GLfloat> getUV() const; std::vector<GLfloat> getUV() const;
std::list<std::uint32_t> getSize() const;
std::list<std::string> getTexture() const; std::list<std::string> getTexture() const;
}; };

View File

@ -49,6 +49,7 @@ private:
// data // data
std::vector<GLfloat> vfVertices; std::vector<GLfloat> vfVertices;
std::vector<GLfloat> vfUV; std::vector<GLfloat> vfUV;
std::uint32_t ui32MeshSize;
// transformation =============== // transformation ===============
//values //values

View File

@ -124,9 +124,6 @@ void Object::loadChunks(std::list<ChunkHeader*>& destination, std::streampos sta
} }
} while (true); } while (true);
std::cout << "got all chunks, totaly found: " << destination.size() << std::endl;
} }
void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList) void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
@ -180,7 +177,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); setModlDefault(tempModl);
@ -313,12 +309,10 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
continue; continue;
} }
} }
} }
void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList) void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
{ {
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("SEGM", (*it)->name)) if (!strcmp("SEGM", (*it)->name))
@ -359,14 +353,13 @@ void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>&
continue; continue;
} }
} }
} }
void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList) void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
{ {
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)) /*if (!strcmp("SHDW", (*it)->name))
{ {
fsMesh.seekg((*it)->position); fsMesh.seekg((*it)->position);
/* shadow mesh geometry /* shadow mesh geometry
@ -381,7 +374,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
> short int - 2 - MAX_VALUE of short integers (65535). Indicates the end of this edge > short int - 2 - MAX_VALUE of short integers (65535). Indicates the end of this edge
* / * /
continue; continue;
} }*/
if (!strcmp("MATI", (*it)->name)) if (!strcmp("MATI", (*it)->name))
{ {
@ -404,14 +397,14 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
continue; continue;
} }
if (!strcmp("NRML", (*it)->name)) /*if (!strcmp("NRML", (*it)->name))
{ {
fsMesh.seekg((*it)->position); fsMesh.seekg((*it)->position);
// 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
continue; continue;
} }*/
if (!strcmp("UV0L", (*it)->name)) if (!strcmp("UV0L", (*it)->name))
{ {
@ -494,7 +487,6 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
continue; continue;
} }
} }
} }
void Object::readVertex(Modl* dataDestination, std::streampos position) void Object::readVertex(Modl* dataDestination, std::streampos position)
@ -571,6 +563,16 @@ std::vector<GLfloat> Object::getUV() const
return tempData; return tempData;
} }
std::list<std::uint32_t> Object::getSize() const
{
std::list<std::uint32_t> tempData;
for (std::list<Modl*>::const_iterator it = lModls.begin(); it != lModls.end(); it++)
tempData.push_back((*it)->meshSize);
return tempData;
}
std::list<std::string> Object::getTexture() const std::list<std::string> Object::getTexture() const
{ {
std::list<std::string> tempData; std::list<std::string> tempData;

View File

@ -247,7 +247,7 @@ void OpenGLController::updateScene()
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);
//draw objects //draw objects
glDrawArrays(GL_TRIANGLES, 0, 12 * 3); glDrawArrays(GL_TRIANGLES, 0, ui32MeshSize * 3);
//close attributes //close attributes
glDisableVertexAttribArray(0); glDisableVertexAttribArray(0);
@ -288,6 +288,7 @@ void OpenGLController::loadMsh(const char * path)
vfVertices = obj.getVertex(); vfVertices = obj.getVertex();
vfUV = obj.getUV(); vfUV = obj.getUV();
listTextures = obj.getTexture(); listTextures = obj.getTexture();
ui32MeshSize = obj.getSize().front();
} }
catch (std::invalid_argument e) catch (std::invalid_argument e)
{ {

View File

@ -11,3 +11,20 @@ So far it is just me. If you wanna help me, let me know :D
### Licence ### Licence
Feel free to use my code the way you like. But remember i used some public libraries. Make sure you read their Feel free to use my code the way you like. But remember i used some public libraries. Make sure you read their
licence, too. 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

BIN
Release/Msh/sphere.msh Normal file

Binary file not shown.