display all models from a mesh,
problem, apply different model matrices for each model, solution give a list of all models to ogl controller, where they are handled, next steps: find solution for wrong rotation + draw ALL models instead of only the first
This commit is contained in:
@@ -73,6 +73,7 @@ void Object::setModlDefault(Modl * model)
|
||||
model->parent = "";
|
||||
model->type = null;
|
||||
model->renderFlags = -1;
|
||||
model->m4x4Translation = glm::mat4(1.0f);
|
||||
model->tran.scale[0] = 0;
|
||||
model->tran.scale[1] = 0;
|
||||
model->tran.scale[2] = 0;
|
||||
@@ -196,7 +197,7 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
|
||||
}
|
||||
|
||||
// save Model data
|
||||
lModls.push_back(tempModl);
|
||||
vModls.push_back(tempModl);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -265,17 +266,54 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
|
||||
|
||||
if (!strcmp("TRAN", (*it)->name))
|
||||
{
|
||||
float tempScale[3];
|
||||
float tempRotation[4];
|
||||
float tempTrans[3];
|
||||
|
||||
fsMesh.seekg((*it)->position);
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.scale[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.scale[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.scale[2]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.rotation[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.rotation[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.rotation[2]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.rotation[3]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.translation[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.translation[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->tran.translation[2]), sizeof(float));
|
||||
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempScale[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempScale[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempScale[2]), sizeof(float));
|
||||
|
||||
//TODO: rotation value is wrong
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[2]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempRotation[3]), sizeof(float));
|
||||
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempTrans[0]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempTrans[1]), sizeof(float));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempTrans[2]), sizeof(float));
|
||||
|
||||
dataDestination->m4x4Translation = glm::scale(
|
||||
dataDestination->m4x4Translation,
|
||||
glm::vec3(tempScale[0], tempScale[1], tempScale[2])
|
||||
);
|
||||
|
||||
dataDestination->m4x4Translation = glm::translate(
|
||||
dataDestination->m4x4Translation,
|
||||
glm::vec3(tempTrans[0], tempTrans[1], tempTrans[2])
|
||||
);
|
||||
|
||||
dataDestination->m4x4Translation = glm::rotate(
|
||||
dataDestination->m4x4Translation,
|
||||
tempRotation[0],
|
||||
glm::vec3(1, 0, 0)
|
||||
);
|
||||
|
||||
dataDestination->m4x4Translation = glm::rotate(
|
||||
dataDestination->m4x4Translation,
|
||||
tempRotation[1],
|
||||
glm::vec3(0, 1, 0)
|
||||
);
|
||||
|
||||
dataDestination->m4x4Translation = glm::rotate(
|
||||
dataDestination->m4x4Translation,
|
||||
tempRotation[2],
|
||||
glm::vec3(0, 0, 1)
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -528,8 +566,11 @@ std::vector<GLfloat> Object::getVertex() const
|
||||
{
|
||||
std::vector<GLfloat> tempData;
|
||||
|
||||
for (std::list<Modl*>::const_iterator it = lModls.begin(); it != lModls.end(); it++)
|
||||
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
|
||||
{
|
||||
if ((*it)->renderFlags == 1)
|
||||
continue;
|
||||
|
||||
for (unsigned int i = 0; i < (*it)->meshSize; i++)
|
||||
{
|
||||
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] * 3]);
|
||||
@@ -545,8 +586,11 @@ std::vector<GLfloat> Object::getUV() const
|
||||
{
|
||||
std::vector<GLfloat> tempData;
|
||||
|
||||
for (std::list<Modl*>::const_iterator it = lModls.begin(); it != lModls.end(); it++)
|
||||
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
|
||||
{
|
||||
if ((*it)->renderFlags == 1)
|
||||
continue;
|
||||
|
||||
if ((*it)->uv == NULL)
|
||||
{
|
||||
for (unsigned int i = 0; i < (*it)->meshSize; i++)
|
||||
@@ -563,12 +607,17 @@ std::vector<GLfloat> Object::getUV() const
|
||||
return tempData;
|
||||
}
|
||||
|
||||
std::list<std::uint32_t> Object::getSize() const
|
||||
std::uint32_t Object::getSize() const
|
||||
{
|
||||
std::list<std::uint32_t> tempData;
|
||||
std::uint32_t tempData(0);
|
||||
|
||||
for (std::list<Modl*>::const_iterator it = lModls.begin(); it != lModls.end(); it++)
|
||||
tempData.push_back((*it)->meshSize);
|
||||
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
|
||||
{
|
||||
if ((*it)->renderFlags == 1)
|
||||
continue;
|
||||
|
||||
tempData += (*it)->meshSize;
|
||||
}
|
||||
|
||||
return tempData;
|
||||
}
|
||||
@@ -577,12 +626,22 @@ std::list<std::string> Object::getTexture() const
|
||||
{
|
||||
std::list<std::string> tempData;
|
||||
|
||||
for (std::list<Modl*>::const_iterator it = lModls.begin(); it != lModls.end(); it++)
|
||||
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
|
||||
{
|
||||
if ((*it)->renderFlags == 1)
|
||||
continue;
|
||||
|
||||
tempData.push_back((*it)->texture);
|
||||
}
|
||||
|
||||
return tempData;
|
||||
}
|
||||
|
||||
std::vector<Modl*> Object::getModels() const
|
||||
{
|
||||
return vModls;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// public functions
|
||||
|
||||
Reference in New Issue
Block a user