Skip to content

Commit

Permalink
Review some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Oct 14, 2021
1 parent d7266ea commit 2a6bd97
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
25 changes: 11 additions & 14 deletions examples/models/models_loading_gltf.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
/*******************************************************************************************
*
* raylib [models] example - Load 3d gltf model
* raylib [models] example - Load models gltf
*
* This example has been created using raylib 3.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* NOTE: To export a model from Blender, make sure it is not posed, the vertices need to be
* in the same position as they would be in edit mode.
* Also make sure the scale parameter of your models is set to 0.0,
* scaling can be applied from the export menu.
*
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
*
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
*
********************************************************************************************
*
* To export a model from blender, make sure it is not posed, the vertices need to be in the
* same position as they would be in edit mode.
* and that the scale of your models is set to 0. Scaling can be done from the export menu.
*
********************************************************************************************/

#include "raylib.h"

#include <stdlib.h>

#define MAX_MODELS 8
#define MAX_GLTF_MODELS 8

int main(void)
{
Expand All @@ -41,7 +38,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type

// Load some models
Model model[MAX_MODELS] = { 0 };
Model model[MAX_GLTF_MODELS] = { 0 };
model[0] = LoadModel("resources/models/gltf/raylib_32x32.glb");
model[1] = LoadModel("resources/models/gltf/rigged_figure.glb");
model[2] = LoadModel("resources/models/gltf/GearboxAssy.glb");
Expand Down Expand Up @@ -70,13 +67,13 @@ int main(void)
if (IsKeyReleased(KEY_RIGHT))
{
currentModel++;
if (currentModel == MAX_MODELS) currentModel = 0;
if (currentModel == MAX_GLTF_MODELS) currentModel = 0;
}

if (IsKeyReleased(KEY_LEFT))
{
currentModel--;
if (currentModel < 0) currentModel = MAX_MODELS - 1;
if (currentModel < 0) currentModel = MAX_GLTF_MODELS - 1;
}
//----------------------------------------------------------------------------------

Expand All @@ -99,7 +96,7 @@ int main(void)

// De-Initialization
//--------------------------------------------------------------------------------------
for (int i = 0; i < MAX_MODELS; i++) UnloadModel(model[i]); // Unload models
for (int i = 0; i < MAX_GLTF_MODELS; i++) UnloadModel(model[i]); // Unload models

CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
Expand Down
22 changes: 11 additions & 11 deletions examples/models/models_loading_vox.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*******************************************************************************************
*
* raylib [models] example - magicavoxel loader and viewer
* raylib [models] example - Load models vox (MagicaVoxel)
*
* This example has been created using raylib 3.8 (www.raylib.com)
* This example has been created using raylib 4.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Example contributed by Johann Nadalutti (@procfxgen)
* Example contributed by Johann Nadalutti (@procfxgen) and reviewed by Ramon Santamaria (@raysan5)
*
* Copyright (c) 2021 Johann Nadalutti (@procfxgen)
* Copyright (c) 2021 Johann Nadalutti (@procfxgen) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/

#include "raylib.h"

#include "raymath.h" // Required for: MatrixTranslate()

#define NUM_VOX_FILES 3
#define MAX_VOX_FILES 3

int main(void)
{
Expand All @@ -41,9 +41,9 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type

// Load MagicaVoxel files
Model models[NUM_VOX_FILES] = { 0 };
Model models[MAX_VOX_FILES] = { 0 };

for (int i = 0; i < NUM_VOX_FILES; i++)
for (int i = 0; i < MAX_VOX_FILES; i++)
{
// Load VOX file and measure time
double t0 = GetTime()*1000.0;
Expand Down Expand Up @@ -77,18 +77,18 @@ int main(void)
UpdateCamera(&camera); // Update our camera to orbit

// Cycle between models on mouse click
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%NUM_VOX_FILES;
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%MAX_VOX_FILES;

// Cycle between models on key pressed
if (IsKeyPressed(KEY_RIGHT))
{
currentModel++;
if (currentModel >= NUM_VOX_FILES) currentModel = 0;
if (currentModel >= MAX_VOX_FILES) currentModel = 0;
}
else if (IsKeyPressed(KEY_LEFT))
{
currentModel--;
if (currentModel < 0) currentModel = NUM_VOX_FILES - 1;
if (currentModel < 0) currentModel = MAX_VOX_FILES - 1;
}
//----------------------------------------------------------------------------------

Expand Down Expand Up @@ -119,7 +119,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
// Unload models data (GPU VRAM)
for (int i = 0; i < NUM_VOX_FILES; i++) UnloadModel(models[i]);
for (int i = 0; i < MAX_VOX_FILES; i++) UnloadModel(models[i]);

CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/rmodels.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
#define VOX_FREE RL_FREE

#define VOX_LOADER_IMPLEMENTATION
#include "external/vox_loader.h" // vox file format loading (MagikaVoxel)
#include "external/vox_loader.h" // VOX file format loading (MagikaVoxel)
#endif

#if defined(SUPPORT_MESH_GENERATION)
Expand Down

0 comments on commit 2a6bd97

Please sign in to comment.