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;
float* vertex;
float* uv;
std::uint32_t meshSize;
std::uint32_t* mesh;
std::uint32_t meshSize;
};
@ -73,6 +73,7 @@ private:
public:
std::vector<GLfloat> getVertex() const;
std::vector<GLfloat> getUV() const;
std::list<std::uint32_t> getSize() const;
std::list<std::string> getTexture() const;
};

View File

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

View File

@ -124,9 +124,6 @@ void Object::loadChunks(std::list<ChunkHeader*>& destination, std::streampos sta
}
} while (true);
std::cout << "got all chunks, totaly found: " << destination.size() << std::endl;
}
void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
@ -180,7 +177,6 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
if (!strcmp("MODL", (*it)->name))
{
Modl* tempModl = new Modl;
setModlDefault(tempModl);
@ -313,12 +309,10 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
continue;
}
}
}
void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
{
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
{
if (!strcmp("SEGM", (*it)->name))
@ -359,14 +353,13 @@ void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>&
continue;
}
}
}
void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
{
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);
/* shadow mesh geometry
@ -379,9 +372,9 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
> 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<ChunkHeader*>&
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<ChunkHeader*>&
continue;
}
}
}
void Object::readVertex(Modl* dataDestination, std::streampos position)
@ -571,6 +563,16 @@ std::vector<GLfloat> Object::getUV() const
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> tempData;

View File

@ -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)
{

View File

@ -11,3 +11,20 @@ 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.
### 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.