parent
0fefc6168b
commit
c28a12cd8f
|
@ -44,4 +44,5 @@ private:
|
|||
void readUV(Segment* dataDestination, std::streampos position);
|
||||
|
||||
QMatrix4x4 getParentMatrix(std::string parent) const;
|
||||
QQuaternion getParentRotation(std::string parent) const;
|
||||
};
|
|
@ -10,8 +10,6 @@ GeometryEngine::GeometryEngine()
|
|||
: m_indexBuf(QOpenGLBuffer::IndexBuffer)
|
||||
{
|
||||
initializeOpenGLFunctions();
|
||||
|
||||
loadFile("..\\Release\\Msh\\cubeTex.msh");
|
||||
}
|
||||
|
||||
GeometryEngine::~GeometryEngine()
|
||||
|
@ -63,9 +61,10 @@ void GeometryEngine::loadFile(const char* filePath)
|
|||
new_info.modelMatrix = modelIterator->m4x4Translation;
|
||||
new_info.modelMatrix.rotate(modelIterator->quadRotation);
|
||||
|
||||
// add offset to indices
|
||||
for (auto& it : segmentIterator->indices)
|
||||
it += vertexOffset;
|
||||
// add offset to indices, no need to do it for the first one (maybe it's very big)
|
||||
if(vertexOffset != 0)
|
||||
for (auto& it : segmentIterator->indices)
|
||||
it += vertexOffset;
|
||||
|
||||
// save data
|
||||
vertexData += segmentIterator->vertices;
|
||||
|
|
|
@ -291,14 +291,14 @@ void MshFile::analyseModlChunks(Model * dataDestination, std::list<ChunkHeader*>
|
|||
for (int i = 0; i < 3; i++)
|
||||
m_file.read(F2V(tmp_trans[i]), sizeof(float));
|
||||
|
||||
// modify the matrix
|
||||
// modify the matrix and quaternion
|
||||
dataDestination->m4x4Translation.scale(tmp_scale[0], tmp_scale[1], tmp_scale[2]);
|
||||
dataDestination->m4x4Translation.translate(tmp_trans[0], tmp_trans[1], tmp_trans[2]);
|
||||
dataDestination->quadRotation.setVector(QVector3D(tmp_rotation[0], tmp_rotation[1], tmp_rotation[2]));
|
||||
dataDestination->quadRotation.setScalar(tmp_rotation[3]);
|
||||
|
||||
dataDestination->m4x4Translation = getParentMatrix(dataDestination->parent) * dataDestination->m4x4Translation;
|
||||
|
||||
dataDestination->quadRotation = getParentRotation(dataDestination->parent) * dataDestination->quadRotation;
|
||||
}
|
||||
|
||||
// geometry data
|
||||
|
@ -406,10 +406,7 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
|
|||
else if (!strcmp("STRP", it->name))
|
||||
{
|
||||
// don't get null, bone, shadowMesh and hidden mesh indices
|
||||
if (m_currentType == null ||
|
||||
m_currentType == bone ||
|
||||
m_currentType == shadowMesh ||
|
||||
m_currentRenderFlag == 1)
|
||||
if (m_currentType == null || m_currentType == bone || m_currentType == shadowMesh || m_currentRenderFlag == 1)
|
||||
continue;
|
||||
|
||||
// jump to the data section and read the size;
|
||||
|
@ -455,7 +452,7 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
|
|||
for (unsigned int tri = 0; tri < tmp_multiPolySize - 2; tri++)
|
||||
// ..calculate the edge indices
|
||||
for (int triEdge = 0; triEdge < 3; triEdge++)
|
||||
new_segment->indices.push_back((GLuint)tmp_buffer[(tri + triEdge - ((tri % 2) * (triEdge - 1) * 2))]);
|
||||
new_segment->indices.push_back(tmp_buffer[(tri + triEdge - ((tri % 2) * (triEdge - 1) * 2))]);
|
||||
}
|
||||
|
||||
} // if 2 high bits are set
|
||||
|
@ -475,7 +472,7 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
|
|||
for (unsigned int tri = 0; tri < tmp_multiPolySize - 2; tri++)
|
||||
// ..calculate the edge indices
|
||||
for (int triEdge = 0; triEdge < 3; triEdge++)
|
||||
new_segment->indices.push_back((GLuint)tmp_buffer[(tri + triEdge - ((tri % 2) * (triEdge - 1) * 2))]);
|
||||
new_segment->indices.push_back(tmp_buffer[(tri + triEdge - ((tri % 2) * (triEdge - 1) * 2))]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -610,7 +607,6 @@ QMatrix4x4 MshFile::getParentMatrix(std::string parent) const
|
|||
{
|
||||
if (!strcmp(parent.c_str(), it->name.c_str()))
|
||||
{
|
||||
//TODO: the other way around??
|
||||
matrix = getParentMatrix(it->parent) * it->m4x4Translation;
|
||||
break;
|
||||
}
|
||||
|
@ -618,3 +614,19 @@ QMatrix4x4 MshFile::getParentMatrix(std::string parent) const
|
|||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
QQuaternion MshFile::getParentRotation(std::string parent) const
|
||||
{
|
||||
QQuaternion rotation;
|
||||
|
||||
for (auto& it : *m_models)
|
||||
{
|
||||
if (!strcmp(parent.c_str(), it->name.c_str()))
|
||||
{
|
||||
rotation = getParentRotation(it->parent) * it->quadRotation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#include "Header\MainWindow.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue