From a422d2fc8b633ba14bba922f9a74c1be6a72ce39 Mon Sep 17 00:00:00 2001 From: procfxgen Date: Fri, 10 Sep 2021 15:24:01 +0200 Subject: Vox loaded (#1981) * new models_magicavoxel_loading example * Portable header-only file "magicavoxel_loader.h" for MagicaVoxel loader example. * models_magicavoxel_loading example added to CMakeLists.txt and Makefile * fix models_magicavoxel_loading example for linux. * * vox_loader into "src/external/vox_loader.h" * vox file support for "models.c" * updated example "models/models_magicavoxel_loading.c" * * Fix Vox_FreeArrays (removed memory leak) * * removed magicavoxel_loader.h * * Revert vs2019 solution * * vox_loader.h -> Support custom memory allocators * vox_loader.h -> Reverse Y<>Z for left to right handed system * models/models_magicavoxel_loading.c -> fix model center * * vox_loader.h -> Removed Raylib dependencies * * Changed Vox_LoadFileName to Vox_LoadFromMemory --- examples/models/models_magicavoxel_loading.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/models/models_magicavoxel_loading.c b/examples/models/models_magicavoxel_loading.c index bb1389d6..fd268f07 100644 --- a/examples/models/models_magicavoxel_loading.c +++ b/examples/models/models_magicavoxel_loading.c @@ -51,16 +51,14 @@ int main(void) t1 = GetTime() * 1000.0; TraceLog(LOG_INFO, TextFormat("Vox <%s> loaded in %f ms", GetFileName(szVoxFiles[i]), t1 - t0)); - //Compute model matrix + //Compute model's center matrix BoundingBox bb = GetModelBoundingBox(models[i]); Vector3 center; - center.x = -(((bb.max.x - bb.min.x) / 2)); - center.y = -(((bb.max.y - bb.min.y) / 2)); - center.z = -(((bb.max.z - bb.min.z) / 2)); + center.x = bb.min.x + (((bb.max.x - bb.min.x) / 2)); + center.z = bb.min.z + (((bb.max.z - bb.min.z) / 2)); - Matrix matP = MatrixTranslate(center.x, center.z, 0); - Matrix matR = MatrixRotateX(90 * DEG2RAD); - models[i].transform = MatrixMultiply(matP, matR); + Matrix matP = MatrixTranslate(-center.x, 0, -center.z); + models[i].transform = matP; } -- cgit v1.2.3