Нет соответствующей функции для вызова iterateAccessorWithIndex при использовании fastgltfC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 Нет соответствующей функции для вызова iterateAccessorWithIndex при использовании fastgltf

Сообщение Anonymous »

Я следую vk-guide и использую эту библиотеку для загрузки модели gltf.
Но я сталкиваюсь с этой ошибкой при загрузке вершины.

Код: Выделить всё

Severity    Code    Description Project File    Line    Suppression State   Details
Error   GAF447572   no matching function for call to 'iterateAccessorWithIndex' F:\dev\vulkan\VulkanEngine\out\build\debug\VulkanEngine F:\dev\vulkan\VulkanEngine\renderer\src\huan\utils\gltf\gltf_loader.cpp 67
Вот мой код:

Код: Выделить всё

#include "huan/utils/gltf/gltf_loader.hpp"

#include 
#include 
#include 
#include 

namespace huan
{

std::optional loadGltfMeshes(VulkanEngine* engine, std::filesystem::path filePath)
{

spdlog::info("Loading GLTF meshes from {}", filePath.string());
auto data = fastgltf::GltfDataBuffer::FromPath(filePath);
if (data.error() != fastgltf::Error::None)
{
spdlog::error("Failed to load GLTF data from {}", filePath.string());
return std::nullopt;
}
constexpr auto gltfOptions = fastgltf::Options::LoadGLBBuffers | fastgltf::Options::LoadExternalBuffers;
fastgltf::Parser parser{};
fastgltf::Asset gltfAsset;
auto load = parser.loadGltfBinary(data.get(), filePath.parent_path(), gltfOptions);
if (load.error() == fastgltf::Error::None)
{
gltfAsset = std::move(load.get());
}
else
{
spdlog::error("Failed to parse GLTF binary from {}", filePath.string());
return std::nullopt;
}
std::vector meshes;

// Process the GLTF asset to extract mesh data
std::vector indices;
std::vector vertices;

for (const auto& mesh : gltfAsset.meshes)
{
Ref newMesh = std::make_shared();
// Populate meshAsset with data from mesh
newMesh->name = mesh.name;
indices.clear();
vertices.clear();
for (auto&& prim : mesh.primitives)
{
GeometrySuface newSurface;
newSurface.startIndex = (uint32_t)indices.size();
newSurface.count = (uint32_t)gltfAsset.accessors[prim.indicesAccessor.value()].count;
size_t initialVerticesSize = vertices.size();
// load indices
{
fastgltf::Accessor& indexAccessor = gltfAsset.accessors[prim.indicesAccessor.value()];
indices.reserve(indices.size() + indexAccessor.count);
fastgltf::iterateAccessor(gltfAsset, indexAccessor, [&](std::uint32_t index) {
indices.push_back(index + initialVerticesSize);
});
}
// load vertices
{
fastgltf::Accessor& positionAccessor =
gltfAsset.accessors[prim.findAttribute("POSITION")->accessorIndex];

vertices.resize(vertices.size() + positionAccessor.count);
fastgltf::iterateAccessorWithIndex(
gltfAsset, positionAccessor, [&](glm::vec3 v, size_t index) {
auto& curVertex = vertices[initialVerticesSize + index];
curVertex.position = v;
curVertex.normal = {1, 0, 0};
curVertex.color = glm::vec4(1.0f);
curVertex.uvX = 0;
curVertex.uvY = 0;
});
}
// load normal
if (auto normalAccessor = prim.findAttribute("NORMAL"))
{
fastgltf::Accessor& normalAcc = gltfAsset.accessors[normalAccessor->accessorIndex];
fastgltf::iterateAccessorWithIndex(
gltfAsset, normalAcc,
[&](glm::vec3 n, std::size_t index) { vertices[initialVerticesSize + index].normal = n; });
}
// load UVs
if (auto uvAccessor = prim.findAttribute("TEXCOORD_0"))
{
fastgltf::Accessor&  uvAcc = gltfAsset.accessors[uvAccessor->accessorIndex];
fastgltf::iterateAccessorWithIndex(gltfAsset, uvAcc, [&](glm::vec2 uv, std::size_t index) {
vertices[initialVerticesSize + index].uvX = uv.x;
vertices[initialVerticesSize + index].uvY = uv.y;
});
}
// load vertex color
if (auto colorAccessor = prim.findAttribute("COLOR_0"))
{
fastgltf::Accessor& colorAcc = gltfAsset.accessors[colorAccessor->accessorIndex];
fastgltf::iterateAccessorWithIndex(
gltfAsset, colorAcc,
[&](glm::vec4 color, std::size_t index) { vertices[initialVerticesSize + index].color = color; });
}
newMesh->surfaces.push_back(newSurface);
}

/**
* @brief Display the vertex normal
*/
constexpr bool overrideColors = true;
if (overrideColors)
{
for (auto& vertex : vertices)
{
vertex.color = glm::vec4(vertex.normal * 0.5f + 0.5f, 1.0f);
}
}
newMesh->meshBuffers = engine->uploadMesh(indices, vertices);
meshes.push_back(newMesh);
}

return meshes;
}

} // namespace huan
Я думаю, что это странно, потому что с iterateAccessor все в порядке, но с iterateAccessorWithIndex возникла ошибка.
Я проверяю определение и не нашел в этом ничего плохого.
Это ошибка?

Подробнее здесь: https://stackoverflow.com/questions/793 ... g-fastgltf
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C++»