From c8e427ad231652cfd68f7cfc2615c64a606c1e58 Mon Sep 17 00:00:00 2001 From: hristo Date: Tue, 2 Feb 2021 11:49:42 +0200 Subject: Update loading of gltf animation. (#1561) This is to account for GLTF info being more like instructions on how to build your animation instead of verbose description of each pose. --- examples/models/models_gltf_animation.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/models/models_gltf_animation.c b/examples/models/models_gltf_animation.c index e3120500..0efced5e 100644 --- a/examples/models/models_gltf_animation.c +++ b/examples/models/models_gltf_animation.c @@ -50,10 +50,11 @@ int main(void) int animsCount = 0; ModelAnimation *anims = LoadModelAnimations("resources/gltf/rigged_figure.glb", &animsCount); int animFrameCounter = 0; + int animationDirection = 1; SetCameraMode(camera, CAMERA_FREE); // Set free camera mode - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(30); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -66,9 +67,15 @@ int main(void) // Play animation when spacebar is held down if (IsKeyDown(KEY_SPACE)) { - animFrameCounter++; + animFrameCounter += animationDirection; + + if (animFrameCounter >= anims[0].frameCount || animFrameCounter <= 0) + { + animationDirection *= -1; + animFrameCounter += animationDirection; + } + UpdateModelAnimation(model, anims[0], animFrameCounter); - if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0; } //---------------------------------------------------------------------------------- -- cgit v1.2.3