read msh in,

handle non UVed msh,
next test UVed msh + dynamical switch between UVed/not UVed
This commit is contained in:
Anakin
2016-10-17 17:49:44 +02:00
parent e583c361ec
commit c3d73895c7
2 changed files with 29 additions and 16 deletions

View File

@@ -34,6 +34,7 @@ Object::Object(const char* path)
if (!strcmp("MODL", (*it)->name))
{
Modl* tempModl = new Modl;
setModlDefault(tempModl);
// get all subchunks
std::list<ChunkHeader*> tempChunks;
@@ -342,9 +343,9 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
}
std::cout << "vertices" << std::endl;
std::cout << "triangles: " << dataDestination->meshSize << std::endl;
for (int i = 0; i < dataDestination->meshSize; i += 3)
std::cout << dataDestination->mesh[i] << " - " << dataDestination->mesh[i + 1] << " - " << dataDestination->mesh[i + 2] << std::endl;
std::cout << dataDestination->mesh[i] << " <> " << dataDestination->mesh[i + 1] << " <> " << dataDestination->mesh[i + 2] << std::endl;
continue;
@@ -414,12 +415,18 @@ void Object::readVertex(Modl* dataDestination, std::streampos position)
dataDestination->vertex = new float[tempSize * 3];
for (unsigned int i = 0; i < tempSize; i += 3)
for (unsigned int i = 0; i < tempSize * 3; i += 3)
{
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i]), sizeof(float));
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i + 1]), sizeof(float));
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i + 2]), sizeof(float));
}
std::cout << "Vertex number: " << tempSize << std::endl;
for (int i = 0; i < tempSize * 3; i += 3)
std::cout << dataDestination->vertex[i] << " <> " << dataDestination->vertex[i + 1] << " <> " << dataDestination->vertex[i + 2] << std::endl;
}
void Object::readUV(Modl* dataDestination, std::streampos position)
@@ -452,11 +459,11 @@ std::vector<GLfloat> Object::getVertex() const
for (std::list<Modl*>::const_iterator it = lModls.begin(); it != lModls.end(); it++)
{
for (int i = 0; i < (*it)->meshSize; i += 3)
for (unsigned int i = 0; i < (*it)->meshSize; i++)
{
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i]]);
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] + 1]);
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] + 2]);
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] * 3]);
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] * 3 + 1]);
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] * 3 + 2]);
}
}
@@ -470,8 +477,12 @@ std::vector<GLfloat> Object::getUV() const
for (std::list<Modl*>::const_iterator it = lModls.begin(); it != lModls.end(); it++)
{
if ((*it)->uv == NULL)
{
for (unsigned int i = 0; i < (*it)->meshSize; i++)
tempData.push_back(1.0);
continue;
for (int i = 0; i < (*it)->meshSize; i++)
}
for (unsigned int i = 0; i < (*it)->meshSize; i++)
{
tempData.push_back((GLfloat)(*it)->uv[(*it)->mesh[i]]);
}