|
|
|
@@ -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;
|
|
|
|
|
}
|
|
|
|
|