Files
top-octane/src/assets/model.hpp
T
2026-11-30 22:31:51 +02:00

58 lines
1.3 KiB
C++

#pragma once
#include "assets/palette.hpp"
#include "core/math.hpp"
#include "core/vfs.hpp"
#include <cstdint>
#include <string>
#include <vector>
namespace top_octane::assets {
struct ObjectTexEntry {
uint32_t offset = 0;
uint16_t x = 0;
uint16_t y = 0;
uint8_t w = 0;
uint8_t h = 0;
};
struct ObjectTextureAtlas {
int width = 256;
int height = 768;
std::vector<uint8_t> rgba;
std::vector<ObjectTexEntry> entries;
bool load(const Vfs& vfs, const Palette& pal, const std::string& dat_path = "OBJECTS/DATA/TEX0-0.DAT",
const std::string& tab_path = "OBJECTS/DATA/TEX0-0.TAB");
};
struct ModelTriangle {
uint16_t v[3]{};
float u[3]{};
float v_coord[3]{};
uint8_t pal_color = 0;
uint8_t flags = 0;
uint8_t tex_id = 0;
bool textured = false;
};
struct ModelVertex {
Vec3 pos; // Converted to OpenGL Y-up (x, z, -y) in model units
Vec3 raw_pos; // Original Bullfrog (x, y, z)
uint8_t shade = 0;
};
struct ModelMesh {
std::string name;
std::vector<ModelVertex> vertices;
std::vector<ModelTriangle> triangles;
Vec3 bounds_min{0, 0, 0};
Vec3 bounds_max{0, 0, 0};
bool load(const Vfs& vfs, const std::string& path, const ObjectTextureAtlas* atlas = nullptr);
};
} // namespace top_octane::assets