提示画像ですがテクスチャのUV展開ですがなぜ立方体の提示画像ように画像が反転してしまうのでしょうか?またなぜUV展開の画像は画像の端からではなく
F1 E1 D1 分の空白があるのでしょうか? UV展開画像はblenderの展開図です。
知りたい事
1、テクスチャが反転して描画されてしまう原因が知りたい。
2、なぜ F1 E1 D1 分テクスチャ画像の空白があるのか知りたい。
#####試したこと
UV座標のY軸をマイナスして表示してみました。
Model.cpp
// ##################################### .objファイル読み込み ##################################### void FrameWork::D3::LoadObj(const char *fileName, ObjFile &attribute) { ObjFile obj; std::vector<int> vertexIndex; std::vector<int> uvIndex; std::vector<int> normalIndex; std::vector<glm::vec3> vertex; std::vector<glm::vec2> uv; std::vector<glm::vec3> normal; FILE *file = fopen(fileName, "r"); if (file == NULL) { std::cerr << ".OBJファイルが開けません: " << fileName << std::endl; assert(0); } else { while (true) { char line[500]; int res = fscanf(file, "%s", line); if (res == EOF) { break; } if (strcmp(line, "v") == 0) { glm::vec3 vert; fscanf(file, "%f %f %fn", &vert.x, &vert.y, &vert.z); vertex.push_back(vert); } else if (strcmp(line, "vt") == 0) { glm::vec2 u; fscanf(file, "%f %fn", &u.x, &u.y); uv.push_back(u); } else if (strcmp(line, "vn") == 0) { glm::vec3 norm; fscanf(file, "%f %f %fn", &norm.x, &norm.y, &norm.z); normal.push_back(norm); } else if (strcmp(line, "f") == 0) { unsigned int v[3], u[3], n[3]; int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%dn", &v[0], &u[0], &n[0], &v[1], &u[1], &n[1], &v[2], &u[2], &n[2]); vertexIndex.push_back(v[0]); vertexIndex.push_back(v[1]); vertexIndex.push_back(v[2]); uvIndex.push_back(u[0]); uvIndex.push_back(u[1]); uvIndex.push_back(u[2]); normalIndex.push_back(n[0]); normalIndex.push_back(n[1]); normalIndex.push_back(n[2]); } } for (unsigned int i = 0; i < vertexIndex.size(); i++) { unsigned int vi = vertexIndex[i]; unsigned int ui = uvIndex[i]; unsigned int ni = normalIndex[i]; glm::vec3 v = vertex[vi - 1]; glm::vec2 u = uv[ui - 1]; glm::vec3 n = normal[ni - 1]; VertexAttribute attrib; attrib.position[0] = v.x; attrib.position[1] = v.y; attrib.position[2] = v.z; attrib.uv[0] = u.x; attrib.uv[1] = u.y; attrib.normal[0] = n.x; attrib.normal[1] = n.y; attrib.normal[2] = n.z; obj.attribute.push_back(attrib); } } attribute = obj; }
あなたの回答
tips
プレビュー