Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ColladaParser::GetMeshData(std::vector<float>& vertices, std::vector<unsigned short>& indices, bool hasAnimation)
- {
- std::vector<unsigned short> jointList; //ids
- std::vector<float> weightList; //vertexWeightData.
- GetVertexSkinning(weightList, jointList);
- if (hasAnimation) {
- //GetVertexSkinning(weightList, jointList);
- //jointList = GetVertexJoints();
- //weightList = GetVertexWeights();
- }
- auto verticesCorrect = GetVertexPositions();
- auto normals = GetVertexNormals();
- auto uvs = GetVertexUVs();
- std::vector<glm::vec3> glmVertices;
- std::vector<glm::vec3> glmNormals;
- std::vector<glm::vec2> glmUVs;
- glmVertices.resize(verticesCorrect.size() / 3);
- glmNormals.resize(normals.size() / 3);
- glmUVs.resize(uvs.size() / 2);
- size_t i = 0;
- for (i = 0; i < verticesCorrect.size() / 3; ++i)
- {
- float x = verticesCorrect[i * 3];
- float y = verticesCorrect[i * 3 + 1];
- float z = verticesCorrect[i * 3 + 2];
- glmVertices[i] = glm::vec3(x, y, z);
- }
- for (i = 0; i < normals.size() / 3; ++i)
- {
- float nx = normals[i * 3];
- float ny = normals[i * 3 + 1];
- float nz = normals[i * 3 + 2];
- glmNormals[i] = glm::vec3(nx, ny, nz);
- }
- for (i = 0; i < uvs.size() / 2; ++i)
- {
- float u = uvs[i * 2];
- float v = uvs[i * 2 + 1];
- glmUVs[i] = glm::vec2(u, v);
- }
- std::vector<unsigned short> newIndices;
- std::vector<glm::vec3> newVertices;
- std::vector<glm::vec2> newUVs;
- std::vector<glm::vec3> newNormals;
- indexVBO(glmVertices, glmUVs, glmNormals, newIndices, newVertices, newUVs, newNormals);
- //if hasAnimation alternamos en 2 opciones.
- vertices.resize(newVertices.size() * 3 + newNormals.size() * 3 + newUVs.size() * 2);
- for (i = 0; i < vertices.size() / 8; ++i)
- {
- vertices[i * 8] = newVertices[i].x * 0.1f;
- vertices[i * 8 + 1] = newVertices[i].y * 0.1f;
- vertices[i * 8 + 2] = newVertices[i].z * 0.1f;
- vertices[i * 8 + 3] = newNormals[i].x;
- vertices[i * 8 + 4] = newNormals[i].y;
- vertices[i * 8 + 5] = newNormals[i].z;
- vertices[i * 8 + 6] = newUVs[i].x;
- vertices[i * 8 + 7] = 1.0f - newUVs[i].y;
- }
- for (i = 0; i < newIndices.size() / 3; ++i)
- {
- indices.push_back(newIndices[i * 3 + 2]);
- indices.push_back(newIndices[i * 3 + 1]);
- indices.push_back(newIndices[i * 3 + 0]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement