From 1bc1cf8cd2c66bbae615a5ddba883b7cd55bd67f Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 07:00:28 +0100 Subject: feat(3d): Implement Blender export and binary scene loading pipeline --- src/tests/test_scene_loader.cc | 107 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 src/tests/test_scene_loader.cc (limited to 'src/tests/test_scene_loader.cc') diff --git a/src/tests/test_scene_loader.cc b/src/tests/test_scene_loader.cc new file mode 100644 index 0000000..e14054b --- /dev/null +++ b/src/tests/test_scene_loader.cc @@ -0,0 +1,107 @@ +#include "3d/scene_loader.h" +#include "util/mini_math.h" +#include "util/asset_manager.h" +#include "generated/assets.h" +#include +#include +#include +#include + +int main() { + Scene scene; + std::vector buffer; + + // Header + const char* magic = "SCN1"; + for(int i=0; i<4; ++i) buffer.push_back(magic[i]); + + uint32_t num_obj = 2; // Increased to 2 + uint32_t num_cam = 0; + uint32_t num_light = 0; + + auto push_u32 = [&](uint32_t v) { + uint8_t* p = (uint8_t*)&v; + for(int i=0; i<4; ++i) buffer.push_back(p[i]); + }; + auto push_f = [&](float v) { + uint8_t* p = (uint8_t*)&v; + for(int i=0; i<4; ++i) buffer.push_back(p[i]); + }; + + push_u32(num_obj); + push_u32(num_cam); + push_u32(num_light); + + // --- Object 1: Basic Cube --- + char name1[64] = {0}; + std::strcpy(name1, "TestObject"); + for(int i=0; i<64; ++i) buffer.push_back(name1[i]); + + push_u32(0); // CUBE + + // Pos + push_f(1.0f); push_f(2.0f); push_f(3.0f); + // Rot (0,0,0,1) + push_f(0.0f); push_f(0.0f); push_f(0.0f); push_f(1.0f); + // Scale + push_f(1.0f); push_f(1.0f); push_f(1.0f); + // Color + push_f(1.0f); push_f(0.0f); push_f(0.0f); push_f(1.0f); + + // Mesh Name length 0 + push_u32(0); + + // Physics + push_f(10.0f); // mass + push_f(0.8f); // restitution + push_u32(1); // static + + // --- Object 2: Mesh with Asset Ref --- + char name2[64] = {0}; + std::strcpy(name2, "MeshObject"); + for(int i=0; i<64; ++i) buffer.push_back(name2[i]); + + push_u32(6); // MESH + + // Pos + push_f(0.0f); push_f(0.0f); push_f(0.0f); + // Rot + push_f(0.0f); push_f(0.0f); push_f(0.0f); push_f(1.0f); + // Scale + push_f(1.0f); push_f(1.0f); push_f(1.0f); + // Color + push_f(0.0f); push_f(1.0f); push_f(0.0f); push_f(1.0f); + + // Mesh Name "MESH_CUBE" + const char* mesh_name = "MESH_CUBE"; + uint32_t mesh_name_len = std::strlen(mesh_name); + push_u32(mesh_name_len); + for(size_t i=0; i