REVIEWED: models_gltf_model #1684

This commit is contained in:
raysan5 2021-03-28 20:15:57 +02:00
parent 23a764190e
commit 8f3e91ae83

View file

@ -21,6 +21,8 @@
#include <stdlib.h> #include <stdlib.h>
#define MAX_MODELS 6
int main(void) int main(void)
{ {
// Initialization // Initialization
@ -38,18 +40,16 @@ int main(void)
camera.fovy = 45.0f; // Camera field-of-view Y camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
Model model[7]; Model model[MAX_MODELS] = { 0 };
model[0] = LoadModel("resources/gltf/raylib_32x32.glb"); model[0] = LoadModel("resources/gltf/raylib_32x32.glb");
model[1] = LoadModel("resources/gltf/rigged_figure.glb"); model[1] = LoadModel("resources/gltf/rigged_figure.glb");
model[2] = LoadModel("resources/gltf/Avocado.glb"); model[2] = LoadModel("resources/gltf/GearboxAssy.glb");
model[3] = LoadModel("resources/gltf/GearboxAssy.glb"); model[3] = LoadModel("resources/gltf/BoxAnimated.glb");
model[4] = LoadModel("resources/gltf/BoxAnimated.glb"); model[4] = LoadModel("resources/gltf/AnimatedTriangle.gltf");
model[5] = LoadModel("resources/gltf/AnimatedTriangle.gltf"); model[5] = LoadModel("resources/gltf/AnimatedMorphCube.glb");
model[6] = LoadModel("resources/gltf/AnimatedMorphCube.glb");
int currentModel = 0; int currentModel = 0;
int modelCount = 7;
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
@ -68,13 +68,13 @@ int main(void)
if (IsKeyReleased(KEY_RIGHT)) if (IsKeyReleased(KEY_RIGHT))
{ {
currentModel++; currentModel++;
if (currentModel == modelCount) currentModel = 0; if (currentModel == MAX_MODELS) currentModel = 0;
} }
if (IsKeyReleased(KEY_LEFT)) if (IsKeyReleased(KEY_LEFT))
{ {
currentModel--; currentModel--;
if (currentModel < 0) currentModel = modelCount - 1; if (currentModel < 0) currentModel = MAX_MODELS - 1;
} }
// Draw // Draw
@ -97,7 +97,7 @@ int main(void)
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
for(int i = 0; i < modelCount; i++) UnloadModel(model[i]); // Unload models for(int i = 0; i < MAX_MODELS; i++) UnloadModel(model[i]); // Unload models
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------