Files
ViewDesignEngine/include/vde/foundation/io_obj.h
T
2026-07-23 12:36:39 +00:00

36 lines
1.1 KiB
C++

#pragma once
#include <string>
#include <vector>
#include "vde/foundation/math_types.h"
namespace vde::foundation {
struct ObjMeshData {
std::vector<Point3D> vertices;
std::vector<Point2D> texcoords;
std::vector<Vector3D> normals;
/// Vertex indices per face (0-based internally).
/// Always populated regardless of face format.
std::vector<std::vector<int>> faces;
/// Texcoord indices per face (0-based). Empty if the file had no vt data.
/// Same length as faces; each sub-vector same length as corresponding face.
std::vector<std::vector<int>> face_texcoords;
/// Normal indices per face (0-based). Empty if the file had no vn data.
std::vector<std::vector<int>> face_normals;
/// Material name per face group (appears before the faces that use it).
/// The i-th entry gives the material active for the i-th face.
std::vector<std::string> face_materials;
/// Helpers
[[nodiscard]] bool has_texcoords() const { return !texcoords.empty(); }
};
ObjMeshData read_obj(const std::string& filepath);
void write_obj(const std::string& filepath, const ObjMeshData& data);
} // namespace vde::foundation