summaryrefslogtreecommitdiffhomepage
path: root/examples/models/models_loading_vox.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2021-10-19 14:58:04 +0200
committerraysan5 <[email protected]>2021-10-19 14:58:04 +0200
commit2e151408bb54204b07985da41c260665a7f9376b (patch)
treeb9320791dfd5db5187521ebcbae548a3c2932480 /examples/models/models_loading_vox.c
parentfec0ce34c5da82fcd36446abddd235e36bc0f5be (diff)
downloadraylib-2e151408bb54204b07985da41c260665a7f9376b.tar.gz
raylib-2e151408bb54204b07985da41c260665a7f9376b.zip
REVIEWED: models_yaw_pitch_roll
Diffstat (limited to 'examples/models/models_loading_vox.c')
-rw-r--r--examples/models/models_loading_vox.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/examples/models/models_loading_vox.c b/examples/models/models_loading_vox.c
index 7836cdd3..dca17590 100644
--- a/examples/models/models_loading_vox.c
+++ b/examples/models/models_loading_vox.c
@@ -19,10 +19,10 @@
int main(void)
{
- // Initialization
- //--------------------------------------------------------------------------------------
- const int screenWidth = 800;
- const int screenHeight = 450;
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
const char *voxFileNames[] = {
"resources/models/vox/chr_knight.vox",
@@ -30,7 +30,7 @@ int main(void)
"resources/models/vox/monu9.vox"
};
- InitWindow(screenWidth, screenHeight, "raylib [models] example - magicavoxel loading");
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - magicavoxel loading");
// Define the camera to look into our 3d world
Camera camera = { 0 };
@@ -40,61 +40,61 @@ int main(void)
camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
- // Load MagicaVoxel files
- Model models[MAX_VOX_FILES] = { 0 };
+ // Load MagicaVoxel files
+ Model models[MAX_VOX_FILES] = { 0 };
- for (int i = 0; i < MAX_VOX_FILES; i++)
- {
+ for (int i = 0; i < MAX_VOX_FILES; i++)
+ {
// Load VOX file and measure time
- double t0 = GetTime()*1000.0;
- models[i] = LoadModel(voxFileNames[i]);
- double t1 = GetTime()*1000.0;
-
+ double t0 = GetTime()*1000.0;
+ models[i] = LoadModel(voxFileNames[i]);
+ double t1 = GetTime()*1000.0;
+
TraceLog(LOG_WARNING, TextFormat("[%s] File loaded in %.3f ms", voxFileNames[i], t1 - t0));
- // Compute model translation matrix to center model on draw position (0, 0 , 0)
- BoundingBox bb = GetModelBoundingBox(models[i]);
- Vector3 center = { 0 };
- center.x = bb.min.x + (((bb.max.x - bb.min.x)/2));
- center.z = bb.min.z + (((bb.max.z - bb.min.z)/2));
+ // Compute model translation matrix to center model on draw position (0, 0 , 0)
+ BoundingBox bb = GetModelBoundingBox(models[i]);
+ Vector3 center = { 0 };
+ 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 matTranslate = MatrixTranslate(-center.x, 0, -center.z);
- models[i].transform = matTranslate;
- }
+ Matrix matTranslate = MatrixTranslate(-center.x, 0, -center.z);
+ models[i].transform = matTranslate;
+ }
- int currentModel = 0;
+ int currentModel = 0;
- SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
+ SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
- //--------------------------------------------------------------------------------------
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
- // Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
- {
- // Update
- //----------------------------------------------------------------------------------
- UpdateCamera(&camera); // Update our camera to orbit
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ UpdateCamera(&camera); // Update our camera to orbit
// Cycle between models on mouse click
- if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%MAX_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 >= MAX_VOX_FILES) currentModel = 0;
- }
- else if (IsKeyPressed(KEY_LEFT))
- {
- currentModel--;
- if (currentModel < 0) currentModel = MAX_VOX_FILES - 1;
- }
- //----------------------------------------------------------------------------------
-
- // Draw
- //----------------------------------------------------------------------------------
- BeginDrawing();
+ if (IsKeyPressed(KEY_RIGHT))
+ {
+ currentModel++;
+ if (currentModel >= MAX_VOX_FILES) currentModel = 0;
+ }
+ else if (IsKeyPressed(KEY_LEFT))
+ {
+ currentModel--;
+ if (currentModel < 0) currentModel = MAX_VOX_FILES - 1;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
ClearBackground(RAYWHITE);
@@ -112,19 +112,19 @@ int main(void)
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
- EndDrawing();
- //----------------------------------------------------------------------------------
- }
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
- // De-Initialization
- //--------------------------------------------------------------------------------------
- // Unload models data (GPU VRAM)
- for (int i = 0; i < MAX_VOX_FILES; i++) UnloadModel(models[i]);
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ // Unload models data (GPU VRAM)
+ for (int i = 0; i < MAX_VOX_FILES; i++) UnloadModel(models[i]);
- CloseWindow(); // Close window and OpenGL context
- //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
- return 0;
+ return 0;
}