summaryrefslogtreecommitdiffhomepage
path: root/examples/models
diff options
context:
space:
mode:
authorprocfxgen <[email protected]>2021-09-10 15:24:01 +0200
committerGitHub <[email protected]>2021-09-10 15:24:01 +0200
commita422d2fc8b633ba14bba922f9a74c1be6a72ce39 (patch)
treeed2297327f473280530fc37ab1dff86bcf62ac2b /examples/models
parent803094f41f887c43852a09870d8d0e05ee5f687f (diff)
downloadraylib-a422d2fc8b633ba14bba922f9a74c1be6a72ce39.tar.gz
raylib-a422d2fc8b633ba14bba922f9a74c1be6a72ce39.zip
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
Diffstat (limited to 'examples/models')
-rw-r--r--examples/models/models_magicavoxel_loading.c12
1 files changed, 5 insertions, 7 deletions
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;
}