提示コードですが参考サイトより
テクスチャ座標はほぼ同じですが、Assimp ではモデルが頂点ごとに最大 8 つの異なるテクスチャ座標を持つことができます。8 は使用しません。テクスチャ座標の最初のセットのみを考慮します。また、メッシュに実際にテクスチャ座標が含まれているかどうかも確認します (常にそうであるとは限りません)。
という説明がりますが頂点にはUV座標は一つのみという常識があると思うのですがこの文章は何がいいたいのでしょうか?
知りたいこと
モデルが頂点ごとに最大 8 つの異なるテクスチャ座標を持つことができます
は何を言っているのか知りたい
参考サイトコード:https://learnopengl.com/code_viewer_gh.php?code=includes/learnopengl/model.h
参考サイト:https://learnopengl.com/Model-Loading/Model
cpp
1 2/*############################################################################################ 3# モデル ロード 4############################################################################################*/ 5FrameWork::Model FrameWork::Resource::LoadModel(const std::string path) 6{ 7 Assimp::Importer importer; 8 9 const aiScene* scene = importer.ReadFile("asset/model/mesh.fbx", 10 aiProcess_CalcTangentSpace | 11 aiProcess_Triangulate | 12 aiProcess_JoinIdenticalVertices | 13 aiProcess_SortByPType); 14 15 ProcessNode(scene->mRootNode, scene); 16 17 18 19 20 21 FrameWork::Model model; 22 23 model.mesh = meshes; 24 25 26 27 28 meshes.clear(); 29 return model; 30} 31 32void FrameWork::Resource::ProcessNode(aiNode* node, const aiScene* scene) 33{ 34 for (unsigned int i = 0; i < node->mNumMeshes; i++) 35 { 36 aiMesh* mesh = scene->mMeshes[node->mMeshes[i]]; 37 meshes.push_back(ProcessMesh(mesh, scene)); 38 } 39 40 for (unsigned int i = 0; i < node->mNumChildren; i++) 41 { 42 ProcessNode(node->mChildren[i], scene); 43 } 44 45} 46 47FrameWork::Mesh FrameWork::Resource::ProcessMesh(aiMesh* mesh, const aiScene* scene) 48{ 49 std::vector<VertexAttribute> vertices; 50 std::vector<unsigned int> indices; 51 52 for (unsigned int i = 0; i < mesh->mNumVertices; i++) 53 { 54 VertexAttribute vertex; 55 56 vertex.position[0] = mesh->mVertices[i].x; 57 vertex.position[1] = mesh->mVertices[i].y; 58 vertex.position[2] = mesh->mVertices[i].z; 59/////////////////////////////////////////////////////////////////////////// 60 //テクスチャ座標があるかどうか? 61 if (mesh->mTextureCoords[0] != nullptr) 62 { 63 vertex.uv[0] = mesh->mTextureCoords[0][i].x; 64 vertex.uv[1] = mesh->mTextureCoords[0][i].y; 65 } 66 else 67 { 68 vertex.uv[0] = 0.0f; 69 vertex.uv[1] = 0.0f; 70 } 71/////////////////////////////////////////////////////////////////////////// 72 73 74 vertices.push_back(vertex); 75 } 76 77 for (unsigned int i = 0; i < mesh->mNumFaces; i++) 78 { 79 aiFace face = mesh->mFaces[i]; 80 for (unsigned int j = 0; j < face.mNumIndices; j++) 81 { 82 indices.push_back(face.mIndices[j]); 83 } 84 } 85 86 Mesh data; 87 data.vertex = vertices; 88 data.index = indices; 89 90 91 return data; 92} 93
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。